@nuxt/webpack-builder 3.2.3 → 3.3.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.
Files changed (2) hide show
  1. package/dist/index.mjs +25 -28
  2. package/package.json +13 -10
package/dist/index.mjs CHANGED
@@ -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.includes(name) || node.arguments.length >= 4) {
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 (node.arguments.length >= 2 || stringTypes.includes(node.arguments[0]?.type)) {
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 (node.arguments.length >= 3 || stringTypes.includes(node.arguments[1]?.type)) {
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 (node.arguments.length >= 3 || stringTypes.includes(node.arguments[0]?.type) || stringTypes.includes(node.arguments[node.arguments.length - 1]?.type)) {
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;
@@ -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: "none",
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(escapeRegExp(normalize(pattern))));
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,12 +1,15 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder",
3
- "version": "3.2.3",
3
+ "version": "3.3.1",
4
4
  "repository": "nuxt/nuxt",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
9
- ".": "./dist/index.mjs",
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs"
12
+ },
10
13
  "./dist/*": "./dist/*"
11
14
  },
12
15
  "files": [
@@ -15,8 +18,8 @@
15
18
  "dependencies": {
16
19
  "@babel/core": "^7.21.0",
17
20
  "@nuxt/friendly-errors-webpack-plugin": "^2.5.2",
18
- "@nuxt/kit": "3.2.3",
19
- "autoprefixer": "^10.4.13",
21
+ "@nuxt/kit": "3.3.1",
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": "^7.3.0",
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
34
  "magic-string": "^0.30.0",
32
35
  "memfs": "^3.4.13",
33
- "mini-css-extract-plugin": "^2.7.2",
34
- "mlly": "^1.1.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",
@@ -42,11 +45,11 @@
42
45
  "style-resources-loader": "^1.5.0",
43
46
  "time-fix-plugin": "^2.0.7",
44
47
  "ufo": "^1.1.1",
45
- "unplugin": "^1.1.0",
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.75.0",
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.2.3",
60
+ "@nuxt/schema": "3.3.1",
58
61
  "@types/lodash-es": "^4.17.6",
59
62
  "@types/pify": "^5.0.1",
60
63
  "@types/webpack-bundle-analyzer": "^4.6.0",