Repository navigation
Add --enable-experiment to jaspr build and jaspr serve - #895
Conversation
|
@tomwyr tried this on his end and the build passes with the flag. Thanks for checking, that's the part I couldn't test from 3.12.2. One odd thing in his output: Dart prints |
|
Same question as #896: want this one on For context, @tomwyr confirmed on #877 that the build passes against this branch with |
|
Yes lets also rebase this onto As I wrote in #877 the specific issue is probably already fixed on next (at least I couldn't reproduce on next), but this flag is still a nice feature for future dart language experiments. |
f7391ca to
6eed874
Compare
|
Rebased onto Good to know it doesn't reproduce on |
Package Version ReportThe following packages have been updated: |
Jaspr launches `build_runner` itself, so an app had no way to turn on a Dart language experiment. `build_runner` takes `--enable-experiment` and puts it in a zone that everything inside the build reads: the analyzer behind `buildStep.resolver`, which is what Jaspr's own builders see, and `build_web_compilers` for kernel, ddc, dart2js and dart2wasm. Nothing of that can be reached from the app's `analysis_options.yaml`, which is why a `@client` component written with a primary constructor failed the build while the same component built fine unannotated. The option now goes to `build_runner` from both commands, and to the other places the CLI compiles or runs the app's code: the server, whether `jaspr serve` runs it or `jaspr build` compiles it or runs it to generate a static site, the compiler that generates the stylesheets, and the expression evaluation DWDS does for the debugger. Fixes schultek#877
6eed874 to
d9d67f8
Compare
|
Rebased onto |
There was a problem hiding this comment.
🟢 Approval recommended
The focused argument-forwarding changes have regression coverage and no identified blocking defects, though end-to-end validation of primary constructors remains outstanding.
No open issues 🎉
What changed in this PR
Adds --enable-experiment to jaspr build and jaspr serve, enabling applications to pass Dart language experiments through Jaspr’s build and development workflows for cases such as #877.
Changes:
- Adds shared parsing for repeated and comma-separated experiment options.
- Forwards experiments to build_runner, server execution and compilation, stylesheet compilation, and development compiler settings.
- Adds parsing and command-forwarding tests, plus a changelog entry.
| File | Description |
|---|---|
packages/jaspr/CHANGELOG.md |
Documents the new option. |
packages/jaspr_cli/test/src/commands/serve_command_test.dart |
Tests forwarding to build_runner and the development server. |
packages/jaspr_cli/test/src/commands/build_command_test.dart |
Tests forwarding to build_runner and server compilation. |
packages/jaspr_cli/test/helpers/experiment_helpers_test.dart |
Tests default, single, repeated, and comma-separated options. |
packages/jaspr_cli/lib/src/helpers/experiment_helpers.dart |
Defines shared experiment parsing, help text, and argument formatting. |
packages/jaspr_cli/lib/src/dev/server_runner.dart |
Passes experiments to development and static-rendering servers. |
packages/jaspr_cli/lib/src/dev/dev_workflow.dart |
Passes experiments to stylesheet generation and development compiler settings. |
packages/jaspr_cli/lib/src/dev/css_runner.dart |
Enables experiments during stylesheet compilation. |
packages/jaspr_cli/lib/src/commands/dev_command.dart |
Registers the option and forwards experiments through development workflows. |
packages/jaspr_cli/lib/src/commands/build_command.dart |
Registers the option and forwards experiments through production builds. |
Review effort: Balanced
schultek
left a comment
There was a problem hiding this comment.
LGTM, thanks for this contribution!
Description
Adds
--enable-experimenttojaspr buildandjaspr serve, which is what #877 needs.There was no way for an app to turn a Dart language experiment on. An experiment has to be enabled in three places for a Jaspr app, and the app cannot reach any of them from its own
analysis_options.yaml:buildStep.resolver, which is what Jaspr's own builders see — that is the one that fails in Support primary constructors in @client components #877, withThis requires the 'primary-constructors' language feature to be enabledfromjaspr_builder:client_modulebuild_runneralready covers the first two: it takes--enable-experimentand puts the list in a zone (withEnabledExperiments), whichbuild_resolversturns into the analyzer's feature set andbuild_web_compilersreads for kernel, ddc, dart2js and dart2wasm.build_web_compilerseven points at that flag when it sees an experiment indart2js_args:Since
jasprlaunchesbuild_runnerrather than the user, the flag had nowhere to come from. It now does, and it is passed on in the same shape to the Dart VM invocation injaspr serveand todart compileinjaspr build, so server code may use the experiment as well.Type of Change
Tests
packages/jaspr_cli/test/helpers/experiment_helpers_test.dart, following the shape of the--dart-definetests: no experiments by default, one experiment, the option repeated, and a comma separated list — asserting both what is parsed and the--enable-experiment=<name>flags that get handed on.dart test test/helpersis green inpackages/jaspr_cli(28 tests), and the option shows up injaspr build --helpandjaspr serve --help.What I could not verify here is the end of the chain for #877 specifically: primary constructors need Dart 3.13 and this machine is on 3.12.2, so I confirmed the flag reaches
build_runnerand follows its documented path rather than watching that component build. Worth a check by @tomwyr or anyone on 3.13.Fixes #877