Skip to content

Commit

Permalink
Remove @babel/preset-modules (#18759)
Browse files Browse the repository at this point in the history
This is a prerequisite to being able to ncc inline the Babel dependencies in next.js.

The removal of preset-modules is based on replacing it with preset-env under `targets: { esmodules: true }`, as per the guidance from the package (https://www.npmjs.com/package/@babel/preset-modules):

> Starting from @babel/preset-env 7.9.0, you can enable the bugfixes: true option to get the same behavior as using @babel/preset-modules, but with support for custom targets. If you need to target browsers with native modules support (like this preset does), you can use targets: { esmodules: true }.

From the above, I'm pretty sure this is entirely a backwards compatible change, apart from the change to the runtime plugin list being visible. Perhaps @developit can confirm this as well.
  • Loading branch information
guybedford authored and styfle committed Nov 4, 2020
1 parent 1e834a9 commit 8e42ed8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
8 changes: 6 additions & 2 deletions packages/next/build/webpack/plugins/next-esm-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ export class NextEsmPlugin implements Plugin {

if (IS_PRESET_ENV.test(name)) {
presets.push([
require.resolve('@babel/preset-modules'),
{ loose: true },
require.resolve('@babel/preset-env'),
{
bugfixes: true,
loose: true,
targets: { esmodules: true },
},
])
} else {
presets.push([name, opts])
Expand Down
1 change: 0 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"@babel/plugin-transform-modules-commonjs": "7.10.4",
"@babel/plugin-transform-runtime": "7.11.5",
"@babel/preset-env": "7.11.5",
"@babel/preset-modules": "0.1.4",
"@babel/preset-react": "7.10.4",
"@babel/preset-typescript": "7.10.4",
"@babel/runtime": "7.11.2",
Expand Down
11 changes: 0 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1355,17 +1355,6 @@
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-transform-flow-strip-types" "^7.10.4"

"@babel/[email protected]":
version "0.1.4"
resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.4.tgz#362f2b68c662842970fdb5e254ffc8fc1c2e415e"
integrity sha512-J36NhwnfdzpmH41M1DrnkkgAqhZaqr/NBdPfQ677mLzlaXo+oDiv1deyCDtgAhz8p328otdob0Du7+xgHGZbKg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-proposal-unicode-property-regex" "^7.4.4"
"@babel/plugin-transform-dotall-regex" "^7.4.4"
"@babel/types" "^7.4.4"
esutils "^2.0.2"

"@babel/preset-modules@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.3.tgz#13242b53b5ef8c883c3cf7dddd55b36ce80fbc72"
Expand Down

0 comments on commit 8e42ed8

Please sign in to comment.