forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds inlining for Babel and the Babel plugins used in next. This is based to the PR at vercel#18823. The approach is to make one large bundle and then separate out the individual packages from that in order to avoid duplications. In the first attempt the Babel bundle size was 10MB... using "resolutions" in the Yarn workspace to reduce the duplicated packages this was brought down to a 2.8MB bundle for Babel and all the used plugins which is exactly the expected file size here. This will thus add a 2.8MB download size to the next package, but save downloading any babel dependencies separately, removing a large number of package dependencies from the overall install.
- Loading branch information
1 parent
596ee9c
commit 64850a8
Showing
60 changed files
with
2,961 additions
and
1,023 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
packages/next/build/babel/plugins/next-page-disallow-re-export-all-exports.ts
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
packages/next/build/babel/plugins/no-anonymous-default-export.ts
This file contains 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
6 changes: 5 additions & 1 deletion
6
packages/next/build/babel/plugins/optimize-hook-destructuring.ts
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
packages/next/build/webpack/plugins/wellknown-errors-plugin/parseScss.ts
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
|
||
function codeFrame() { | ||
return require('@babel/code-frame') | ||
} | ||
|
||
function core() { | ||
return require('@babel/core') | ||
} | ||
|
||
function pluginProposalClassProperties() { | ||
return require('@babel/plugin-proposal-class-properties') | ||
} | ||
|
||
function pluginProposalExportNamespaceFrom() { | ||
return require('@babel/plugin-proposal-export-namespace-from') | ||
} | ||
|
||
function pluginProposalNumericSeparator() { | ||
return require('@babel/plugin-proposal-numeric-separator') | ||
} | ||
|
||
function pluginProposalObjectRestSpread() { | ||
return require('@babel/plugin-proposal-object-rest-spread') | ||
} | ||
|
||
function pluginSyntaxBigint() { | ||
return require('@babel/plugin-syntax-bigint') | ||
} | ||
|
||
function pluginSyntaxDynamicImport() { | ||
return require('@babel/plugin-syntax-dynamic-import') | ||
} | ||
|
||
function pluginSyntaxJsx() { | ||
return require('@babel/plugin-syntax-jsx') | ||
} | ||
|
||
function pluginTransformModulesCommonjs() { | ||
return require('@babel/plugin-transform-modules-commonjs') | ||
} | ||
|
||
function pluginTransformRuntime() { | ||
return require('@babel/plugin-transform-runtime') | ||
} | ||
|
||
function presetEnv() { | ||
return require('@babel/preset-env') | ||
} | ||
|
||
function presetReact() { | ||
return require('@babel/preset-react') | ||
} | ||
|
||
function presetTypescript() { | ||
return require('@babel/preset-typescript') | ||
} | ||
|
||
module.exports = { | ||
codeFrame, | ||
core, | ||
pluginProposalClassProperties, | ||
pluginProposalExportNamespaceFrom, | ||
pluginProposalNumericSeparator, | ||
pluginProposalObjectRestSpread, | ||
pluginSyntaxBigint, | ||
pluginSyntaxDynamicImport, | ||
pluginSyntaxJsx, | ||
pluginTransformModulesCommonjs, | ||
pluginTransformRuntime, | ||
presetEnv, | ||
presetReact, | ||
presetTypescript, | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').codeFrame() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').core() |
1 change: 1 addition & 0 deletions
1
packages/next/bundles/babel/packages/plugin-proposal-class-properties.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginProposalClassProperties() |
1 change: 1 addition & 0 deletions
1
packages/next/bundles/babel/packages/plugin-proposal-export-namespace-from.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginProposalExportNamespaceFrom() |
1 change: 1 addition & 0 deletions
1
packages/next/bundles/babel/packages/plugin-proposal-numeric-separator.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginProposalNumericSeparator() |
1 change: 1 addition & 0 deletions
1
packages/next/bundles/babel/packages/plugin-proposal-object-rest-spread.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginProposalObjectRestSpread() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginSyntaxBigint() |
1 change: 1 addition & 0 deletions
1
packages/next/bundles/babel/packages/plugin-syntax-dynamic-import.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginSyntaxDynamicImport() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginSyntaxJsx() |
1 change: 1 addition & 0 deletions
1
packages/next/bundles/babel/packages/plugin-transform-modules-commonjs.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginTransformModulesCommonjs() |
1 change: 1 addition & 0 deletions
1
packages/next/bundles/babel/packages/plugin-transform-runtime.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').pluginTransformRuntime() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').presetEnv() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').presetReact() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./bundle').presetTypescript() |
Oops, something went wrong.