-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use @babel/preset-env with bugfixes for modern builds #702
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'microbundle': patch | ||
--- | ||
|
||
Use @babel/preset-env with bugfixes instead of preset-modules to enable "Optional chaining" & "nullish coalescing" by default. |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,8 @@ const createConfigItems = (babel, type, items) => { | |
}); | ||
}; | ||
|
||
const presetEnvRegex = RegExp(/@babel\/(preset-)?env/); | ||
const environmentPreset = '@babel/preset-env'; | ||
const presetEnvRegex = new RegExp(environmentPreset); | ||
|
||
export default () => { | ||
return createBabelInputPluginFactory(babelCore => { | ||
|
@@ -123,10 +124,6 @@ export default () => { | |
presetEnvRegex.test(preset.file.request), | ||
); | ||
|
||
const environmentPreset = customOptions.modern | ||
? '@babel/preset-modules' | ||
: '@babel/preset-env'; | ||
|
||
if (envIdx !== -1) { | ||
const preset = babelOptions.presets[envIdx]; | ||
babelOptions.presets[envIdx] = babelCore.createConfigItem( | ||
|
@@ -141,6 +138,7 @@ export default () => { | |
}, | ||
preset.options, | ||
{ | ||
bugfixes: customOptions.modern, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can just always be set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sweet |
||
modules: false, | ||
exclude: merge( | ||
['transform-async-to-generator', 'transform-regenerator'], | ||
|
@@ -165,6 +163,7 @@ export default () => { | |
modules: false, | ||
loose: true, | ||
useBuiltIns: false, | ||
bugfixes: customOptions.modern, | ||
exclude: [ | ||
'transform-async-to-generator', | ||
'transform-regenerator', | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export function chain(test: { maybeVar?: { thing: string } }): string | undefined { | ||
return test.maybeVar?.thing; | ||
export function chain(test: { | ||
maybeVar?: { thing: string }; | ||
}): string | undefined { | ||
return test.maybeVar?.thing ?? undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This no longer finds
@babel/env
, which is an alias of@babel/preset-env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I searched for it and couldn't find any usage of it. i'll create a follow up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh - yeah we don't have a test for it, just it's possible to get that value when we read in user config.