@nuxt/webpack-builder 3.11.1 → 3.12.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.
Files changed (3) hide show
  1. package/README.md +9 -1
  2. package/dist/index.mjs +77 -55
  3. package/package.json +23 -22
package/README.md CHANGED
@@ -33,6 +33,7 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
33
33
  - ❤️ [Contribute](#contribute)
34
34
  - 🏠 [Local Development](#local-development)
35
35
  - ⛰️ [Nuxt 2](#nuxt-2)
36
+ - 🛟 [Professional Support](#professional-support)
36
37
  - 🔗 [Follow us](#follow-us)
37
38
  - ⚖️ [License](#license)
38
39
 
@@ -93,7 +94,7 @@ We invite you to contribute and help improve Nuxt 💚
93
94
 
94
95
  Here are a few ways you can get involved:
95
96
  - **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/community/reporting-bugs) to learn how to submit a bug report.
96
- - **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/community/contribution#creating-an-issue) to share your suggestions.
97
+ - **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/community/contribution) to share your suggestions.
97
98
  - **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/community/getting-help) provides resources to help you out.
98
99
 
99
100
  ## <a name="local-development">🏠 Local Development</a>
@@ -104,6 +105,13 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
104
105
 
105
106
  You can find the code for Nuxt 2 on the [`2.x` branch](https://github.com/nuxt/nuxt/tree/2.x) and the documentation at [v2.nuxt.com](https://v2.nuxt.com).
106
107
 
108
+ If you expect to be using Nuxt 2 beyond the EOL (End of Life) date (June 30, 2024), and still need a maintained version that can satisfy security and browser compatibility requirements, make sure to check out [HeroDevs’ NES (Never-Ending Support) Nuxt 2](https://www.herodevs.com/support/nuxt-nes?utm_source=nuxt-github&utm_medium=nuxt-readme).
109
+
110
+ ## <a name="professional-support">🛟 Professional Support</a>
111
+
112
+ - Technical audit & consulting: [Nuxt Experts](https://nuxt.com/enterprise/support)
113
+ - Custom development & more: [Nuxt Agencies Partners](https://nuxt.com/enterprise/agencies)
114
+
107
115
  ## <a name="follow-us">🔗 Follow us</a>
108
116
 
109
117
  <p valign="center">
package/dist/index.mjs CHANGED
@@ -50,8 +50,8 @@ var __publicField$3 = (obj, key, value) => {
50
50
  return value;
51
51
  };
52
52
  const stringTypes = ["Literal", "TemplateLiteral"];
53
- const NUXT_LIB_RE = /node_modules\/(nuxt|nuxt3|nuxt-nightly)\//;
54
- const SUPPORTED_EXT_RE = /\.(m?[jt]sx?|vue)/;
53
+ const NUXT_LIB_RE = /node_modules\/(?:nuxt|nuxt3|nuxt-nightly)\//;
54
+ const SUPPORTED_EXT_RE = /\.(?:m?[jt]sx?|vue)/;
55
55
  const composableKeysPlugin = createUnplugin((options) => {
56
56
  const composableMeta = {};
57
57
  for (const { name, ...meta } of options.composables) {
@@ -71,7 +71,7 @@ const composableKeysPlugin = createUnplugin((options) => {
71
71
  if (!KEYED_FUNCTIONS_RE.test(code)) {
72
72
  return;
73
73
  }
74
- const { 0: script = code, index: codeIndex = 0 } = code.match(/(?<=<script[^>]*>)[\S\s.]*?(?=<\/script>)/) || { index: 0, 0: code };
74
+ const { 0: script = code, index: codeIndex = 0 } = code.match(/(?<=<script[^>]*>)[\s\S]*?(?=<\/script>)/) || { index: 0, 0: code };
75
75
  const s = new MagicString(code);
76
76
  let imports;
77
77
  let count = 0;
@@ -274,17 +274,18 @@ const defaults = {
274
274
  globalPublicPath: "__webpack_public_path__",
275
275
  sourcemap: true
276
276
  };
277
+ const ENTRY_RE = /import ["']#build\/css["'];/;
277
278
  const DynamicBasePlugin = createUnplugin((options = {}) => {
278
279
  options = { ...defaults, ...options };
279
280
  return {
280
281
  name: "nuxt:dynamic-base-path",
281
282
  enforce: "post",
282
283
  transform(code, id) {
283
- if (!id.includes("paths.mjs") || !code.includes("const appConfig = ")) {
284
+ if (!id.includes("entry") || !ENTRY_RE.test(code)) {
284
285
  return;
285
286
  }
286
287
  const s = new MagicString(code);
287
- s.append(`
288
+ s.prepend(`import { buildAssetsURL } from '#internal/nuxt/paths';
288
289
  ${options.globalPublicPath} = buildAssetsURL();
289
290
  `);
290
291
  return {
@@ -334,7 +335,7 @@ function registerVirtualModules() {
334
335
  const virtualModules = new VirtualModulesPlugin(nuxt.vfs);
335
336
  const writeFiles = () => {
336
337
  for (const filePath in nuxt.vfs) {
337
- virtualModules.writeModule(filePath, nuxt.vfs[filePath]);
338
+ virtualModules.writeModule(filePath, nuxt.vfs[filePath] || "");
338
339
  }
339
340
  };
340
341
  nuxt.hook("webpack:compile", ({ compiler }) => {
@@ -381,7 +382,7 @@ function fileName(ctx, key) {
381
382
  fileName2 = fileName2(ctx);
382
383
  }
383
384
  if (typeof fileName2 === "string" && ctx.options.dev) {
384
- const hash = /\[(chunkhash|contenthash|hash)(?::(\d+))?]/.exec(fileName2);
385
+ const hash = /\[(chunkhash|contenthash|hash)(?::\d+)?\]/.exec(fileName2);
385
386
  if (hash) {
386
387
  logger.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`);
387
388
  }
@@ -430,7 +431,7 @@ function assets(ctx) {
430
431
  var __defProp$2 = Object.defineProperty;
431
432
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
432
433
  var __publicField$2 = (obj, key, value) => {
433
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
434
+ __defNormalProp$2(obj, key + "" , value);
434
435
  return value;
435
436
  };
436
437
  class WarningIgnorePlugin {
@@ -535,6 +536,7 @@ function baseAlias(ctx) {
535
536
  "#app": ctx.options.appDir,
536
537
  "#build/plugins": resolve(ctx.options.buildDir, "plugins", ctx.isClient ? "client" : "server"),
537
538
  "#build": ctx.options.buildDir,
539
+ "#internal/nuxt/paths": resolve(ctx.nuxt.options.buildDir, "paths.mjs"),
538
540
  ...ctx.options.alias,
539
541
  ...ctx.alias
540
542
  };
@@ -603,8 +605,8 @@ function getWarningIgnoreFilter(ctx) {
603
605
  function getEnv(ctx) {
604
606
  const _env = {
605
607
  "process.env.NODE_ENV": JSON.stringify(ctx.config.mode),
606
- __NUXT_VERSION__: JSON.stringify(ctx.nuxt._version),
607
- __NUXT_ASYNC_CONTEXT__: ctx.options.experimental.asyncContext,
608
+ "__NUXT_VERSION__": JSON.stringify(ctx.nuxt._version),
609
+ "__NUXT_ASYNC_CONTEXT__": ctx.options.experimental.asyncContext,
608
610
  "process.env.VUE_ENV": JSON.stringify(ctx.name),
609
611
  "process.dev": ctx.options.dev,
610
612
  "process.test": isTest,
@@ -637,11 +639,11 @@ function esbuild(ctx) {
637
639
  test: /\.m?[jt]s$/i,
638
640
  loader: "esbuild-loader",
639
641
  exclude: (file) => {
640
- file = file.split("node_modules", 2)[1];
641
- if (!file) {
642
+ const lastSegment = file.split("node_modules", 2)[1];
643
+ if (!lastSegment) {
642
644
  return false;
643
645
  }
644
- return !ctx.transpile.some((module) => module.test(file));
646
+ return !ctx.transpile.some((module) => module.test(lastSegment));
645
647
  },
646
648
  resolve: {
647
649
  fullySpecified: false
@@ -689,21 +691,17 @@ function pug(ctx) {
689
691
  }
690
692
 
691
693
  const isPureObject = (obj) => obj !== null && !Array.isArray(obj) && typeof obj === "object";
694
+ const ensureItemIsLast = (item) => (arr) => {
695
+ const index = arr.indexOf(item);
696
+ if (index !== -1) {
697
+ arr.splice(index, 1);
698
+ arr.push(item);
699
+ }
700
+ return arr;
701
+ };
692
702
  const orderPresets = {
693
- cssnanoLast(names) {
694
- const nanoIndex = names.indexOf("cssnano");
695
- if (nanoIndex !== names.length - 1) {
696
- names.push(names.splice(nanoIndex, 1)[0]);
697
- }
698
- return names;
699
- },
700
- autoprefixerLast(names) {
701
- const nanoIndex = names.indexOf("autoprefixer");
702
- if (nanoIndex !== names.length - 1) {
703
- names.push(names.splice(nanoIndex, 1)[0]);
704
- }
705
- return names;
706
- },
703
+ cssnanoLast: ensureItemIsLast("cssnano"),
704
+ autoprefixerLast: ensureItemIsLast("autoprefixer"),
707
705
  autoprefixerAndCssnanoLast(names) {
708
706
  return orderPresets.cssnanoLast(orderPresets.autoprefixerLast(names));
709
707
  }
@@ -772,13 +770,16 @@ function minimizer(ctx) {
772
770
  }
773
771
  }
774
772
  function extractCSS(ctx) {
775
- if (ctx.userConfig.extractCSS) {
776
- ctx.config.plugins.push(new MiniCssExtractPlugin({
777
- filename: fileName(ctx, "css"),
778
- chunkFilename: fileName(ctx, "css"),
779
- ...ctx.userConfig.extractCSS === true ? {} : ctx.userConfig.extractCSS
780
- }));
773
+ const config = ctx.userConfig.extractCSS;
774
+ if (!config) {
775
+ return;
781
776
  }
777
+ const filename = fileName(ctx, "css");
778
+ ctx.config.plugins.push(new MiniCssExtractPlugin({
779
+ filename,
780
+ chunkFilename: filename,
781
+ ...config === true ? {} : config
782
+ }));
782
783
  }
783
784
  function loaders(ctx) {
784
785
  ctx.config.module.rules.push(createdStyleRule("css", /\.css$/i, null, ctx));
@@ -867,18 +868,15 @@ const validate = (compiler) => {
867
868
  const isJSRegExp = /\.[cm]?js(\?[^.]+)?$/;
868
869
  const isJS = (file) => isJSRegExp.test(file);
869
870
  const extractQueryPartJS = (file) => isJSRegExp.exec(file)?.[1];
870
- const isCSS = (file) => /\.css(\?[^.]+)?$/.test(file);
871
+ const isCSS = (file) => /\.css(?:\?[^.]+)?$/.test(file);
871
872
  const isHotUpdate = (file) => file.includes("hot-update");
872
873
 
873
874
  var __defProp$1 = Object.defineProperty;
874
875
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
875
876
  var __publicField$1 = (obj, key, value) => {
876
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
877
+ __defNormalProp$1(obj, key + "" , value);
877
878
  return value;
878
879
  };
879
- function uniq(items) {
880
- return [...new Set(items)];
881
- }
882
880
  class VueSSRClientPlugin {
883
881
  constructor(options) {
884
882
  __publicField$1(this, "options");
@@ -889,22 +887,43 @@ class VueSSRClientPlugin {
889
887
  apply(compiler) {
890
888
  compiler.hooks.afterEmit.tap("VueSSRClientPlugin", async (compilation) => {
891
889
  const stats = compilation.getStats().toJson();
892
- const allFiles = uniq(stats.assets.map((a) => a.name)).filter((file) => !isHotUpdate(file));
893
- const initialFiles = uniq(Object.keys(stats.entrypoints).map((name) => stats.entrypoints[name].assets).reduce((files, entryAssets) => files.concat(entryAssets.map((entryAsset) => entryAsset.name)), []).filter((file) => isJS(file) || isCSS(file))).filter((file) => !isHotUpdate(file));
894
- const asyncFiles = allFiles.filter((file) => isJS(file) || isCSS(file)).filter((file) => !initialFiles.includes(file)).filter((file) => !isHotUpdate(file));
890
+ const initialFiles = /* @__PURE__ */ new Set();
891
+ for (const name in stats.entrypoints) {
892
+ const entryAssets = stats.entrypoints[name].assets;
893
+ for (const asset of entryAssets) {
894
+ const file = asset.name;
895
+ if ((isJS(file) || isCSS(file)) && !isHotUpdate(file)) {
896
+ initialFiles.add(file);
897
+ }
898
+ }
899
+ }
900
+ const allFiles = /* @__PURE__ */ new Set();
901
+ const asyncFiles = /* @__PURE__ */ new Set();
902
+ for (const asset of stats.assets) {
903
+ const file = asset.name;
904
+ if (!isHotUpdate(file)) {
905
+ allFiles.add(file);
906
+ if (initialFiles.has(file)) {
907
+ continue;
908
+ }
909
+ if (isJS(file) || isCSS(file)) {
910
+ asyncFiles.add(file);
911
+ }
912
+ }
913
+ }
895
914
  const assetsMapping = {};
896
- stats.assets.filter(({ name }) => isJS(name)).filter(({ name }) => !isHotUpdate(name)).forEach(({ name, chunkNames = [] }) => {
897
- const componentHash = hash$1(chunkNames.join("|"));
898
- if (!assetsMapping[componentHash]) {
899
- assetsMapping[componentHash] = [];
915
+ for (const { name, chunkNames = [] } of stats.assets) {
916
+ if (isJS(name) && !isHotUpdate(name)) {
917
+ const componentHash = hash$1(chunkNames.join("|"));
918
+ const map = assetsMapping[componentHash] || (assetsMapping[componentHash] = []);
919
+ map.push(name);
900
920
  }
901
- assetsMapping[componentHash].push(name);
902
- });
921
+ }
903
922
  const webpackManifest = {
904
923
  publicPath: stats.publicPath,
905
- all: allFiles,
906
- initial: initialFiles,
907
- async: asyncFiles,
924
+ all: [...allFiles],
925
+ initial: [...initialFiles],
926
+ async: [...asyncFiles],
908
927
  modules: {
909
928
  /* [identifier: string]: Array<index: number> */
910
929
  },
@@ -917,7 +936,7 @@ class VueSSRClientPlugin {
917
936
  if (m.chunks.length === 1) {
918
937
  const [cid] = m.chunks;
919
938
  const chunk = stats.chunks.find((c) => c.id === cid);
920
- if (!chunk || !chunk.files) {
939
+ if (!chunk || !chunk.files || !cid) {
921
940
  return;
922
941
  }
923
942
  const id = m.identifier.replace(/\s\w+$/, "");
@@ -963,7 +982,7 @@ class VueSSRClientPlugin {
963
982
  var __defProp = Object.defineProperty;
964
983
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
965
984
  var __publicField = (obj, key, value) => {
966
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
985
+ __defNormalProp(obj, key + "" , value);
967
986
  return value;
968
987
  };
969
988
  const JS_MAP_RE = /\.js\.map$/;
@@ -1188,12 +1207,12 @@ function node(ctx) {
1188
1207
  ctx.config.performance = {
1189
1208
  ...ctx.config.performance,
1190
1209
  hints: false,
1191
- maxEntrypointSize: Infinity,
1192
- maxAssetSize: Infinity
1210
+ maxEntrypointSize: Number.POSITIVE_INFINITY,
1211
+ maxAssetSize: Number.POSITIVE_INFINITY
1193
1212
  };
1194
1213
  }
1195
1214
 
1196
- const assetPattern = /\.(css|s[ca]ss|png|jpe?g|gif|svg|woff2?|eot|ttf|otf|webp|webm|mp4|ogv)(\?.*)?$/i;
1215
+ const assetPattern = /\.(?:css|s[ca]ss|png|jpe?g|gif|svg|woff2?|eot|ttf|otf|webp|webm|mp4|ogv)(?:\?.*)?$/i;
1197
1216
  function server(ctx) {
1198
1217
  ctx.name = "server";
1199
1218
  ctx.isServer = true;
@@ -1233,6 +1252,9 @@ function serverStandalone(ctx) {
1233
1252
  ...ctx.options.build.transpile
1234
1253
  ];
1235
1254
  const external = ["#internal/nitro"];
1255
+ if (!ctx.nuxt.options.dev) {
1256
+ external.push("#internal/nuxt/paths");
1257
+ }
1236
1258
  if (!Array.isArray(ctx.config.externals)) {
1237
1259
  return;
1238
1260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder",
3
- "version": "3.11.1",
3
+ "version": "3.12.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -23,10 +23,10 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@nuxt/friendly-errors-webpack-plugin": "^2.6.0",
26
- "autoprefixer": "^10.4.18",
27
- "css-loader": "^6.10.0",
28
- "css-minimizer-webpack-plugin": "^6.0.0",
29
- "cssnano": "^6.1.0",
26
+ "autoprefixer": "^10.4.19",
27
+ "css-loader": "^7.1.2",
28
+ "css-minimizer-webpack-plugin": "^7.0.0",
29
+ "cssnano": "^7.0.2",
30
30
  "defu": "^6.1.4",
31
31
  "esbuild-loader": "^4.1.0",
32
32
  "escape-string-regexp": "^5.0.0",
@@ -37,45 +37,46 @@
37
37
  "h3": "^1.11.1",
38
38
  "hash-sum": "^2.0.0",
39
39
  "lodash-es": "4.17.21",
40
- "magic-string": "^0.30.8",
41
- "memfs": "^4.7.7",
42
- "mini-css-extract-plugin": "^2.8.1",
43
- "mlly": "^1.6.1",
40
+ "magic-string": "^0.30.10",
41
+ "memfs": "^4.9.2",
42
+ "mini-css-extract-plugin": "^2.9.0",
43
+ "mlly": "^1.7.1",
44
44
  "ohash": "^1.1.3",
45
45
  "pathe": "^1.1.2",
46
46
  "pify": "^6.1.0",
47
- "postcss": "^8.4.36",
48
- "postcss-import": "^16.0.1",
47
+ "postcss": "^8.4.38",
48
+ "postcss-import": "^16.1.0",
49
49
  "postcss-import-resolver": "^2.0.0",
50
50
  "postcss-loader": "^8.1.1",
51
51
  "postcss-url": "^10.1.3",
52
52
  "pug-plain-loader": "^1.1.0",
53
53
  "std-env": "^3.7.0",
54
54
  "time-fix-plugin": "^2.0.7",
55
- "ufo": "^1.5.2",
55
+ "ufo": "^1.5.3",
56
56
  "unenv": "^1.9.0",
57
- "unplugin": "^1.10.0",
57
+ "unplugin": "^1.10.1",
58
58
  "url-loader": "^4.1.1",
59
- "vue-bundle-renderer": "^2.0.0",
59
+ "vue-bundle-renderer": "^2.1.0",
60
60
  "vue-loader": "^17.4.2",
61
- "webpack": "^5.90.3",
62
- "webpack-bundle-analyzer": "^4.10.1",
63
- "webpack-dev-middleware": "^7.0.0",
61
+ "webpack": "^5.91.0",
62
+ "webpack-bundle-analyzer": "^4.10.2",
63
+ "webpack-dev-middleware": "^7.2.1",
64
64
  "webpack-hot-middleware": "^2.26.1",
65
- "webpack-virtual-modules": "^0.6.1",
65
+ "webpack-virtual-modules": "^0.6.2",
66
66
  "webpackbar": "^6.0.1",
67
- "@nuxt/kit": "3.11.1"
67
+ "@nuxt/kit": "3.12.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/fs-extra": "11.0.4",
71
71
  "@types/hash-sum": "1.0.2",
72
+ "@types/lodash-es": "4.17.12",
72
73
  "@types/pify": "5.0.4",
73
74
  "@types/webpack-bundle-analyzer": "4.7.0",
74
75
  "@types/webpack-hot-middleware": "2.25.9",
75
- "@types/webpack-virtual-modules": "0.1.3",
76
+ "@types/webpack-virtual-modules": "0.4.2",
76
77
  "unbuild": "latest",
77
- "vue": "3.4.21",
78
- "@nuxt/schema": "3.11.1"
78
+ "vue": "3.4.27",
79
+ "@nuxt/schema": "3.12.0"
79
80
  },
80
81
  "peerDependencies": {
81
82
  "vue": "^3.3.4"