@nx/webpack 23.0.0-beta.16 → 23.0.0-beta.18
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/index.d.ts +0 -3
- package/index.d.ts.map +1 -1
- package/index.js +1 -4
- package/migrations.json +6 -0
- package/package.json +4 -4
- package/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.d.ts +3 -0
- package/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.d.ts.map +1 -0
- package/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.js +128 -0
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { configurationGenerator } from './src/generators/configuration/configuration';
|
|
2
2
|
import { NxAppWebpackPlugin } from './src/plugins/nx-webpack-plugin/nx-app-webpack-plugin';
|
|
3
|
-
import { NxTsconfigPathsWebpackPlugin as _NxTsconfigPathsWebpackPlugin } from './src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin';
|
|
4
3
|
import { useLegacyNxPlugin } from './src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin';
|
|
5
4
|
export declare function convertConfigToWebpackPluginGenerator(...args: Parameters<typeof import('./src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin').convertConfigToWebpackPluginGenerator>): any;
|
|
6
5
|
export { configurationGenerator, useLegacyNxPlugin };
|
|
@@ -8,8 +7,6 @@ export { configurationGenerator, useLegacyNxPlugin };
|
|
|
8
7
|
export declare const webpackProjectGenerator: typeof configurationGenerator;
|
|
9
8
|
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead, which can improve graph creation by 150-200ms per file. */
|
|
10
9
|
export declare const NxWebpackPlugin: typeof NxAppWebpackPlugin;
|
|
11
|
-
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
12
|
-
export declare const NxTsconfigPathsWebpackPlugin: typeof _NxTsconfigPathsWebpackPlugin;
|
|
13
10
|
export * from './src/utils/create-copy-plugin';
|
|
14
11
|
export * from './src/utils/config';
|
|
15
12
|
export { webpackInitGenerator } from './src/generators/init/init';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/webpack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/webpack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AAM5F,wBAAgB,qCAAqC,CACnD,GAAG,IAAI,EAAE,UAAU,CACjB,cAAc,oFAAoF,EAAE,qCAAqC,CAC1I,OAKF;AAED,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,CAAC;AAGrD,wDAAwD;AACxD,eAAO,MAAM,uBAAuB,+BAAyB,CAAC;AAE9D,wIAAwI;AACxI,eAAO,MAAM,eAAe,2BAAqB,CAAC;AAElD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,cAAc,4CAA4C,CAAC;AAC3D,cAAc,+CAA+C,CAAC;AAC9D,YAAY,EACV,sBAAsB,EACtB,gCAAgC,EAChC,gBAAgB,EAChB,eAAe,GAChB,MAAM,gCAAgC,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uCAAuC,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webpackInitGenerator = exports.
|
|
3
|
+
exports.webpackInitGenerator = exports.NxWebpackPlugin = exports.webpackProjectGenerator = exports.useLegacyNxPlugin = exports.configurationGenerator = void 0;
|
|
4
4
|
exports.convertConfigToWebpackPluginGenerator = convertConfigToWebpackPluginGenerator;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const configuration_1 = require("./src/generators/configuration/configuration");
|
|
7
7
|
Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
|
|
8
8
|
const nx_app_webpack_plugin_1 = require("./src/plugins/nx-webpack-plugin/nx-app-webpack-plugin");
|
|
9
|
-
const nx_tsconfig_paths_webpack_plugin_1 = require("./src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin");
|
|
10
9
|
const use_legacy_nx_plugin_1 = require("./src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin");
|
|
11
10
|
Object.defineProperty(exports, "useLegacyNxPlugin", { enumerable: true, get: function () { return use_legacy_nx_plugin_1.useLegacyNxPlugin; } });
|
|
12
11
|
// Lazy-loaded to avoid requiring typescript before it's installed.
|
|
@@ -21,8 +20,6 @@ function convertConfigToWebpackPluginGenerator(...args) {
|
|
|
21
20
|
exports.webpackProjectGenerator = configuration_1.configurationGenerator;
|
|
22
21
|
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead, which can improve graph creation by 150-200ms per file. */
|
|
23
22
|
exports.NxWebpackPlugin = nx_app_webpack_plugin_1.NxAppWebpackPlugin;
|
|
24
|
-
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
25
|
-
exports.NxTsconfigPathsWebpackPlugin = nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin;
|
|
26
23
|
tslib_1.__exportStar(require("./src/utils/create-copy-plugin"), exports);
|
|
27
24
|
tslib_1.__exportStar(require("./src/utils/config"), exports);
|
|
28
25
|
var init_1 = require("./src/generators/init/init");
|
package/migrations.json
CHANGED
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
"version": "22.0.0-beta.0",
|
|
12
12
|
"description": "Remove deprecated deleteOutputPath and sassImplementation options from @nx/webpack:webpack",
|
|
13
13
|
"implementation": "./src/migrations/update-22-0-0/remove-deprecated-options"
|
|
14
|
+
},
|
|
15
|
+
"update-23-0-0-remove-nx-tsconfig-paths-webpack-plugin-import": {
|
|
16
|
+
"cli": "nx",
|
|
17
|
+
"version": "23.0.0-beta.10",
|
|
18
|
+
"description": "Rewrites imports of NxTsconfigPathsWebpackPlugin from '@nx/webpack' to the sub-path '@nx/webpack/tsconfig-paths-plugin'.",
|
|
19
|
+
"factory": "./src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import"
|
|
14
20
|
}
|
|
15
21
|
},
|
|
16
22
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.18",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
|
|
6
6
|
"repository": {
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"webpack-dev-server": "^5.2.1",
|
|
66
66
|
"webpack-node-externals": "^3.0.0",
|
|
67
67
|
"webpack-subresource-integrity": "^5.1.0",
|
|
68
|
-
"@nx/devkit": "23.0.0-beta.
|
|
69
|
-
"@nx/js": "23.0.0-beta.
|
|
68
|
+
"@nx/devkit": "23.0.0-beta.18",
|
|
69
|
+
"@nx/js": "23.0.0-beta.18"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"nx": "23.0.0-beta.
|
|
72
|
+
"nx": "23.0.0-beta.18"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-nx-tsconfig-paths-webpack-plugin-import.d.ts","sourceRoot":"","sources":["../../../../../../packages/webpack/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAwB,MAAM,YAAY,CAAC;AA8BrE,wBAA8B,wCAAwC,CACpE,IAAI,EAAE,IAAI,iBAwHX"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = removeNxTsconfigPathsWebpackPluginImport;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const DEPRECATED_SYMBOL = 'NxTsconfigPathsWebpackPlugin';
|
|
7
|
+
const DEPRECATED_PACKAGE = '@nx/webpack';
|
|
8
|
+
const NEW_PACKAGE = '@nx/webpack/tsconfig-paths-plugin';
|
|
9
|
+
// ES module import: import { NxTsconfigPathsWebpackPlugin[, ...] } from '@nx/webpack'
|
|
10
|
+
const ES_IMPORT_SELECTOR = `ImportDeclaration:has(StringLiteral[value=${DEPRECATED_PACKAGE}]):has(ImportClause ImportSpecifier > Identifier[name=${DEPRECATED_SYMBOL}])`;
|
|
11
|
+
const IMPORT_SPECIFIERS_SELECTOR = `ImportClause ImportSpecifier`;
|
|
12
|
+
const TARGET_IMPORT_SPECIFIER_SELECTOR = `ImportClause ImportSpecifier > Identifier[name=${DEPRECATED_SYMBOL}]`;
|
|
13
|
+
const ES_MODULE_PATH_SELECTOR = `StringLiteral[value=${DEPRECATED_PACKAGE}]`;
|
|
14
|
+
// CJS require: const { NxTsconfigPathsWebpackPlugin[, ...] } = require('@nx/webpack')
|
|
15
|
+
const CJS_REQUIRE_STMT_SELECTOR = `VariableStatement:has(ObjectBindingPattern > BindingElement > Identifier[name=${DEPRECATED_SYMBOL}]):has(CallExpression:has(Identifier[name=require]) > StringLiteral[value=${DEPRECATED_PACKAGE}])`;
|
|
16
|
+
const CJS_BINDING_ELEMENTS_SELECTOR = `ObjectBindingPattern > BindingElement`;
|
|
17
|
+
const CJS_TARGET_BINDING_SELECTOR = `ObjectBindingPattern > BindingElement > Identifier[name=${DEPRECATED_SYMBOL}]`;
|
|
18
|
+
const CJS_REQUIRE_PATH_SELECTOR = `CallExpression:has(Identifier[name=require]) > StringLiteral[value=${DEPRECATED_PACKAGE}]`;
|
|
19
|
+
// Walk past whitespace from `fromIndex` to find a trailing comma. Returns the
|
|
20
|
+
// position AFTER the comma if found, otherwise the original index. Handles
|
|
21
|
+
// the `Foo , withReact` shape where the user wrote whitespace before the
|
|
22
|
+
// comma — `node.getEnd()` stops at the identifier and the comma sits one
|
|
23
|
+
// character past the whitespace.
|
|
24
|
+
function endAfterTrailingComma(text, fromIndex) {
|
|
25
|
+
let i = fromIndex;
|
|
26
|
+
while (i < text.length && /\s/.test(text.charAt(i)))
|
|
27
|
+
i++;
|
|
28
|
+
return text.charAt(i) === ',' ? i + 1 : fromIndex;
|
|
29
|
+
}
|
|
30
|
+
async function removeNxTsconfigPathsWebpackPluginImport(tree) {
|
|
31
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '', (filePath) => {
|
|
32
|
+
if (!filePath.endsWith('.ts') &&
|
|
33
|
+
!filePath.endsWith('.tsx') &&
|
|
34
|
+
!filePath.endsWith('.js') &&
|
|
35
|
+
!filePath.endsWith('.jsx') &&
|
|
36
|
+
!filePath.endsWith('.cjs') &&
|
|
37
|
+
!filePath.endsWith('.mjs')) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let contents = tree.read(filePath, 'utf-8');
|
|
41
|
+
if (!contents)
|
|
42
|
+
return;
|
|
43
|
+
// Quick check: must contain the deprecated symbol and the deprecated package path
|
|
44
|
+
if (!contents.includes(DEPRECATED_SYMBOL) ||
|
|
45
|
+
(!contents.includes(`'${DEPRECATED_PACKAGE}'`) &&
|
|
46
|
+
!contents.includes(`"${DEPRECATED_PACKAGE}"`))) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let changed = false;
|
|
50
|
+
// Re-parse on every iteration so multiple matches in the same file work
|
|
51
|
+
// correctly. The multi-specifier branch prepends a new declaration which
|
|
52
|
+
// shifts every offset; collected AST positions go stale after one rewrite,
|
|
53
|
+
// so process one match at a time.
|
|
54
|
+
let didRewrite = true;
|
|
55
|
+
while (didRewrite) {
|
|
56
|
+
didRewrite = false;
|
|
57
|
+
const sourceFile = (0, tsquery_1.ast)(contents);
|
|
58
|
+
const importNode = (0, tsquery_1.query)(sourceFile, ES_IMPORT_SELECTOR)[0];
|
|
59
|
+
if (importNode) {
|
|
60
|
+
const specifiers = (0, tsquery_1.query)(importNode, IMPORT_SPECIFIERS_SELECTOR);
|
|
61
|
+
const targetIdentifier = (0, tsquery_1.query)(importNode, TARGET_IMPORT_SPECIFIER_SELECTOR)[0];
|
|
62
|
+
if (targetIdentifier) {
|
|
63
|
+
// Walk to the ImportSpecifier to cover `Foo` and `Foo as Bar`.
|
|
64
|
+
const targetSpec = targetIdentifier.parent;
|
|
65
|
+
if (specifiers.length === 1) {
|
|
66
|
+
const modulePathNode = (0, tsquery_1.query)(importNode, ES_MODULE_PATH_SELECTOR)[0];
|
|
67
|
+
if (modulePathNode) {
|
|
68
|
+
contents =
|
|
69
|
+
contents.slice(0, modulePathNode.getStart()) +
|
|
70
|
+
`'${NEW_PACKAGE}'` +
|
|
71
|
+
contents.slice(modulePathNode.getEnd());
|
|
72
|
+
changed = true;
|
|
73
|
+
didRewrite = true;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Extract target spec verbatim (preserves alias)
|
|
79
|
+
const end = endAfterTrailingComma(contents, targetSpec.getEnd());
|
|
80
|
+
contents =
|
|
81
|
+
`import { ${targetSpec.getText()} } from '${NEW_PACKAGE}';\n` +
|
|
82
|
+
contents.slice(0, targetSpec.getStart()) +
|
|
83
|
+
contents.slice(end);
|
|
84
|
+
changed = true;
|
|
85
|
+
didRewrite = true;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const stmtNode = (0, tsquery_1.query)(sourceFile, CJS_REQUIRE_STMT_SELECTOR)[0];
|
|
91
|
+
if (stmtNode) {
|
|
92
|
+
const bindingElements = (0, tsquery_1.query)(stmtNode, CJS_BINDING_ELEMENTS_SELECTOR);
|
|
93
|
+
const targetIdentifier = (0, tsquery_1.query)(stmtNode, CJS_TARGET_BINDING_SELECTOR)[0];
|
|
94
|
+
if (targetIdentifier) {
|
|
95
|
+
// Walk to the BindingElement to cover `Foo` and `Foo: Bar`.
|
|
96
|
+
const targetBinding = targetIdentifier.parent;
|
|
97
|
+
if (bindingElements.length === 1) {
|
|
98
|
+
const requirePathNode = (0, tsquery_1.query)(stmtNode, CJS_REQUIRE_PATH_SELECTOR)[0];
|
|
99
|
+
if (requirePathNode) {
|
|
100
|
+
contents =
|
|
101
|
+
contents.slice(0, requirePathNode.getStart()) +
|
|
102
|
+
`'${NEW_PACKAGE}'` +
|
|
103
|
+
contents.slice(requirePathNode.getEnd());
|
|
104
|
+
changed = true;
|
|
105
|
+
didRewrite = true;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// Extract target binding verbatim (preserves alias)
|
|
111
|
+
const end = endAfterTrailingComma(contents, targetBinding.getEnd());
|
|
112
|
+
contents =
|
|
113
|
+
`const { ${targetBinding.getText()} } = require('${NEW_PACKAGE}');\n` +
|
|
114
|
+
contents.slice(0, targetBinding.getStart()) +
|
|
115
|
+
contents.slice(end);
|
|
116
|
+
changed = true;
|
|
117
|
+
didRewrite = true;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (changed) {
|
|
124
|
+
tree.write(filePath, contents);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
128
|
+
}
|