@nuxt/webpack-builder 3.2.2 → 3.3.0
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/README.md +1 -0
- package/dist/index.mjs +29 -32
- package/package.json +16 -13
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Nuxt's goal is to make web development intuitive and performant, with a great de
|
|
|
11
11
|
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
|
|
12
12
|
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
|
|
13
13
|
<a href="./LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
|
|
14
|
+
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Open%20Documentation-18181B?logo=nuxt.js" alt="Website"></a>
|
|
14
15
|
<a href="https://volta.net/nuxt/nuxt?utm_source=nuxt_readme"><img src="https://user-images.githubusercontent.com/904724/209143798-32345f6c-3cf8-4e06-9659-f4ace4a6acde.svg" alt="Volta board"></a>
|
|
15
16
|
</p>
|
|
16
17
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pify from 'pify';
|
|
2
|
-
import webpack
|
|
2
|
+
import webpack 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';
|
|
@@ -11,6 +11,7 @@ import { isAbsolute, relative, join, resolve, normalize, dirname } from 'pathe';
|
|
|
11
11
|
import { walk } from 'estree-walker';
|
|
12
12
|
import MagicString from 'magic-string';
|
|
13
13
|
import { hash } from 'ohash';
|
|
14
|
+
import escapeRE from 'escape-string-regexp';
|
|
14
15
|
import { findStaticImports, parseStaticImport, createCommonJS } from 'mlly';
|
|
15
16
|
import { createFsFromVolume, Volume } from 'memfs';
|
|
16
17
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
@@ -21,7 +22,6 @@ import { cloneDeep, defaults as defaults$1, merge, uniq } from 'lodash-es';
|
|
|
21
22
|
import TimeFixPlugin from 'time-fix-plugin';
|
|
22
23
|
import WebpackBar from 'webpackbar';
|
|
23
24
|
import FriendlyErrorsWebpackPlugin from '@nuxt/friendly-errors-webpack-plugin';
|
|
24
|
-
import escapeRegExp from 'escape-string-regexp';
|
|
25
25
|
import { EsbuildPlugin } from 'esbuild-loader';
|
|
26
26
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
27
27
|
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
@@ -30,16 +30,12 @@ import { normalizeWebpackManifest } from 'vue-bundle-renderer';
|
|
|
30
30
|
import hash$1 from 'hash-sum';
|
|
31
31
|
import fse from 'fs-extra';
|
|
32
32
|
|
|
33
|
-
const keyedFunctions = [
|
|
34
|
-
"useState",
|
|
35
|
-
"useFetch",
|
|
36
|
-
"useAsyncData",
|
|
37
|
-
"useLazyAsyncData",
|
|
38
|
-
"useLazyFetch"
|
|
39
|
-
];
|
|
40
|
-
const KEYED_FUNCTIONS_RE = new RegExp(`(${keyedFunctions.join("|")})`);
|
|
41
33
|
const stringTypes = ["Literal", "TemplateLiteral"];
|
|
42
34
|
const composableKeysPlugin = createUnplugin((options) => {
|
|
35
|
+
const composableMeta = Object.fromEntries(options.composables.map(({ name, ...meta }) => [name, meta]));
|
|
36
|
+
const maxLength = Math.max(...options.composables.map(({ argumentLength }) => argumentLength));
|
|
37
|
+
const keyedFunctions = new Set(options.composables.map(({ name }) => name));
|
|
38
|
+
const KEYED_FUNCTIONS_RE = new RegExp(`\\b(${[...keyedFunctions].map((f) => escapeRE(f)).join("|")})\\b`);
|
|
43
39
|
return {
|
|
44
40
|
name: "nuxt:composable-keys",
|
|
45
41
|
enforce: "post",
|
|
@@ -66,28 +62,32 @@ const composableKeysPlugin = createUnplugin((options) => {
|
|
|
66
62
|
}
|
|
67
63
|
const node = _node;
|
|
68
64
|
const name = "name" in node.callee && node.callee.name;
|
|
69
|
-
if (!name || !keyedFunctions.
|
|
65
|
+
if (!name || !keyedFunctions.has(name) || node.arguments.length >= maxLength) {
|
|
70
66
|
return;
|
|
71
67
|
}
|
|
72
68
|
imports = imports || detectImportNames(script);
|
|
73
69
|
if (imports.has(name)) {
|
|
74
70
|
return;
|
|
75
71
|
}
|
|
72
|
+
const meta = composableMeta[name];
|
|
73
|
+
if (node.arguments.length >= meta.argumentLength) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
76
|
switch (name) {
|
|
77
77
|
case "useState":
|
|
78
|
-
if (
|
|
78
|
+
if (stringTypes.includes(node.arguments[0]?.type)) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
break;
|
|
82
82
|
case "useFetch":
|
|
83
83
|
case "useLazyFetch":
|
|
84
|
-
if (
|
|
84
|
+
if (stringTypes.includes(node.arguments[1]?.type)) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
break;
|
|
88
88
|
case "useAsyncData":
|
|
89
89
|
case "useLazyAsyncData":
|
|
90
|
-
if (
|
|
90
|
+
if (stringTypes.includes(node.arguments[0]?.type) || stringTypes.includes(node.arguments[node.arguments.length - 1]?.type)) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
break;
|
|
@@ -157,9 +157,9 @@ ${options.globalPublicPath} = buildAssetsURL();
|
|
|
157
157
|
|
|
158
158
|
const pluginName = "ChunkErrorPlugin";
|
|
159
159
|
const script = `
|
|
160
|
-
if (typeof ${RuntimeGlobals.require} !== "undefined") {
|
|
161
|
-
var _ensureChunk = ${RuntimeGlobals.ensureChunk};
|
|
162
|
-
${RuntimeGlobals.ensureChunk} = function (chunkId) {
|
|
160
|
+
if (typeof ${webpack.RuntimeGlobals.require} !== "undefined") {
|
|
161
|
+
var _ensureChunk = ${webpack.RuntimeGlobals.ensureChunk};
|
|
162
|
+
${webpack.RuntimeGlobals.ensureChunk} = function (chunkId) {
|
|
163
163
|
return Promise.resolve(_ensureChunk(chunkId)).catch(err => {
|
|
164
164
|
const e = new Event("nuxt.preloadError");
|
|
165
165
|
e.payload = err;
|
|
@@ -340,7 +340,7 @@ function baseConfig(ctx) {
|
|
|
340
340
|
mode: ctx.isDev ? "development" : "production",
|
|
341
341
|
cache: getCache(ctx),
|
|
342
342
|
output: getOutput(ctx),
|
|
343
|
-
stats:
|
|
343
|
+
stats: statsMap[ctx.nuxt.options.logLevel] ?? statsMap.info,
|
|
344
344
|
...ctx.config
|
|
345
345
|
};
|
|
346
346
|
}
|
|
@@ -444,7 +444,7 @@ function baseTranspile(ctx) {
|
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
if (typeof pattern === "string") {
|
|
447
|
-
transpile.push(new RegExp(
|
|
447
|
+
transpile.push(new RegExp(escapeRE(normalize(pattern))));
|
|
448
448
|
} else if (pattern instanceof RegExp) {
|
|
449
449
|
transpile.push(pattern);
|
|
450
450
|
}
|
|
@@ -481,6 +481,7 @@ function getEnv(ctx) {
|
|
|
481
481
|
"process.env.NODE_ENV": JSON.stringify(ctx.config.mode),
|
|
482
482
|
"process.mode": JSON.stringify(ctx.config.mode),
|
|
483
483
|
"process.dev": options.dev,
|
|
484
|
+
__NUXT_VERSION__: JSON.stringify(ctx.nuxt._version),
|
|
484
485
|
"process.env.VUE_ENV": JSON.stringify(ctx.name),
|
|
485
486
|
"process.browser": ctx.isClient,
|
|
486
487
|
"process.client": ctx.isClient,
|
|
@@ -492,6 +493,11 @@ function getEnv(ctx) {
|
|
|
492
493
|
}
|
|
493
494
|
return _env;
|
|
494
495
|
}
|
|
496
|
+
const statsMap = {
|
|
497
|
+
silent: "none",
|
|
498
|
+
info: "normal",
|
|
499
|
+
verbose: "verbose"
|
|
500
|
+
};
|
|
495
501
|
|
|
496
502
|
function esbuild(ctx) {
|
|
497
503
|
const { config } = ctx;
|
|
@@ -999,12 +1005,7 @@ function clientPlugins(ctx) {
|
|
|
999
1005
|
if (!ctx.nuxt.options.ssr) {
|
|
1000
1006
|
if (ctx.nuxt.options.typescript.typeCheck === true || ctx.nuxt.options.typescript.typeCheck === "build" && !ctx.nuxt.options.dev) {
|
|
1001
1007
|
config.plugins.push(new ForkTSCheckerWebpackPlugin({
|
|
1002
|
-
logger
|
|
1003
|
-
typescript: {
|
|
1004
|
-
extensions: {
|
|
1005
|
-
vue: { compiler: "@vue/compiler-sfc" }
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
+
logger
|
|
1008
1009
|
}));
|
|
1009
1010
|
}
|
|
1010
1011
|
}
|
|
@@ -1105,12 +1106,7 @@ function serverPlugins(ctx) {
|
|
|
1105
1106
|
}
|
|
1106
1107
|
if (ctx.nuxt.options.typescript.typeCheck === true || ctx.nuxt.options.typescript.typeCheck === "build" && !ctx.nuxt.options.dev) {
|
|
1107
1108
|
config.plugins.push(new ForkTSCheckerWebpackPlugin({
|
|
1108
|
-
logger
|
|
1109
|
-
typescript: {
|
|
1110
|
-
extensions: {
|
|
1111
|
-
vue: { compiler: "@vue/compiler-sfc" }
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1109
|
+
logger
|
|
1114
1110
|
}));
|
|
1115
1111
|
}
|
|
1116
1112
|
}
|
|
@@ -1133,7 +1129,8 @@ async function bundle(nuxt) {
|
|
|
1133
1129
|
}
|
|
1134
1130
|
config.plugins.push(composableKeysPlugin.webpack({
|
|
1135
1131
|
sourcemap: nuxt.options.sourcemap[config.name],
|
|
1136
|
-
rootDir: nuxt.options.rootDir
|
|
1132
|
+
rootDir: nuxt.options.rootDir,
|
|
1133
|
+
composables: nuxt.options.optimization.keyedComposables
|
|
1137
1134
|
}));
|
|
1138
1135
|
const compiler = webpack(config);
|
|
1139
1136
|
if (nuxt.options.dev) {
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/webpack-builder",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"repository": "nuxt/nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
12
|
+
},
|
|
10
13
|
"./dist/*": "./dist/*"
|
|
11
14
|
},
|
|
12
15
|
"files": [
|
|
13
16
|
"dist"
|
|
14
17
|
],
|
|
15
18
|
"dependencies": {
|
|
16
|
-
"@babel/core": "^7.
|
|
19
|
+
"@babel/core": "^7.21.0",
|
|
17
20
|
"@nuxt/friendly-errors-webpack-plugin": "^2.5.2",
|
|
18
|
-
"@nuxt/kit": "3.
|
|
19
|
-
"autoprefixer": "^10.4.
|
|
21
|
+
"@nuxt/kit": "3.3.0",
|
|
22
|
+
"autoprefixer": "^10.4.14",
|
|
20
23
|
"css-loader": "^6.7.3",
|
|
21
24
|
"css-minimizer-webpack-plugin": "^4.2.2",
|
|
22
25
|
"cssnano": "^5.1.15",
|
|
@@ -24,14 +27,14 @@
|
|
|
24
27
|
"escape-string-regexp": "^5.0.0",
|
|
25
28
|
"estree-walker": "^3.0.3",
|
|
26
29
|
"file-loader": "^6.2.0",
|
|
27
|
-
"fork-ts-checker-webpack-plugin": "^
|
|
30
|
+
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
|
28
31
|
"fs-extra": "^11.1.0",
|
|
29
32
|
"hash-sum": "^2.0.0",
|
|
30
33
|
"lodash-es": "^4.17.21",
|
|
31
|
-
"magic-string": "^0.
|
|
34
|
+
"magic-string": "^0.30.0",
|
|
32
35
|
"memfs": "^3.4.13",
|
|
33
|
-
"mini-css-extract-plugin": "^2.7.
|
|
34
|
-
"mlly": "^1.
|
|
36
|
+
"mini-css-extract-plugin": "^2.7.3",
|
|
37
|
+
"mlly": "^1.2.0",
|
|
35
38
|
"ohash": "^1.0.0",
|
|
36
39
|
"pathe": "^1.1.0",
|
|
37
40
|
"pify": "^6.1.0",
|
|
@@ -41,12 +44,12 @@
|
|
|
41
44
|
"postcss-url": "^10.1.3",
|
|
42
45
|
"style-resources-loader": "^1.5.0",
|
|
43
46
|
"time-fix-plugin": "^2.0.7",
|
|
44
|
-
"ufo": "^1.1.
|
|
45
|
-
"unplugin": "^1.
|
|
47
|
+
"ufo": "^1.1.1",
|
|
48
|
+
"unplugin": "^1.3.0",
|
|
46
49
|
"url-loader": "^4.1.1",
|
|
47
50
|
"vue-bundle-renderer": "^1.0.2",
|
|
48
51
|
"vue-loader": "^17.0.1",
|
|
49
|
-
"webpack": "^5.
|
|
52
|
+
"webpack": "^5.76.1",
|
|
50
53
|
"webpack-bundle-analyzer": "^4.8.0",
|
|
51
54
|
"webpack-dev-middleware": "^6.0.1",
|
|
52
55
|
"webpack-hot-middleware": "^2.25.3",
|
|
@@ -54,7 +57,7 @@
|
|
|
54
57
|
"webpackbar": "^5.0.2"
|
|
55
58
|
},
|
|
56
59
|
"devDependencies": {
|
|
57
|
-
"@nuxt/schema": "3.
|
|
60
|
+
"@nuxt/schema": "3.3.0",
|
|
58
61
|
"@types/lodash-es": "^4.17.6",
|
|
59
62
|
"@types/pify": "^5.0.1",
|
|
60
63
|
"@types/webpack-bundle-analyzer": "^4.6.0",
|