@nuxt/webpack-builder 3.0.0-rc.9 → 3.1.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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -3
  3. package/dist/index.mjs +89 -70
  4. package/package.json +39 -41
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present - Nuxt Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,128 @@
1
- # Nuxt Webpack Builder
2
1
 
3
- > The [Webpack](https://webpack.js.org) bundler for Nuxt 3
2
+ [![Nuxt banner](./.github/assets/banner.png)](https://nuxt.com)
3
+
4
+ # 👋 Welcome to Nuxt
5
+
6
+
7
+ Nuxt's goal is to make web development intuitive and performant, with a great developer experience.<br>Learn more in the ['What is Nuxt?'](https://nuxt.com/docs/getting-started/introduction) section of our documentation.
8
+
9
+
10
+ <p>
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
+ <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
+ <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://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
+ </p>
16
+
17
+ <table>
18
+ <thead>
19
+ <tr>
20
+ <th width="2000" colspan="2">
21
+ </th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <tr>
26
+ <td width="80" align="center" valign="top">
27
+ <br>
28
+ <a href="https://nuxt.com/docs"><img src="./.github/assets/documentation.png"></a>
29
+ </td>
30
+ <td valign="top">
31
+ <h3>Documentation</h3>
32
+ <p>
33
+ We highly recommend you take a look at <a href="https://nuxt.com">the Nuxt documentation</a> to level up.
34
+ </p>
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td width="80" align="center" valign="top">
39
+ <br>
40
+ <a href="https://nuxt.com/modules"><img src="./.github/assets/modules.png"></a>
41
+ </td>
42
+ <td valign="top">
43
+ <h3>Modules</h3>
44
+ <p>
45
+ Discover our <a href="https://nuxt.com/modules">list of modules</a> to supercharge your Nuxt project. Created by the Nuxt team and community.
46
+ </p>
47
+ </td>
48
+ </tr>
49
+ <tr>
50
+ <td width="80" align="center" valign="top">
51
+ <br>
52
+ <a href="https://nuxt.com/docs/examples/hello-world"><img src="./.github/assets/examples.png"></a>
53
+ </td>
54
+ <td>
55
+ <h3>Examples</h3>
56
+ <p>
57
+ Explore different ways of using Nuxt features and get inspired with <a href="https://nuxt.com/docs/examples/essentials/hello-world">our list of examples</a>.
58
+ </p>
59
+ </td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+
64
+ <table>
65
+ <thead>
66
+ <tr>
67
+ <th width="2000" colspan="2">
68
+ </th>
69
+ </tr>
70
+ </thead>
71
+ <tbody>
72
+ <tr>
73
+ <td width="80" align="center" valign="top">
74
+ <br>
75
+ <a href="https://nuxt.com/docs/community/reporting-bugs"><img src="./.github/assets/reporting-bugs.png"></a>
76
+ </td>
77
+ <td valign="top">
78
+ <h3>Reporting bugs</h3>
79
+ <p>
80
+ Check out the <a href="https://nuxt.com/docs/community/reporting-bugs">Reporting Bugs</a> page.</p>
81
+ </p>
82
+ </td>
83
+ </tr>
84
+ <tr>
85
+ <td width="80" align="center" valign="top">
86
+ <br>
87
+ <a href="https://nuxt.com/docs/community/contribution"><img src="./.github/assets/suggestions.png"></a>
88
+ </td>
89
+ <td valign="top">
90
+ <h3>Suggestions</h3>
91
+ <p>
92
+ Check out the <a href="https://nuxt.com/docs/community/contribution">Contribution</a> page.
93
+ </p>
94
+ </td>
95
+ </tr>
96
+ <tr>
97
+ <td width="80" align="center" valign="top">
98
+ <br>
99
+ <a href="https://nuxt.com/docs/community/getting-help"><img src="./.github/assets/questions.png"></a>
100
+ </td>
101
+ <td valign="top">
102
+ <h3>Questions</h3>
103
+ <p>
104
+ Check out the <a href="https://nuxt.com/docs/community/getting-help">Getting Help</a> page.
105
+ </p>
106
+ </td>
107
+ </tr>
108
+ </tbody>
109
+ </table>
110
+
111
+ ## Local Development
112
+
113
+ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#set-up-your-local-development-environment) to contribute to the framework and documentation.
114
+
115
+ ## Nuxt 2
116
+
117
+ You can find the code for Nuxt 2 on the [`2.x-dev` branch](https://github.com/nuxt/nuxt/tree/2.x-dev) and the documentation at [nuxtjs.org](https://nuxtjs.org).
118
+
119
+ ## Follow us
120
+
121
+ <p valign="center">
122
+ <a href="https://chat.nuxt.dev"><img width="20px" src="./.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://twitter.nuxt.dev"><img width="20px" src="./.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://github.nuxt.dev"><img width="20px" src="./.github/assets/github.svg" alt="GitHub"></a>
123
+ </p>
124
+
125
+ ## License
126
+
127
+ [MIT](./LICENSE)
4
128
 
5
- Learn more about this package: <https://v3.nuxtjs.org>
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import pify from 'pify';
2
2
  import webpack from 'webpack';
3
+ import { fromNodeMiddleware, defineEventHandler } from 'h3';
3
4
  import webpackDevMiddleware from 'webpack-dev-middleware';
4
5
  import webpackHotMiddleware from 'webpack-hot-middleware';
5
- import { parseURL, joinURL } from 'ufo';
6
+ import { parseURL, parseQuery, joinURL } from 'ufo';
6
7
  import { useNuxt, logger, requireModule } from '@nuxt/kit';
7
8
  import { pathToFileURL } from 'node:url';
8
9
  import { createUnplugin } from 'unplugin';
@@ -37,19 +38,20 @@ const keyedFunctions = [
37
38
  "useLazyFetch"
38
39
  ];
39
40
  const KEYED_FUNCTIONS_RE = new RegExp(`(${keyedFunctions.join("|")})`);
41
+ const stringTypes = ["Literal", "TemplateLiteral"];
40
42
  const composableKeysPlugin = createUnplugin((options) => {
41
43
  return {
42
44
  name: "nuxt:composable-keys",
43
45
  enforce: "post",
46
+ transformInclude(id) {
47
+ const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
48
+ return !pathname.match(/node_modules\/nuxt3?\//) && pathname.match(/\.(m?[jt]sx?|vue)/) && parseQuery(search).type !== "style" && !parseQuery(search).macro;
49
+ },
44
50
  transform(code, id) {
45
- const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href));
46
- if (!pathname.match(/\.(m?[jt]sx?|vue)/)) {
47
- return;
48
- }
49
51
  if (!KEYED_FUNCTIONS_RE.test(code)) {
50
52
  return;
51
53
  }
52
- const { 0: script = code, index: codeIndex = 0 } = code.match(/(?<=<script[^>]*>)[\S\s.]*?(?=<\/script>)/) || [];
54
+ const { 0: script = code, index: codeIndex = 0 } = code.match(/(?<=<script[^>]*>)[\S\s.]*?(?=<\/script>)/) || { index: 0, 0: code };
53
55
  const s = new MagicString(code);
54
56
  let count = 0;
55
57
  const relativeID = isAbsolute(id) ? relative(options.rootDir, id) : id;
@@ -62,13 +64,34 @@ const composableKeysPlugin = createUnplugin((options) => {
62
64
  return;
63
65
  }
64
66
  const node = _node;
65
- if (keyedFunctions.includes(node.callee.name) && node.arguments.length < 4) {
66
- const end = node.end;
67
- s.appendLeft(
68
- codeIndex + end - 1,
69
- (node.arguments.length ? ", " : "") + "'$" + hash(`${relativeID}-${++count}`) + "'"
70
- );
67
+ const name = "name" in node.callee && node.callee.name;
68
+ if (!name || !keyedFunctions.includes(name) || node.arguments.length >= 4) {
69
+ return;
70
+ }
71
+ switch (name) {
72
+ case "useState":
73
+ if (node.arguments.length >= 2 || stringTypes.includes(node.arguments[0]?.type)) {
74
+ return;
75
+ }
76
+ break;
77
+ case "useFetch":
78
+ case "useLazyFetch":
79
+ if (node.arguments.length >= 3 || stringTypes.includes(node.arguments[1]?.type)) {
80
+ return;
81
+ }
82
+ break;
83
+ case "useAsyncData":
84
+ case "useLazyAsyncData":
85
+ if (node.arguments.length >= 3 || stringTypes.includes(node.arguments[0]?.type) || stringTypes.includes(node.arguments[node.arguments.length - 1]?.type)) {
86
+ return;
87
+ }
88
+ break;
71
89
  }
90
+ const endsWithComma = code.slice(codeIndex + node.start, codeIndex + node.end - 1).trim().endsWith(",");
91
+ s.appendLeft(
92
+ codeIndex + node.end - 1,
93
+ (node.arguments.length && !endsWithComma ? ", " : "") + "'$" + hash(`${relativeID}-${++count}`) + "'"
94
+ );
72
95
  }
73
96
  });
74
97
  if (s.hasChanged()) {
@@ -95,7 +118,8 @@ const DynamicBasePlugin = createUnplugin((options = {}) => {
95
118
  return;
96
119
  }
97
120
  const s = new MagicString(code);
98
- s.append(`${options.globalPublicPath} = buildAssetsURL();
121
+ s.append(`
122
+ ${options.globalPublicPath} = buildAssetsURL();
99
123
  `);
100
124
  return {
101
125
  code: s.toString(),
@@ -122,7 +146,7 @@ function registerVirtualModules() {
122
146
  virtualModules.writeModule(filePath, nuxt.vfs[filePath]);
123
147
  }
124
148
  };
125
- nuxt.hook("build:compile", ({ compiler }) => {
149
+ nuxt.hook("webpack:compile", ({ compiler }) => {
126
150
  if (compiler.name === "server") {
127
151
  writeFiles();
128
152
  }
@@ -278,12 +302,13 @@ function basePlugins(ctx) {
278
302
  config.plugins.push(...options.webpack.plugins || []);
279
303
  config.plugins.push(new WarningIgnorePlugin(getWarningIgnoreFilter(ctx)));
280
304
  config.plugins.push(new webpack.DefinePlugin(getEnv(ctx)));
281
- if (ctx.isServer || ctx.isDev && !options.build.quiet && options.webpack.friendlyErrors) {
305
+ if (ctx.isServer || ctx.isDev && options.webpack.friendlyErrors) {
282
306
  config.plugins.push(
283
307
  new FriendlyErrorsWebpackPlugin({
284
308
  clearConsole: false,
285
309
  reporter: "consola",
286
310
  logLevel: "ERROR"
311
+ // TODO
287
312
  })
288
313
  );
289
314
  }
@@ -299,23 +324,26 @@ function basePlugins(ctx) {
299
324
  reporters: ["stats"],
300
325
  stats: !ctx.isDev,
301
326
  reporter: {
327
+ // @ts-ignore
302
328
  change: (_, { shortPath }) => {
303
329
  if (!ctx.isServer) {
304
- nuxt.callHook("bundler:change", shortPath);
330
+ nuxt.callHook("webpack:change", shortPath);
305
331
  }
306
332
  },
333
+ // @ts-ignore
307
334
  done: ({ state }) => {
308
335
  if (state.hasErrors) {
309
- nuxt.callHook("bundler:error");
336
+ nuxt.callHook("webpack:error");
310
337
  } else {
311
338
  logger.success(`${state.name} ${state.message}`);
312
339
  }
313
340
  },
314
341
  allDone: () => {
315
- nuxt.callHook("bundler:done");
342
+ nuxt.callHook("webpack:done");
316
343
  },
344
+ // @ts-ignore
317
345
  progress({ statesArray }) {
318
- nuxt.callHook("bundler:progress", statesArray);
346
+ nuxt.callHook("webpack:progress", statesArray);
319
347
  }
320
348
  }
321
349
  }));
@@ -353,12 +381,16 @@ function baseTranspile(ctx) {
353
381
  const { options } = ctx;
354
382
  const transpile = [
355
383
  /\.vue\.js/i,
384
+ // include SFCs in node_modules
356
385
  /consola\/src/,
357
386
  /vue-demi/
358
387
  ];
359
388
  for (let pattern of options.build.transpile) {
360
389
  if (typeof pattern === "function") {
361
- pattern = pattern(ctx);
390
+ const result = pattern(ctx);
391
+ if (result) {
392
+ pattern = result;
393
+ }
362
394
  }
363
395
  if (typeof pattern === "string") {
364
396
  transpile.push(new RegExp(escapeRegExp(normalize(pattern))));
@@ -386,6 +418,7 @@ function getOutput(ctx) {
386
418
  function getWarningIgnoreFilter(ctx) {
387
419
  const { options } = ctx;
388
420
  const filters = [
421
+ // Hide warnings about plugins without a default export (#1179)
389
422
  (warn) => warn.name === "ModuleDependencyWarning" && warn.message.includes("export 'default'") && warn.message.includes("nuxt_plugin_"),
390
423
  ...options.webpack.warningIgnoreFilters || []
391
424
  ];
@@ -397,8 +430,6 @@ function getEnv(ctx) {
397
430
  "process.env.NODE_ENV": JSON.stringify(ctx.config.mode),
398
431
  "process.mode": JSON.stringify(ctx.config.mode),
399
432
  "process.dev": options.dev,
400
- "process.static": options.target === "static",
401
- "process.target": JSON.stringify(options.target),
402
433
  "process.env.VUE_ENV": JSON.stringify(ctx.name),
403
434
  "process.browser": ctx.isClient,
404
435
  "process.client": ctx.isClient,
@@ -408,10 +439,6 @@ function getEnv(ctx) {
408
439
  _env["typeof process"] = JSON.stringify(ctx.isServer ? "object" : "undefined");
409
440
  _env["typeof window"] = _env["typeof document"] = JSON.stringify(!ctx.isServer ? "object" : "undefined");
410
441
  }
411
- Object.entries(options.env).forEach(([key, value]) => {
412
- const isNative = ["boolean", "number"].includes(typeof value);
413
- _env["process.env." + key] = isNative ? value : JSON.stringify(value);
414
- });
415
442
  return _env;
416
443
  }
417
444
 
@@ -498,6 +525,7 @@ const getPostcssConfig = (nuxt) => {
498
525
  return {
499
526
  sourceMap: nuxt.options.webpack.cssSourceMap,
500
527
  plugins: nuxt.options.postcss.plugins,
528
+ // Array, String or Function
501
529
  order: "autoprefixerAndCssnanoLast"
502
530
  };
503
531
  }
@@ -525,15 +553,6 @@ const getPostcssConfig = (nuxt) => {
525
553
  if (!nuxt.options.webpack.postcss || !nuxt.options.postcss) {
526
554
  return false;
527
555
  }
528
- const configFile = nuxt.options.postcss.config;
529
- if (configFile) {
530
- return {
531
- postcssOptions: {
532
- config: configFile
533
- },
534
- sourceMap: nuxt.options.webpack.cssSourceMap
535
- };
536
- }
537
556
  let postcssOptions = cloneDeep(nuxt.options.postcss);
538
557
  if (isPureObject(postcssOptions)) {
539
558
  if (Array.isArray(postcssOptions.plugins)) {
@@ -544,6 +563,7 @@ const getPostcssConfig = (nuxt) => {
544
563
  }
545
564
  delete nuxt.options.webpack.postcss.order;
546
565
  return {
566
+ // @ts-expect-error
547
567
  sourceMap: nuxt.options.webpack.cssSourceMap,
548
568
  ...nuxt.options.webpack.postcss,
549
569
  postcssOptions
@@ -601,10 +621,12 @@ function createdStyleRule(lang, test, processorLoader, ctx) {
601
621
  return {
602
622
  test,
603
623
  oneOf: [
624
+ // This matches <style module>
604
625
  {
605
626
  resourceQuery: /module/,
606
627
  use: cssModuleLoaders.concat(styleLoaders)
607
628
  },
629
+ // This matches plain <style> or <style scoped>
608
630
  {
609
631
  use: cssLoaders.concat(styleLoaders)
610
632
  }
@@ -629,6 +651,11 @@ function createCssLoadersRule(ctx, cssLoaderOptions) {
629
651
  ];
630
652
  }
631
653
  return [
654
+ // https://github.com/vuejs/vue-style-loader/issues/56
655
+ // {
656
+ // loader: 'vue-style-loader',
657
+ // options: options.webpack.loaders.vueStyle
658
+ // },
632
659
  cssLoader
633
660
  ];
634
661
  }
@@ -688,7 +715,9 @@ class VueSSRClientPlugin {
688
715
  all: allFiles,
689
716
  initial: initialFiles,
690
717
  async: asyncFiles,
691
- modules: {},
718
+ modules: {
719
+ /* [identifier: string]: Array<index: number> */
720
+ },
692
721
  assetsMapping
693
722
  };
694
723
  const { entrypoints = {}, namedChunkGroups = {} } = stats;
@@ -725,7 +754,7 @@ class VueSSRClientPlugin {
725
754
  }
726
755
  assetModules.forEach((m2) => {
727
756
  if (m2.chunks.includes(cid)) {
728
- files.push.apply(files, m2.assets.map(fileToIndex));
757
+ files.push(...m2.assets.map(fileToIndex));
729
758
  }
730
759
  });
731
760
  }
@@ -859,13 +888,15 @@ function client(ctx) {
859
888
  ]);
860
889
  }
861
890
  function clientDevtool(ctx) {
862
- if (!ctx.isDev) {
891
+ if (!ctx.nuxt.options.sourcemap.client) {
863
892
  ctx.config.devtool = false;
864
893
  return;
865
894
  }
866
- const scriptPolicy = getCspScriptPolicy(ctx);
867
- const noUnsafeEval = scriptPolicy && !scriptPolicy.includes("'unsafe-eval'");
868
- ctx.config.devtool = noUnsafeEval ? "cheap-module-source-map" : "eval-cheap-module-source-map";
895
+ if (!ctx.isDev) {
896
+ ctx.config.devtool = "source-map";
897
+ return;
898
+ }
899
+ ctx.config.devtool = "eval-cheap-module-source-map";
869
900
  }
870
901
  function clientPerformance(ctx) {
871
902
  ctx.config.performance = {
@@ -892,6 +923,7 @@ function clientHMR(ctx) {
892
923
  const hotMiddlewareClientOptionsStr = querystring.stringify(hotMiddlewareClientOptions);
893
924
  const app = config.entry.app;
894
925
  app.unshift(
926
+ // https://github.com/glenjamin/webpack-hot-middleware#config
895
927
  `webpack-hot-middleware/client?${hotMiddlewareClientOptionsStr}`
896
928
  );
897
929
  config.plugins = config.plugins || [];
@@ -907,20 +939,13 @@ function clientPlugins(ctx) {
907
939
  analyzerMode: "static",
908
940
  defaultSizes: "gzip",
909
941
  generateStatsFile: true,
910
- openAnalyzer: !options.build.quiet,
942
+ openAnalyzer: true,
911
943
  reportFilename: resolve(statsDir, `${ctx.name}.html`),
912
944
  statsFilename: resolve(statsDir, `${ctx.name}.json`),
913
945
  ...options.webpack.analyze === true ? {} : options.webpack.analyze
914
946
  }));
915
947
  }
916
948
  }
917
- function getCspScriptPolicy(ctx) {
918
- const { csp } = ctx.options.render;
919
- if (typeof csp === "object") {
920
- const { policies = {} } = csp;
921
- return policies["script-src"] || policies["default-src"] || [];
922
- }
923
- }
924
949
 
925
950
  function node(ctx) {
926
951
  const { config } = ctx;
@@ -970,7 +995,7 @@ function server(ctx) {
970
995
  function serverPreset(ctx) {
971
996
  const { config } = ctx;
972
997
  config.output.filename = "server.mjs";
973
- config.devtool = "cheap-module-source-map";
998
+ config.devtool = ctx.nuxt.options.sourcemap.server ? ctx.isDev ? "cheap-module-source-map" : "source-map" : false;
974
999
  config.optimization = {
975
1000
  splitChunks: false,
976
1001
  minimize: false
@@ -1031,10 +1056,10 @@ async function bundle(nuxt) {
1031
1056
  const mfs = nuxt.options.dev ? createMFS() : null;
1032
1057
  const compilers = webpackConfigs.map((config) => {
1033
1058
  config.plugins.push(DynamicBasePlugin.webpack({
1034
- sourcemap: nuxt.options.sourcemap
1059
+ sourcemap: nuxt.options.sourcemap[config.name]
1035
1060
  }));
1036
1061
  config.plugins.push(composableKeysPlugin.webpack({
1037
- sourcemap: nuxt.options.sourcemap,
1062
+ sourcemap: nuxt.options.sourcemap[config.name],
1038
1063
  rootDir: nuxt.options.rootDir
1039
1064
  }));
1040
1065
  const compiler = webpack(config);
@@ -1058,37 +1083,34 @@ async function bundle(nuxt) {
1058
1083
  async function createDevMiddleware(compiler) {
1059
1084
  const nuxt = useNuxt();
1060
1085
  logger.debug("Creating webpack middleware...");
1061
- const devMiddleware = pify(webpackDevMiddleware(compiler, {
1086
+ const devMiddleware = webpackDevMiddleware(compiler, {
1062
1087
  publicPath: joinURL(nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir),
1063
1088
  outputFileSystem: compiler.outputFileSystem,
1064
1089
  stats: "none",
1065
1090
  ...nuxt.options.webpack.devMiddleware
1066
- }));
1091
+ });
1067
1092
  nuxt.hook("close", () => pify(devMiddleware.close.bind(devMiddleware))());
1068
1093
  const { client: _client, ...hotMiddlewareOptions } = nuxt.options.webpack.hotMiddleware || {};
1069
- const hotMiddleware = pify(webpackHotMiddleware(compiler, {
1094
+ const hotMiddleware = webpackHotMiddleware(compiler, {
1070
1095
  log: false,
1071
1096
  heartbeat: 1e4,
1072
1097
  path: joinURL(nuxt.options.app.baseURL, "__webpack_hmr", compiler.options.name),
1073
1098
  ...hotMiddlewareOptions
1074
- }));
1075
- await nuxt.callHook("webpack:devMiddleware", devMiddleware);
1076
- await nuxt.callHook("webpack:hotMiddleware", hotMiddleware);
1077
- await nuxt.callHook("server:devMiddleware", async (req, res, next) => {
1078
- for (const mw of [devMiddleware, hotMiddleware]) {
1079
- await mw?.(req, res, next);
1080
- }
1081
- next();
1082
1099
  });
1100
+ const devHandler = fromNodeMiddleware(devMiddleware);
1101
+ const hotHandler = fromNodeMiddleware(hotMiddleware);
1102
+ await nuxt.callHook("server:devHandler", defineEventHandler(async (event) => {
1103
+ await devHandler(event);
1104
+ await hotHandler(event);
1105
+ }));
1083
1106
  return devMiddleware;
1084
1107
  }
1085
1108
  async function compile(compiler) {
1086
1109
  const nuxt = useNuxt();
1087
1110
  const { name } = compiler.options;
1088
- await nuxt.callHook("build:compile", { name, compiler });
1111
+ await nuxt.callHook("webpack:compile", { name, compiler });
1089
1112
  compiler.hooks.done.tap("load-resources", async (stats2) => {
1090
- await nuxt.callHook("build:compiled", { name, compiler, stats: stats2 });
1091
- await nuxt.callHook("build:resources", compiler.outputFileSystem);
1113
+ await nuxt.callHook("webpack:compiled", { name, compiler, stats: stats2 });
1092
1114
  });
1093
1115
  if (nuxt.options.dev) {
1094
1116
  const compilersWatching = [];
@@ -1121,12 +1143,9 @@ async function compile(compiler) {
1121
1143
  const stats = await new Promise((resolve, reject) => compiler.run((err, stats2) => err ? reject(err) : resolve(stats2)));
1122
1144
  if (stats.hasErrors()) {
1123
1145
  const error = new Error("Nuxt build error");
1124
- if (nuxt.options.build.quiet === true) {
1125
- error.stack = stats.toString("errors-only");
1126
- }
1146
+ error.stack = stats.toString("errors-only");
1127
1147
  throw error;
1128
1148
  }
1129
- await nuxt.callHook("build:resources");
1130
1149
  }
1131
1150
 
1132
1151
  export { bundle };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder",
3
- "version": "3.0.0-rc.9",
4
- "repository": "nuxt/framework",
3
+ "version": "3.1.0",
4
+ "repository": "nuxt/nuxt",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "types": "./dist/index.d.ts",
@@ -12,65 +12,63 @@
12
12
  "files": [
13
13
  "dist"
14
14
  ],
15
- "scripts": {
16
- "prepack": "unbuild"
17
- },
18
15
  "dependencies": {
19
- "@babel/core": "^7.18.13",
16
+ "@babel/core": "^7.20.12",
20
17
  "@nuxt/friendly-errors-webpack-plugin": "^2.5.2",
21
- "@nuxt/kit": "3.0.0-rc.9",
22
- "autoprefixer": "^10.4.8",
23
- "css-loader": "^6.7.1",
24
- "css-minimizer-webpack-plugin": "^4.0.0",
25
- "cssnano": "^5.1.13",
26
- "esbuild-loader": "^2.19.0",
18
+ "@nuxt/kit": "3.1.0",
19
+ "autoprefixer": "^10.4.13",
20
+ "css-loader": "^6.7.3",
21
+ "css-minimizer-webpack-plugin": "^4.2.2",
22
+ "cssnano": "^5.1.14",
23
+ "esbuild-loader": "^2.21.0",
27
24
  "escape-string-regexp": "^5.0.0",
28
- "estree-walker": "^3.0.1",
25
+ "estree-walker": "^3.0.3",
29
26
  "file-loader": "^6.2.0",
30
- "fork-ts-checker-webpack-plugin": "^7.2.13",
31
- "fs-extra": "^10.1.0",
27
+ "fork-ts-checker-webpack-plugin": "^7.3.0",
28
+ "fs-extra": "^11.1.0",
32
29
  "hash-sum": "^2.0.0",
33
30
  "lodash-es": "^4.17.21",
34
- "magic-string": "^0.26.3",
35
- "memfs": "^3.4.7",
36
- "mini-css-extract-plugin": "^2.6.1",
37
- "mlly": "^0.5.14",
38
- "ohash": "^0.1.5",
39
- "pathe": "^0.3.5",
31
+ "magic-string": "^0.27.0",
32
+ "memfs": "^3.4.13",
33
+ "mini-css-extract-plugin": "^2.7.2",
34
+ "mlly": "^1.1.0",
35
+ "ohash": "^1.0.0",
36
+ "pathe": "^1.0.0",
40
37
  "pify": "^6.1.0",
41
- "postcss": "^8.4.16",
42
- "postcss-import": "^15.0.0",
43
- "postcss-loader": "^7.0.1",
38
+ "postcss": "^8.4.21",
39
+ "postcss-import": "^15.1.0",
40
+ "postcss-loader": "^7.0.2",
44
41
  "postcss-url": "^10.1.3",
45
42
  "style-resources-loader": "^1.5.0",
46
43
  "time-fix-plugin": "^2.0.7",
47
- "ufo": "^0.8.5",
48
- "unplugin": "^0.9.2",
44
+ "ufo": "^1.0.1",
45
+ "unplugin": "^1.0.1",
49
46
  "url-loader": "^4.1.1",
50
- "vue-bundle-renderer": "^0.4.2",
51
- "vue-loader": "^17.0.0",
52
- "webpack": "^5.74.0",
53
- "webpack-bundle-analyzer": "^4.6.1",
54
- "webpack-dev-middleware": "^5.3.3",
55
- "webpack-hot-middleware": "^2.25.2",
56
- "webpack-virtual-modules": "^0.4.4",
47
+ "vue-bundle-renderer": "^1.0.0",
48
+ "vue-loader": "^17.0.1",
49
+ "webpack": "^5.75.0",
50
+ "webpack-bundle-analyzer": "^4.7.0",
51
+ "webpack-dev-middleware": "^6.0.1",
52
+ "webpack-hot-middleware": "^2.25.3",
53
+ "webpack-virtual-modules": "^0.5.0",
57
54
  "webpackbar": "^5.0.2"
58
55
  },
59
56
  "devDependencies": {
60
- "@nuxt/schema": "3.0.0-rc.9",
57
+ "@nuxt/schema": "3.1.0",
61
58
  "@types/lodash-es": "^4.17.6",
62
59
  "@types/pify": "^5.0.1",
63
- "@types/webpack-bundle-analyzer": "^4.4.2",
64
- "@types/webpack-dev-middleware": "^5.0.2",
60
+ "@types/webpack-bundle-analyzer": "^4.6.0",
61
+ "@types/webpack-dev-middleware": "^5.3.0",
65
62
  "@types/webpack-hot-middleware": "^2.25.6",
66
63
  "@types/webpack-virtual-modules": "^0",
67
64
  "unbuild": "latest",
68
- "vue": "3.2.38"
65
+ "vue": "3.2.45"
69
66
  },
70
67
  "peerDependencies": {
71
- "vue": "^3.2.38"
68
+ "vue": "^3.2.45"
72
69
  },
73
70
  "engines": {
74
- "node": "^14.16.0 || ^16.11.0 || ^17.0.0 || ^18.0.0"
75
- }
76
- }
71
+ "node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
72
+ },
73
+ "scripts": {}
74
+ }