@nuxt/webpack-builder 3.1.0 → 3.1.2

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- MIT License
1
+ The MIT License (MIT)
2
2
 
3
3
  Copyright (c) 2016-present - Nuxt Team
4
4
 
package/README.md CHANGED
@@ -114,7 +114,7 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
114
114
 
115
115
  ## Nuxt 2
116
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).
117
+ 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 [nuxtjs.org](https://nuxtjs.org).
118
118
 
119
119
  ## Follow us
120
120
 
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 { findStaticImports, parseStaticImport, createCommonJS } from 'mlly';
14
15
  import { createFsFromVolume, Volume } from 'memfs';
15
16
  import VirtualModulesPlugin from 'webpack-virtual-modules';
16
17
  import querystring from 'node:querystring';
@@ -23,7 +24,6 @@ import escapeRegExp from 'escape-string-regexp';
23
24
  import esbuildLoader from 'esbuild-loader';
24
25
  import MiniCssExtractPlugin from 'mini-css-extract-plugin';
25
26
  import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
26
- import { createCommonJS } from 'mlly';
27
27
  import VueLoaderPlugin from 'vue-loader/dist/pluginWebpack5.js';
28
28
  import { normalizeWebpackManifest } from 'vue-bundle-renderer';
29
29
  import hash$1 from 'hash-sum';
@@ -53,6 +53,7 @@ const composableKeysPlugin = createUnplugin((options) => {
53
53
  }
54
54
  const { 0: script = code, index: codeIndex = 0 } = code.match(/(?<=<script[^>]*>)[\S\s.]*?(?=<\/script>)/) || { index: 0, 0: code };
55
55
  const s = new MagicString(code);
56
+ let imports;
56
57
  let count = 0;
57
58
  const relativeID = isAbsolute(id) ? relative(options.rootDir, id) : id;
58
59
  walk(this.parse(script, {
@@ -68,6 +69,10 @@ const composableKeysPlugin = createUnplugin((options) => {
68
69
  if (!name || !keyedFunctions.includes(name) || node.arguments.length >= 4) {
69
70
  return;
70
71
  }
72
+ imports = imports || detectImportNames(script);
73
+ if (imports.has(name)) {
74
+ return;
75
+ }
71
76
  switch (name) {
72
77
  case "useState":
73
78
  if (node.arguments.length >= 2 || stringTypes.includes(node.arguments[0]?.type)) {
@@ -103,6 +108,27 @@ const composableKeysPlugin = createUnplugin((options) => {
103
108
  }
104
109
  };
105
110
  });
111
+ const NUXT_IMPORT_RE = /nuxt|#app|#imports/;
112
+ function detectImportNames(code) {
113
+ const imports = findStaticImports(code);
114
+ const names = /* @__PURE__ */ new Set();
115
+ for (const i of imports) {
116
+ if (NUXT_IMPORT_RE.test(i.specifier)) {
117
+ continue;
118
+ }
119
+ const { namedImports, defaultImport, namespacedImport } = parseStaticImport(i);
120
+ for (const name in namedImports || {}) {
121
+ names.add(namedImports[name]);
122
+ }
123
+ if (defaultImport) {
124
+ names.add(defaultImport);
125
+ }
126
+ if (namespacedImport) {
127
+ names.add(namespacedImport);
128
+ }
129
+ }
130
+ return names;
131
+ }
106
132
 
107
133
  const defaults = {
108
134
  globalPublicPath: "__webpack_public_path__",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "repository": "nuxt/nuxt",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
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.0",
18
+ "@nuxt/kit": "3.1.2",
19
19
  "autoprefixer": "^10.4.13",
20
20
  "css-loader": "^6.7.3",
21
21
  "css-minimizer-webpack-plugin": "^4.2.2",
@@ -33,7 +33,7 @@
33
33
  "mini-css-extract-plugin": "^2.7.2",
34
34
  "mlly": "^1.1.0",
35
35
  "ohash": "^1.0.0",
36
- "pathe": "^1.0.0",
36
+ "pathe": "^1.1.0",
37
37
  "pify": "^6.1.0",
38
38
  "postcss": "^8.4.21",
39
39
  "postcss-import": "^15.1.0",
@@ -54,7 +54,7 @@
54
54
  "webpackbar": "^5.0.2"
55
55
  },
56
56
  "devDependencies": {
57
- "@nuxt/schema": "3.1.0",
57
+ "@nuxt/schema": "3.1.2",
58
58
  "@types/lodash-es": "^4.17.6",
59
59
  "@types/pify": "^5.0.1",
60
60
  "@types/webpack-bundle-analyzer": "^4.6.0",
@@ -62,10 +62,10 @@
62
62
  "@types/webpack-hot-middleware": "^2.25.6",
63
63
  "@types/webpack-virtual-modules": "^0",
64
64
  "unbuild": "latest",
65
- "vue": "3.2.45"
65
+ "vue": "3.2.47"
66
66
  },
67
67
  "peerDependencies": {
68
- "vue": "^3.2.45"
68
+ "vue": "^3.2.47"
69
69
  },
70
70
  "engines": {
71
71
  "node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"