Skip to content

Commit

Permalink
upgrade webpack, remove workaround, update sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Mar 16, 2021
1 parent 9eb1cd4 commit c70adb0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ export default async function getBaseWebpackConfig(
: '[name].js'
: `static/chunks/[name]${dev ? '' : '-[chunkhash]'}.js`,
library: isServer ? undefined : '_N_E',
libraryTarget: isServer ? 'commonjs2' : 'var',
libraryTarget: isServer ? 'commonjs2' : 'assign',
hotUpdateChunkFilename: isWebpack5
? 'static/webpack/[id].[fullhash].hot-update.js'
: 'static/webpack/[id].[hash].hot-update.js',
Expand Down
12 changes: 6 additions & 6 deletions packages/next/bundles/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ commander@^2.20.0:
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

electron-to-chromium@^1.3.634:
version "1.3.689"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.689.tgz#0f4082467c109844b79a7b32a2649c9ab6a6c822"
integrity sha512-WCn+ZaU3V8WttlLNSOGOAlR2XpxibGre7slwGrYBB6oTjYPgP29LNDGG6wLvLTMseLdE+G1vno7PfY7JyDV48g==
version "1.3.690"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.690.tgz#54df63ec42fba6b8e9e05fe4be52caeeedb6e634"
integrity sha512-zPbaSv1c8LUKqQ+scNxJKv01RYFkVVF1xli+b+3Ty8ONujHjAMg+t/COmdZqrtnS1gT+g4hbSodHillymt1Lww==

enhanced-resolve@^5.7.0:
version "5.7.0"
Expand Down Expand Up @@ -476,9 +476,9 @@ watchpack@^2.0.0:
source-map "^0.6.1"

"webpack5@npm:webpack@5":
version "5.26.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.26.1.tgz#164ce73703f88936925dfe843b85806145f4d1e9"
integrity sha512-yepddlLlSfXq9NEIl5udTbETC4kG4UMzdeY4KJfaznFbN1SEIobj89aVVfh/Xei/pKPofGmC8hVT2CJ3Hl/8VQ==
version "5.26.2"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.26.2.tgz#b61c018c9abdb7c67b08e2783ba46fe8723f59e8"
integrity sha512-h07tAPeQceEO3Idrevqv4ECcpMH8Zp0aUUJ+IytujWTVf6TF5PI3rKVw0Z+7rNjU4qJuEx18BykFxgRvR9VgEQ==
dependencies:
"@types/eslint-scope" "^3.7.0"
"@types/estree" "^0.0.46"
Expand Down
21 changes: 16 additions & 5 deletions packages/next/compiled/webpack/bundle5.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = JSON.parse("{\"name\":\"terser\",\"description\":\"JavaScript p
/***/ (function(module) {

"use strict";
module.exports = {"i8":"5.26.1"};
module.exports = {"i8":"5.26.2"};

/***/ }),

Expand Down Expand Up @@ -66289,7 +66289,7 @@ class Template {

/**
* @param {RuntimeModule[]} runtimeModules array of runtime modules in order
* @param {RenderContext & { codeGenerationResults?: CodeGenerationResults }} renderContext render context
* @param {RenderContext & { codeGenerationResults?: CodeGenerationResults, useStrict?: boolean }} renderContext render context
* @returns {Source} rendered runtime modules in a Source object
*/
static renderRuntimeModules(runtimeModules, renderContext) {
Expand Down Expand Up @@ -66320,10 +66320,12 @@ class Template {
source.add(runtimeSource);
} else if (renderContext.runtimeTemplate.supportsArrowFunction()) {
source.add("(() => {\n");
if (renderContext.useStrict) source.add('\t"use strict";\n');
source.add(new PrefixSource("\t", runtimeSource));
source.add("\n})();\n\n");
} else {
source.add("!function() {\n");
if (renderContext.useStrict) source.add('\t"use strict";\n');
source.add(new PrefixSource("\t", runtimeSource));
source.add("\n}();\n\n");
}
Expand Down Expand Up @@ -92787,16 +92789,25 @@ class ArrayPushCallbackChunkFormatPlugin {
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
);
if (runtimeModules.length > 0 || entries.length > 0) {
const strictBailout = hooks.strictRuntimeBailout.call(
renderContext
);
const runtime = new ConcatSource(
(runtimeTemplate.supportsArrowFunction()
? "__webpack_require__ =>"
: "function(__webpack_require__)") +
" { // webpackRuntimeModules\n",
'"use strict";\n\n'
strictBailout
? `// runtime can't be in strict mode because ${strictBailout}.\n\n`
: '"use strict";\n\n'
);
if (runtimeModules.length > 0) {
runtime.add(
Template.renderRuntimeModules(runtimeModules, renderContext)
Template.renderRuntimeModules(runtimeModules, {
...renderContext,
codeGenerationResults: compilation.codeGenerationResults,
useStrict: !!strictBailout
})
);
}
if (entries.length > 0) {
Expand Down Expand Up @@ -94452,7 +94463,7 @@ class JavascriptModulesPlugin {
if (strictBailout) {
source.add(
prefix +
`// runtime can't be in strict mode because ${strictBailout}.`
`// runtime can't be in strict mode because ${strictBailout}.\n`
);
} else {
allStrict = true;
Expand Down
2 changes: 1 addition & 1 deletion test/integration/build-output/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Build Output', () => {
expect(parseFloat(err404FirstLoad)).toBeCloseTo(67.8, 0)
expect(err404FirstLoad.endsWith('kB')).toBe(true)

expect(parseFloat(sharedByAll)).toBeCloseTo(64.4, 1)
expect(parseFloat(sharedByAll)).toBeCloseTo(64.3, 1)
expect(sharedByAll.endsWith('kB')).toBe(true)

if (_appSize.endsWith('kB')) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fallback-modules/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Build Output', () => {
expect(parseFloat(indexSize)).toBeGreaterThanOrEqual(2)
expect(indexSize.endsWith('kB')).toBe(true)

expect(parseFloat(indexFirstLoad)).toBeLessThanOrEqual(67.9)
expect(parseFloat(indexFirstLoad)).toBeLessThanOrEqual(67.8)
expect(parseFloat(indexFirstLoad)).toBeGreaterThanOrEqual(60)
expect(indexFirstLoad.endsWith('kB')).toBe(true)
})
Expand Down

0 comments on commit c70adb0

Please sign in to comment.