@nuxt/webpack-builder 3.1.2 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +52 -5
- package/package.json +12 -12
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pify from 'pify';
|
|
2
|
-
import webpack from 'webpack';
|
|
2
|
+
import webpack, { RuntimeGlobals } from 'webpack';
|
|
3
3
|
import { fromNodeMiddleware, defineEventHandler } from 'h3';
|
|
4
4
|
import webpackDevMiddleware from 'webpack-dev-middleware';
|
|
5
5
|
import webpackHotMiddleware from 'webpack-hot-middleware';
|
|
@@ -16,19 +16,19 @@ import { createFsFromVolume, Volume } from 'memfs';
|
|
|
16
16
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
17
17
|
import querystring from 'node:querystring';
|
|
18
18
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
19
|
+
import ForkTSCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
19
20
|
import { cloneDeep, defaults as defaults$1, merge, uniq } from 'lodash-es';
|
|
20
21
|
import TimeFixPlugin from 'time-fix-plugin';
|
|
21
22
|
import WebpackBar from 'webpackbar';
|
|
22
23
|
import FriendlyErrorsWebpackPlugin from '@nuxt/friendly-errors-webpack-plugin';
|
|
23
24
|
import escapeRegExp from 'escape-string-regexp';
|
|
24
|
-
import
|
|
25
|
+
import { EsbuildPlugin } from 'esbuild-loader';
|
|
25
26
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
26
27
|
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
27
28
|
import VueLoaderPlugin from 'vue-loader/dist/pluginWebpack5.js';
|
|
28
29
|
import { normalizeWebpackManifest } from 'vue-bundle-renderer';
|
|
29
30
|
import hash$1 from 'hash-sum';
|
|
30
31
|
import fse from 'fs-extra';
|
|
31
|
-
import ForkTSCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
32
32
|
|
|
33
33
|
const keyedFunctions = [
|
|
34
34
|
"useState",
|
|
@@ -155,6 +155,31 @@ ${options.globalPublicPath} = buildAssetsURL();
|
|
|
155
155
|
};
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
const pluginName = "ChunkErrorPlugin";
|
|
159
|
+
const script = `
|
|
160
|
+
if (typeof ${RuntimeGlobals.require} !== "undefined") {
|
|
161
|
+
var _ensureChunk = ${RuntimeGlobals.ensureChunk};
|
|
162
|
+
${RuntimeGlobals.ensureChunk} = function (chunkId) {
|
|
163
|
+
return Promise.resolve(_ensureChunk(chunkId)).catch(err => {
|
|
164
|
+
const e = new Event("nuxt.preloadError");
|
|
165
|
+
e.payload = err;
|
|
166
|
+
window.dispatchEvent(e);
|
|
167
|
+
throw err;
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
};`;
|
|
171
|
+
class ChunkErrorPlugin {
|
|
172
|
+
apply(compiler) {
|
|
173
|
+
compiler.hooks.thisCompilation.tap(
|
|
174
|
+
pluginName,
|
|
175
|
+
(compilation) => compilation.mainTemplate.hooks.localVars.tap(
|
|
176
|
+
{ name: pluginName, stage: 1 },
|
|
177
|
+
(source) => source + script
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
158
183
|
function createMFS() {
|
|
159
184
|
const fs = createFsFromVolume(new Volume());
|
|
160
185
|
const _fs = { ...fs };
|
|
@@ -471,7 +496,7 @@ function getEnv(ctx) {
|
|
|
471
496
|
function esbuild(ctx) {
|
|
472
497
|
const { config } = ctx;
|
|
473
498
|
const target = ctx.isServer ? "es2019" : "chrome85";
|
|
474
|
-
config.optimization.minimizer.push(new
|
|
499
|
+
config.optimization.minimizer.push(new EsbuildPlugin());
|
|
475
500
|
config.module.rules.push(
|
|
476
501
|
{
|
|
477
502
|
test: /\.m?[jt]s$/i,
|
|
@@ -971,6 +996,18 @@ function clientPlugins(ctx) {
|
|
|
971
996
|
...options.webpack.analyze === true ? {} : options.webpack.analyze
|
|
972
997
|
}));
|
|
973
998
|
}
|
|
999
|
+
if (!ctx.nuxt.options.ssr) {
|
|
1000
|
+
if (ctx.nuxt.options.typescript.typeCheck === true || ctx.nuxt.options.typescript.typeCheck === "build" && !ctx.nuxt.options.dev) {
|
|
1001
|
+
config.plugins.push(new ForkTSCheckerWebpackPlugin({
|
|
1002
|
+
logger,
|
|
1003
|
+
typescript: {
|
|
1004
|
+
extensions: {
|
|
1005
|
+
vue: { compiler: "@vue/compiler-sfc" }
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}));
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
974
1011
|
}
|
|
975
1012
|
|
|
976
1013
|
function node(ctx) {
|
|
@@ -1067,7 +1104,14 @@ function serverPlugins(ctx) {
|
|
|
1067
1104
|
}));
|
|
1068
1105
|
}
|
|
1069
1106
|
if (ctx.nuxt.options.typescript.typeCheck === true || ctx.nuxt.options.typescript.typeCheck === "build" && !ctx.nuxt.options.dev) {
|
|
1070
|
-
config.plugins.push(new ForkTSCheckerWebpackPlugin({
|
|
1107
|
+
config.plugins.push(new ForkTSCheckerWebpackPlugin({
|
|
1108
|
+
logger,
|
|
1109
|
+
typescript: {
|
|
1110
|
+
extensions: {
|
|
1111
|
+
vue: { compiler: "@vue/compiler-sfc" }
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}));
|
|
1071
1115
|
}
|
|
1072
1116
|
}
|
|
1073
1117
|
|
|
@@ -1084,6 +1128,9 @@ async function bundle(nuxt) {
|
|
|
1084
1128
|
config.plugins.push(DynamicBasePlugin.webpack({
|
|
1085
1129
|
sourcemap: nuxt.options.sourcemap[config.name]
|
|
1086
1130
|
}));
|
|
1131
|
+
if (config.name === "client" && nuxt.options.experimental.emitRouteChunkError) {
|
|
1132
|
+
config.plugins.push(new ChunkErrorPlugin());
|
|
1133
|
+
}
|
|
1087
1134
|
config.plugins.push(composableKeysPlugin.webpack({
|
|
1088
1135
|
sourcemap: nuxt.options.sourcemap[config.name],
|
|
1089
1136
|
rootDir: nuxt.options.rootDir
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/webpack-builder",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"repository": "nuxt/nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/core": "^7.20.12",
|
|
17
17
|
"@nuxt/friendly-errors-webpack-plugin": "^2.5.2",
|
|
18
|
-
"@nuxt/kit": "3.1
|
|
18
|
+
"@nuxt/kit": "3.2.1",
|
|
19
19
|
"autoprefixer": "^10.4.13",
|
|
20
20
|
"css-loader": "^6.7.3",
|
|
21
21
|
"css-minimizer-webpack-plugin": "^4.2.2",
|
|
22
|
-
"cssnano": "^5.1.
|
|
23
|
-
"esbuild-loader": "^
|
|
22
|
+
"cssnano": "^5.1.15",
|
|
23
|
+
"esbuild-loader": "^3.0.1",
|
|
24
24
|
"escape-string-regexp": "^5.0.0",
|
|
25
25
|
"estree-walker": "^3.0.3",
|
|
26
26
|
"file-loader": "^6.2.0",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"fs-extra": "^11.1.0",
|
|
29
29
|
"hash-sum": "^2.0.0",
|
|
30
30
|
"lodash-es": "^4.17.21",
|
|
31
|
-
"magic-string": "^0.
|
|
31
|
+
"magic-string": "^0.29.0",
|
|
32
32
|
"memfs": "^3.4.13",
|
|
33
33
|
"mini-css-extract-plugin": "^2.7.2",
|
|
34
|
-
"mlly": "^1.1.
|
|
34
|
+
"mlly": "^1.1.1",
|
|
35
35
|
"ohash": "^1.0.0",
|
|
36
36
|
"pathe": "^1.1.0",
|
|
37
37
|
"pify": "^6.1.0",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"postcss-url": "^10.1.3",
|
|
42
42
|
"style-resources-loader": "^1.5.0",
|
|
43
43
|
"time-fix-plugin": "^2.0.7",
|
|
44
|
-
"ufo": "^1.0
|
|
45
|
-
"unplugin": "^1.0
|
|
44
|
+
"ufo": "^1.1.0",
|
|
45
|
+
"unplugin": "^1.1.0",
|
|
46
46
|
"url-loader": "^4.1.1",
|
|
47
|
-
"vue-bundle-renderer": "^1.0.
|
|
47
|
+
"vue-bundle-renderer": "^1.0.2",
|
|
48
48
|
"vue-loader": "^17.0.1",
|
|
49
49
|
"webpack": "^5.75.0",
|
|
50
|
-
"webpack-bundle-analyzer": "^4.
|
|
50
|
+
"webpack-bundle-analyzer": "^4.8.0",
|
|
51
51
|
"webpack-dev-middleware": "^6.0.1",
|
|
52
52
|
"webpack-hot-middleware": "^2.25.3",
|
|
53
53
|
"webpack-virtual-modules": "^0.5.0",
|
|
54
54
|
"webpackbar": "^5.0.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@nuxt/schema": "3.1
|
|
57
|
+
"@nuxt/schema": "3.2.1",
|
|
58
58
|
"@types/lodash-es": "^4.17.6",
|
|
59
59
|
"@types/pify": "^5.0.1",
|
|
60
60
|
"@types/webpack-bundle-analyzer": "^4.6.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"vue": "^3.2.47"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
|
-
"node": "^14.
|
|
71
|
+
"node": "^14.18.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {}
|
|
74
74
|
}
|