Repository navigation
REPL: preserve env targets that have no sidebar control - #3267
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
The REPL only kept the `browsers`, `electron` and `node` keys of the `@babel/preset-env` `targets` option when syncing the config editor with the sidebar. Any other valid target written in the config tab, such as `rhino`, `deno`, `chrome` or `esmodules`, was silently dropped as soon as the config was regenerated (toggling any sidebar option, changing the Babel version, ...), so it was effectively impossible to compile for targets like Rhino, which cannot be expressed as a browserslist query. Move the targets parsing into a new `applyTargetsToEnvConfig` helper in replUtils that stores the extra targets in `envConfig.otherTargets`, and merge them back in `buildTransformOpts`. While here: - reset the Electron/Node toggles when the config's targets object no longer contains them, instead of leaving stale values enabled; - accept `targets` (and `targets.browsers`) given as an array of browserslist queries, instead of discarding them. Fixes babel#2843
👷 Deploy request for babel-v9 pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for babel-v8 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The REPL only kept the
browsers,electronandnodekeys of the preset-envtargetsoption when syncing the config tab with the sidebar. Other valid targets such asrhino,deno,chromeoresmoduleswere dropped whenever the config was regenerated (toggling any sidebar option, switching the Babel version, ...). That made it impossible to compile for Rhino, which can't be expressed as a browserslist query in the "Targets" textarea.Steps to reproduce on main: in the Config tab, set
"presets": [["env", { "targets": { "rhino": "1.7.14" } }]], then toggle any env preset option. Therhinotarget disappears and the output falls back to the default targets.Changes:
Repl.tsxinto a newapplyTargetsToEnvConfighelper inreplUtils.ts. Targets without a dedicated control are stored inenvConfig.otherTargetsand merged back inbuildTransformOpts.targets(andtargets.browsers) given as an array of browserslist queries instead of discarding them.I tested this by bundling
replUtils.tsand running the config → sidebar state → config round trip for string, array, object andnulltargets.{ rhino: "1.7.14" }survives a sidebar change, and the regenerated config compiles with@babel/standalone8 for Rhino: arrow functions and default params are transformed and**is kept.Fixes #2843