You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add 'dart.tool.dart2wasm' to environment during wasm compilation #61464
Be aware that the current restrictions on conditional imports do not allow using dart.tool.* to choose imports, only dart.library.*.
There is (AFAIK) no non-deprecated library that differ in availability between Wasm from Dart2js.
(We should probably allow some more environment variables to be used, as long as they are correlated to the distinctions we use for modular compilation today. We don't want to introduce more distinct compilation targets for build systems.)
Ah @lrhn is there a plan to allow more environment variables in conditional imports then? As things stand we're actively adding new conditional imports to a now deprecated library. This obviously isn't ideal so we should find an alternative solution sooner rather than later.
No concrete plan, at least not that I'm aware of.
I just keep suggesting it, but we probably want to have a proper design work. Or at least have some agreement on how we'll handle adding more allowed env-variables in the future.
Definitely want anything we add to be coordinated and consistent across platforms.
Assuming we get alignment/design in place. The technical challenges vary a bit. The CFE's logic has a special check to only allow dart.library. and it wouldn't be too much work to expand it to accept more.
The bazel rules, however, have more assumptions about knowing ahead of time the set of configurations that are accepted, and includes logic to discern based on certain library imports. I expect there may be more work needed in that integration than inside our tools, but it's mostly a hunch, I haven't looked closely.
I would definitely, at least initially, go for extensions that align with the existing Bazel configurations.
That is, you can only ask about something that would be consistently true or false for each configuration, and not anything where one configuration could have either value.
I don't know what those configurations are. I hope that no two backends use the same configuration, in which case dart.tool.<backend> should be acceptable.
(If no Bazel configuration uses the analyzer, we can even have dart.tool.analyzer as a configuration, to tell the analyzer which import it should prefer to show instead of always using the first one.)
Other options that are aligned with backends are something like dart.something.webNumbers or even dart.something.minified, if production building is a separate configuration.
Those would be useful to have as constants, and the web-numbers as an import guard to choose between implementations (like what we are trying to do for package:fixednum).
Activity
lrhn commentedon Sep 8, 2025
Be aware that the current restrictions on conditional imports do not allow using
dart.tool.*to choose imports, onlydart.library.*.There is (AFAIK) no non-deprecated library that differ in availability between Wasm from Dart2js.
(We should probably allow some more environment variables to be used, as long as they are correlated to the distinctions we use for modular compilation today. We don't want to introduce more distinct compilation targets for build systems.)
mkustermann commentedon Sep 8, 2025
I believe we already added
dart.tool.dart2wasmto the environment, which allowsconst bool.fromEnvironment('dart.tool.dart2wasm').It's really what @lrhn points out: Those don't work in conditional imports atm
biggs0125 commentedon Sep 8, 2025
Ah @lrhn is there a plan to allow more environment variables in conditional imports then? As things stand we're actively adding new conditional imports to a now deprecated library. This obviously isn't ideal so we should find an alternative solution sooner rather than later.
lrhn commentedon Sep 8, 2025
No concrete plan, at least not that I'm aware of.
I just keep suggesting it, but we probably want to have a proper design work. Or at least have some agreement on how we'll handle adding more allowed env-variables in the future.
Definitely want anything we add to be coordinated and consistent across platforms.
I wrote #54785 as a starting point.
sigmundch commentedon Sep 9, 2025
Assuming we get alignment/design in place. The technical challenges vary a bit. The CFE's logic has a special check to only allow
dart.library.and it wouldn't be too much work to expand it to accept more.The bazel rules, however, have more assumptions about knowing ahead of time the set of configurations that are accepted, and includes logic to discern based on certain library imports. I expect there may be more work needed in that integration than inside our tools, but it's mostly a hunch, I haven't looked closely.
lrhn commentedon Sep 9, 2025
I would definitely, at least initially, go for extensions that align with the existing Bazel configurations.
That is, you can only ask about something that would be consistently true or false for each configuration, and not anything where one configuration could have either value.
I don't know what those configurations are. I hope that no two backends use the same configuration, in which case
dart.tool.<backend>should be acceptable.(If no Bazel configuration uses the analyzer, we can even have
dart.tool.analyzeras a configuration, to tell the analyzer which import it should prefer to show instead of always using the first one.)Other options that are aligned with backends are something like
dart.something.webNumbersor evendart.something.minified, if production building is a separate configuration.Those would be useful to have as constants, and the web-numbers as an import guard to choose between implementations (like what we are trying to do for
package:fixednum).Reference dart-lang/sdk#61464 on deprecated_web_configuration ignores (…