@nx/rspack 19.7.1 → 20.0.0-beta.3
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 +1 -1
- package/README.md +70 -34
- package/executors.json +2 -2
- package/module-federation.js +0 -1
- package/package.json +14 -9
- package/plugin.js +0 -1
- package/src/executors/dev-server/dev-server.impl.js +39 -38
- package/src/executors/dev-server/lib/get-dev-server-config.js +1 -3
- package/src/executors/dev-server/lib/serve-path.js +0 -1
- package/src/executors/dev-server/schema.json +3 -9
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +109 -98
- package/src/executors/module-federation-dev-server/schema.json +1 -3
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +153 -148
- package/src/executors/module-federation-ssr-dev-server/schema.json +1 -4
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +117 -125
- package/src/executors/rspack/rspack.impl.js +60 -67
- package/src/executors/rspack/schema.json +6 -26
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +0 -1
- package/src/executors/ssr-dev-server/schema.json +1 -4
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +26 -40
- package/src/generators/application/application.js +79 -76
- package/src/generators/application/lib/create-ts-config.js +5 -3
- package/src/generators/application/lib/normalize-options.js +12 -7
- package/src/generators/application/schema.json +1 -0
- package/src/generators/configuration/configuration.js +63 -65
- package/src/generators/configuration/schema.json +2 -1
- package/src/generators/init/init.js +58 -59
- package/src/generators/init/schema.json +2 -1
- package/src/generators/preset/preset.js +26 -29
- package/src/generators/preset/schema.json +1 -0
- package/src/index.js +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -7
- package/src/plugins/generate-package-json-plugin.js +1 -3
- package/src/plugins/plugin.js +81 -90
- package/src/utils/config.js +7 -11
- package/src/utils/create-compiler.js +21 -25
- package/src/utils/generator-utils.js +55 -66
- package/src/utils/get-copy-patterns.js +1 -3
- package/src/utils/jest-utils.js +0 -1
- package/src/utils/mode-utils.js +0 -1
- package/src/utils/model.js +0 -1
- package/src/utils/module-federation/build-static.remotes.js +57 -61
- package/src/utils/module-federation/dependencies.js +1 -3
- package/src/utils/module-federation/get-remotes-for-host.js +4 -8
- package/src/utils/module-federation/index.js +0 -1
- package/src/utils/module-federation/models/index.js +0 -1
- package/src/utils/module-federation/package-json.js +0 -1
- package/src/utils/module-federation/parse-static-remotes-config.js +2 -3
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +1 -2
- package/src/utils/module-federation/public-api.js +0 -1
- package/src/utils/module-federation/remotes.js +0 -1
- package/src/utils/module-federation/secondary-entry-points.js +4 -5
- package/src/utils/module-federation/share.js +22 -19
- package/src/utils/module-federation/start-remote-proxies.js +0 -1
- package/src/utils/module-federation/start-ssr-remote-proxies.js +0 -1
- package/src/utils/module-federation/typescript.js +6 -6
- package/src/utils/module-federation/with-module-federation/package-json.js +0 -1
- package/src/utils/module-federation/with-module-federation/utils.js +41 -43
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +48 -35
- package/src/utils/module-federation/with-module-federation/with-module-federation.js +56 -38
- package/src/utils/normalize-assets.js +5 -3
- package/src/utils/read-rspack-options.js +23 -27
- package/src/utils/resolve-user-defined-rspack-config.js +0 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -3
- package/src/utils/with-nx.js +30 -13
- package/src/utils/with-react.js +11 -5
- package/src/utils/with-web.js +20 -11
- package/module-federation.js.map +0 -1
- package/plugin.js.map +0 -1
- package/src/executors/dev-server/dev-server.impl.js.map +0 -1
- package/src/executors/dev-server/lib/get-dev-server-config.js.map +0 -1
- package/src/executors/dev-server/lib/serve-path.js.map +0 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +0 -1
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +0 -1
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js.map +0 -1
- package/src/executors/rspack/rspack.impl.js.map +0 -1
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js.map +0 -1
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js.map +0 -1
- package/src/generators/application/application.js.map +0 -1
- package/src/generators/application/lib/create-ts-config.js.map +0 -1
- package/src/generators/application/lib/normalize-options.js.map +0 -1
- package/src/generators/configuration/configuration.js.map +0 -1
- package/src/generators/init/init.js.map +0 -1
- package/src/generators/preset/preset.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
- package/src/plugins/generate-package-json-plugin.js.map +0 -1
- package/src/plugins/plugin.js.map +0 -1
- package/src/utils/config.js.map +0 -1
- package/src/utils/create-compiler.js.map +0 -1
- package/src/utils/generator-utils.js.map +0 -1
- package/src/utils/get-copy-patterns.js.map +0 -1
- package/src/utils/jest-utils.js.map +0 -1
- package/src/utils/mode-utils.js.map +0 -1
- package/src/utils/model.js.map +0 -1
- package/src/utils/module-federation/build-static.remotes.js.map +0 -1
- package/src/utils/module-federation/dependencies.js.map +0 -1
- package/src/utils/module-federation/get-remotes-for-host.js.map +0 -1
- package/src/utils/module-federation/index.js.map +0 -1
- package/src/utils/module-federation/models/index.js.map +0 -1
- package/src/utils/module-federation/package-json.js.map +0 -1
- package/src/utils/module-federation/parse-static-remotes-config.js.map +0 -1
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js.map +0 -1
- package/src/utils/module-federation/public-api.js.map +0 -1
- package/src/utils/module-federation/remotes.js.map +0 -1
- package/src/utils/module-federation/secondary-entry-points.js.map +0 -1
- package/src/utils/module-federation/share.js.map +0 -1
- package/src/utils/module-federation/start-remote-proxies.js.map +0 -1
- package/src/utils/module-federation/start-ssr-remote-proxies.js.map +0 -1
- package/src/utils/module-federation/typescript.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/package-json.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/utils.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation.js.map +0 -1
- package/src/utils/normalize-assets.js.map +0 -1
- package/src/utils/read-rspack-options.js.map +0 -1
- package/src/utils/resolve-user-defined-rspack-config.js.map +0 -1
- package/src/utils/versions.js.map +0 -1
- package/src/utils/with-nx.js.map +0 -1
- package/src/utils/with-react.js.map +0 -1
- package/src/utils/with-web.js.map +0 -1
|
@@ -6,76 +6,74 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const generator_utils_1 = require("../../utils/generator-utils");
|
|
7
7
|
const create_ts_config_1 = require("../application/lib/create-ts-config");
|
|
8
8
|
const init_1 = tslib_1.__importDefault(require("../init/init"));
|
|
9
|
-
function configurationGenerator(tree, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
async function configurationGenerator(tree, options) {
|
|
10
|
+
const task = await (0, init_1.default)(tree, {
|
|
11
|
+
...options,
|
|
12
|
+
// TODO: Crystalize the default rspack.config.js file.
|
|
13
|
+
// The default setup isn't crystalized so don't add plugin.
|
|
14
|
+
addPlugin: false,
|
|
15
|
+
});
|
|
16
|
+
const { targets, root, projectType } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
17
|
+
const { target, framework } = (0, generator_utils_1.determineFrameworkAndTarget)(tree, options, root, targets);
|
|
18
|
+
options.framework = framework;
|
|
19
|
+
options.target = target;
|
|
20
|
+
let foundStylePreprocessorOptions;
|
|
21
|
+
let buildTargetName = 'build';
|
|
22
|
+
let serveTargetName = 'serve';
|
|
23
|
+
/**
|
|
24
|
+
* This is for when we are converting an existing project
|
|
25
|
+
* to use the vite executors.
|
|
26
|
+
*/
|
|
27
|
+
let projectAlreadyHasRspackTargets = {};
|
|
28
|
+
if (!options.newProject) {
|
|
29
|
+
const userProvidedTargetName = {
|
|
30
|
+
build: options.buildTarget,
|
|
31
|
+
serve: options.serveTarget,
|
|
32
|
+
};
|
|
33
|
+
const { validFoundTargetName, projectContainsUnsupportedExecutor, userProvidedTargetIsUnsupported, alreadyHasNxRspackTargets, } = (0, generator_utils_1.findExistingTargetsInProject)(targets, userProvidedTargetName);
|
|
34
|
+
projectAlreadyHasRspackTargets = alreadyHasNxRspackTargets;
|
|
35
|
+
if (alreadyHasNxRspackTargets.build &&
|
|
36
|
+
(alreadyHasNxRspackTargets.serve ||
|
|
37
|
+
projectType === 'library' ||
|
|
38
|
+
options.framework === 'nest')) {
|
|
39
|
+
throw new Error(`The project ${options.project} is already configured to use the @nx/rspack executors.
|
|
40
40
|
Please try a different project, or remove the existing targets
|
|
41
41
|
and re-run this generator to reset the existing Rspack Configuration.
|
|
42
42
|
`);
|
|
43
|
-
}
|
|
44
|
-
if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {
|
|
45
|
-
throw new Error(`The project ${options.project} cannot be converted to use the @nx/rspack executors.`);
|
|
46
|
-
}
|
|
47
|
-
if (!projectContainsUnsupportedExecutor &&
|
|
48
|
-
!validFoundTargetName.build &&
|
|
49
|
-
!validFoundTargetName.serve) {
|
|
50
|
-
yield (0, generator_utils_1.handleUnknownExecutors)(options.project);
|
|
51
|
-
}
|
|
52
|
-
yield (0, generator_utils_1.handleUnsupportedUserProvidedTargets)(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, options.framework);
|
|
53
|
-
/**
|
|
54
|
-
* Once the user is at this stage, then they can go ahead and convert.
|
|
55
|
-
*/
|
|
56
|
-
buildTargetName = (_a = validFoundTargetName.build) !== null && _a !== void 0 ? _a : buildTargetName;
|
|
57
|
-
serveTargetName = (_b = validFoundTargetName.serve) !== null && _b !== void 0 ? _b : serveTargetName;
|
|
58
|
-
// Not needed atm
|
|
59
|
-
// if (projectType === 'application' && options.target !== 'node') {
|
|
60
|
-
// moveAndEditIndexHtml(tree, options, buildTargetName);
|
|
61
|
-
// }
|
|
62
|
-
foundStylePreprocessorOptions =
|
|
63
|
-
(_d = (_c = targets === null || targets === void 0 ? void 0 : targets[buildTargetName]) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.stylePreprocessorOptions;
|
|
64
|
-
(0, generator_utils_1.deleteWebpackConfig)(tree, root, (_f = (_e = targets === null || targets === void 0 ? void 0 : targets[buildTargetName]) === null || _e === void 0 ? void 0 : _e.options) === null || _f === void 0 ? void 0 : _f.webpackConfig);
|
|
65
|
-
(0, create_ts_config_1.editTsConfig)(tree, root, options.framework, (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(root), 'tsconfig.base.json'));
|
|
66
43
|
}
|
|
67
|
-
if (!
|
|
68
|
-
|
|
44
|
+
if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {
|
|
45
|
+
throw new Error(`The project ${options.project} cannot be converted to use the @nx/rspack executors.`);
|
|
69
46
|
}
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
!
|
|
73
|
-
(0, generator_utils_1.
|
|
47
|
+
if (!projectContainsUnsupportedExecutor &&
|
|
48
|
+
!validFoundTargetName.build &&
|
|
49
|
+
!validFoundTargetName.serve) {
|
|
50
|
+
await (0, generator_utils_1.handleUnknownExecutors)(options.project);
|
|
74
51
|
}
|
|
75
|
-
(0, generator_utils_1.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
52
|
+
await (0, generator_utils_1.handleUnsupportedUserProvidedTargets)(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, options.framework);
|
|
53
|
+
/**
|
|
54
|
+
* Once the user is at this stage, then they can go ahead and convert.
|
|
55
|
+
*/
|
|
56
|
+
buildTargetName = validFoundTargetName.build ?? buildTargetName;
|
|
57
|
+
serveTargetName = validFoundTargetName.serve ?? serveTargetName;
|
|
58
|
+
// Not needed atm
|
|
59
|
+
// if (projectType === 'application' && options.target !== 'node') {
|
|
60
|
+
// moveAndEditIndexHtml(tree, options, buildTargetName);
|
|
61
|
+
// }
|
|
62
|
+
foundStylePreprocessorOptions =
|
|
63
|
+
targets?.[buildTargetName]?.options?.stylePreprocessorOptions;
|
|
64
|
+
(0, generator_utils_1.deleteWebpackConfig)(tree, root, targets?.[buildTargetName]?.options?.webpackConfig);
|
|
65
|
+
(0, create_ts_config_1.editTsConfig)(tree, root, options.framework, (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(root), 'tsconfig.base.json'));
|
|
66
|
+
}
|
|
67
|
+
if (!projectAlreadyHasRspackTargets.build) {
|
|
68
|
+
(0, generator_utils_1.addOrChangeBuildTarget)(tree, options, buildTargetName);
|
|
69
|
+
}
|
|
70
|
+
if ((options.framework !== 'none' || options.devServer) &&
|
|
71
|
+
options.framework !== 'nest' &&
|
|
72
|
+
!projectAlreadyHasRspackTargets.serve) {
|
|
73
|
+
(0, generator_utils_1.addOrChangeServeTarget)(tree, options, serveTargetName);
|
|
74
|
+
}
|
|
75
|
+
(0, generator_utils_1.writeRspackConfigFile)(tree, options, foundStylePreprocessorOptions);
|
|
76
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
77
|
+
return task;
|
|
79
78
|
}
|
|
80
79
|
exports.default = configurationGenerator;
|
|
81
|
-
//# sourceMappingURL=configuration.js.map
|
|
@@ -2,71 +2,70 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rspackInitSchematic = void 0;
|
|
4
4
|
exports.rspackInitGenerator = rspackInitGenerator;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
8
7
|
const js_1 = require("@nx/js");
|
|
9
8
|
const plugin_1 = require("../../../plugin");
|
|
10
9
|
const versions_1 = require("../../utils/versions");
|
|
11
|
-
function rspackInitGenerator(tree, schema) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const devDependencies = {
|
|
47
|
-
'@rspack/core': versions_1.rspackCoreVersion,
|
|
48
|
-
'@rspack/cli': versions_1.rspackCoreVersion,
|
|
49
|
-
'@rspack/plugin-minify': versions_1.rspackPluginMinifyVersion,
|
|
50
|
-
'@rspack/plugin-react-refresh': versions_1.rspackPluginReactRefreshVersion,
|
|
51
|
-
'react-refresh': versions_1.reactRefreshVersion,
|
|
52
|
-
};
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
54
|
-
const version = require('../../../package.json').version;
|
|
55
|
-
if (version !== '0.0.1') {
|
|
56
|
-
// Ignored for local dev / e2e tests.
|
|
57
|
-
devDependencies['@nx/rspack'] = version;
|
|
58
|
-
}
|
|
59
|
-
if (schema.style === 'less') {
|
|
60
|
-
devDependencies['less-loader'] = versions_1.lessLoaderVersion;
|
|
61
|
-
}
|
|
62
|
-
if (schema.framework !== 'none' || schema.devServer) {
|
|
63
|
-
devDependencies['@rspack/dev-server'] = versions_1.rspackDevServerVersion;
|
|
64
|
-
}
|
|
65
|
-
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
66
|
-
tasks.push(installTask);
|
|
67
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
10
|
+
async function rspackInitGenerator(tree, schema) {
|
|
11
|
+
const tasks = [];
|
|
12
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
13
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
14
|
+
nxJson.useInferencePlugins !== false;
|
|
15
|
+
schema.addPlugin ??= addPluginDefault;
|
|
16
|
+
if (schema.addPlugin) {
|
|
17
|
+
await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rspack/plugin', plugin_1.createNodesV2, {
|
|
18
|
+
buildTargetName: [
|
|
19
|
+
'build',
|
|
20
|
+
'rspack:build',
|
|
21
|
+
'build:rspack',
|
|
22
|
+
'rspack-build',
|
|
23
|
+
'build-rspack',
|
|
24
|
+
],
|
|
25
|
+
serveTargetName: [
|
|
26
|
+
'serve',
|
|
27
|
+
'rspack:serve',
|
|
28
|
+
'serve:rspack',
|
|
29
|
+
'rspack-serve',
|
|
30
|
+
'serve-rspack',
|
|
31
|
+
],
|
|
32
|
+
previewTargetName: [
|
|
33
|
+
'preview',
|
|
34
|
+
'rspack:preview',
|
|
35
|
+
'preview:rspack',
|
|
36
|
+
'rspack-preview',
|
|
37
|
+
'preview-rspack',
|
|
38
|
+
],
|
|
39
|
+
}, schema.updatePackageScripts);
|
|
40
|
+
}
|
|
41
|
+
const jsInitTask = await (0, js_1.initGenerator)(tree, {
|
|
42
|
+
...schema,
|
|
43
|
+
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
44
|
+
skipFormat: true,
|
|
68
45
|
});
|
|
46
|
+
tasks.push(jsInitTask);
|
|
47
|
+
const devDependencies = {
|
|
48
|
+
'@rspack/core': versions_1.rspackCoreVersion,
|
|
49
|
+
'@rspack/cli': versions_1.rspackCoreVersion,
|
|
50
|
+
'@rspack/plugin-minify': versions_1.rspackPluginMinifyVersion,
|
|
51
|
+
'@rspack/plugin-react-refresh': versions_1.rspackPluginReactRefreshVersion,
|
|
52
|
+
'react-refresh': versions_1.reactRefreshVersion,
|
|
53
|
+
};
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
55
|
+
const version = require('../../../package.json').version;
|
|
56
|
+
if (version !== '0.0.1') {
|
|
57
|
+
// Ignored for local dev / e2e tests.
|
|
58
|
+
devDependencies['@nx/rspack'] = version;
|
|
59
|
+
}
|
|
60
|
+
if (schema.style === 'less') {
|
|
61
|
+
devDependencies['less-loader'] = versions_1.lessLoaderVersion;
|
|
62
|
+
}
|
|
63
|
+
if (schema.framework !== 'none' || schema.devServer) {
|
|
64
|
+
devDependencies['@rspack/dev-server'] = versions_1.rspackDevServerVersion;
|
|
65
|
+
}
|
|
66
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
67
|
+
tasks.push(installTask);
|
|
68
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
69
69
|
}
|
|
70
70
|
exports.default = rspackInitGenerator;
|
|
71
71
|
exports.rspackInitSchematic = (0, devkit_1.convertNxGenerator)(rspackInitGenerator);
|
|
72
|
-
//# sourceMappingURL=init.js.map
|
|
@@ -4,34 +4,31 @@ exports.default = default_1;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const application_1 = tslib_1.__importDefault(require("../application/application"));
|
|
7
|
-
function default_1(tree, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f;
|
|
20
|
-
var _g, _h, _j, _k, _l;
|
|
21
|
-
(_a = json.scripts) !== null && _a !== void 0 ? _a : (json.scripts = {});
|
|
22
|
-
(_b = (_g = json.scripts).build) !== null && _b !== void 0 ? _b : (_g.build = 'npx nx build');
|
|
23
|
-
(_c = (_h = json.scripts).start) !== null && _c !== void 0 ? _c : (_h.start = 'npx nx serve');
|
|
24
|
-
(_d = (_j = json.scripts).lint) !== null && _d !== void 0 ? _d : (_j.lint = 'npx nx lint');
|
|
25
|
-
(_e = (_k = json.scripts).test) !== null && _e !== void 0 ? _e : (_k.test = 'npx nx test');
|
|
26
|
-
(_f = (_l = json.scripts).e2e) !== null && _f !== void 0 ? _f : (_l.e2e = 'npx nx e2e e2e');
|
|
27
|
-
return json;
|
|
28
|
-
});
|
|
29
|
-
if (options.rootProject) {
|
|
30
|
-
// Remove these folders so projects will be generated at the root.
|
|
31
|
-
tree.delete('apps');
|
|
32
|
-
tree.delete('libs');
|
|
33
|
-
}
|
|
34
|
-
return appTask;
|
|
7
|
+
async function default_1(tree, options) {
|
|
8
|
+
const appTask = (0, application_1.default)(tree, {
|
|
9
|
+
...options,
|
|
10
|
+
// Since `--style` is not passed down to custom preset, we're using individual flags for now.
|
|
11
|
+
style: options.sass
|
|
12
|
+
? 'scss'
|
|
13
|
+
: options.less
|
|
14
|
+
? 'less'
|
|
15
|
+
: options.stylus
|
|
16
|
+
? 'styl'
|
|
17
|
+
: 'css',
|
|
35
18
|
});
|
|
19
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
20
|
+
json.scripts ??= {};
|
|
21
|
+
json.scripts.build ??= 'npx nx build';
|
|
22
|
+
json.scripts.start ??= 'npx nx serve';
|
|
23
|
+
json.scripts.lint ??= 'npx nx lint';
|
|
24
|
+
json.scripts.test ??= 'npx nx test';
|
|
25
|
+
json.scripts.e2e ??= 'npx nx e2e e2e';
|
|
26
|
+
return json;
|
|
27
|
+
});
|
|
28
|
+
if (options.rootProject) {
|
|
29
|
+
// Remove these folders so projects will be generated at the root.
|
|
30
|
+
tree.delete('apps');
|
|
31
|
+
tree.delete('libs');
|
|
32
|
+
}
|
|
33
|
+
return appTask;
|
|
36
34
|
}
|
|
37
|
-
//# sourceMappingURL=preset.js.map
|
package/src/index.js
CHANGED
|
@@ -7,4 +7,3 @@ tslib_1.__exportStar(require("./utils/config"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./utils/with-nx"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./utils/with-react"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./utils/with-web"), exports);
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = replacePackage;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
7
|
-
function replacePackage(tree) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
11
|
-
});
|
|
6
|
+
async function replacePackage(tree) {
|
|
7
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/rspack', '@nx/rspack');
|
|
8
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
12
9
|
}
|
|
13
|
-
//# sourceMappingURL=update-16-0-0-add-nx-packages.js.map
|
|
@@ -17,7 +17,6 @@ class GeneratePackageJsonPlugin {
|
|
|
17
17
|
name: pluginName,
|
|
18
18
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
19
19
|
}, () => {
|
|
20
|
-
var _a;
|
|
21
20
|
const helperDependencies = (0, js_1.getHelperDependenciesFromProjectGraph)(this.context.root, this.context.projectName, this.projectGraph);
|
|
22
21
|
const importHelpers = !!(0, js_1.readTsConfig)(this.options.tsConfig).options
|
|
23
22
|
.importHelpers;
|
|
@@ -36,7 +35,7 @@ class GeneratePackageJsonPlugin {
|
|
|
36
35
|
isProduction: true,
|
|
37
36
|
helperDependencies: helperDependencies.map((dep) => dep.target),
|
|
38
37
|
});
|
|
39
|
-
packageJson.main =
|
|
38
|
+
packageJson.main = packageJson.main ?? this.options.outputFileName;
|
|
40
39
|
compilation.emitAsset('package.json', new webpack_sources_1.RawSource((0, devkit_1.serializeJson)(packageJson)));
|
|
41
40
|
const packageManager = (0, devkit_1.detectPackageManager)(this.context.root);
|
|
42
41
|
compilation.emitAsset((0, js_1.getLockFileName)(packageManager), new webpack_sources_1.RawSource((0, js_1.createLockFile)(packageJson, this.projectGraph, packageManager)));
|
|
@@ -45,4 +44,3 @@ class GeneratePackageJsonPlugin {
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
exports.GeneratePackageJsonPlugin = GeneratePackageJsonPlugin;
|
|
48
|
-
//# sourceMappingURL=generate-package-json-plugin.js.map
|
package/src/plugins/plugin.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = exports.createDependencies = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
7
6
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
@@ -25,106 +24,99 @@ exports.createDependencies = createDependencies;
|
|
|
25
24
|
const rspackConfigGlob = '**/rspack.config.{js,ts,mjs,mts,cjs,cts}';
|
|
26
25
|
exports.createNodesV2 = [
|
|
27
26
|
rspackConfigGlob,
|
|
28
|
-
(configFilePaths, options, context) =>
|
|
27
|
+
async (configFilePaths, options, context) => {
|
|
29
28
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
30
|
-
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `
|
|
29
|
+
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `rspack-${optionsHash}.hash`);
|
|
31
30
|
const targetsCache = readTargetsCache(cachePath);
|
|
32
31
|
try {
|
|
33
|
-
return
|
|
32
|
+
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache), configFilePaths, options, context);
|
|
34
33
|
}
|
|
35
34
|
finally {
|
|
36
35
|
writeTargetsToCache(cachePath, targetsCache);
|
|
37
36
|
}
|
|
38
|
-
}
|
|
37
|
+
},
|
|
39
38
|
];
|
|
40
|
-
function createNodesInternal(configFilePath, options, context, targetsCache) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
targets,
|
|
61
|
-
metadata,
|
|
62
|
-
},
|
|
39
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache) {
|
|
40
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
41
|
+
// Do not create a project if package.json and project.json isn't there.
|
|
42
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
43
|
+
if (!siblingFiles.includes('package.json') &&
|
|
44
|
+
!siblingFiles.includes('project.json')) {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
const normalizedOptions = normalizeOptions(options);
|
|
48
|
+
// We do not want to alter how the hash is calculated, so appending the config file path to the hash
|
|
49
|
+
// to prevent vite/vitest files overwriting the target cache created by the other
|
|
50
|
+
const hash = (await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, normalizedOptions, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))])) + configFilePath;
|
|
51
|
+
targetsCache[hash] ??= await createRspackTargets(configFilePath, projectRoot, normalizedOptions, context);
|
|
52
|
+
const { targets, metadata } = targetsCache[hash];
|
|
53
|
+
return {
|
|
54
|
+
projects: {
|
|
55
|
+
[projectRoot]: {
|
|
56
|
+
root: projectRoot,
|
|
57
|
+
targets,
|
|
58
|
+
metadata,
|
|
63
59
|
},
|
|
64
|
-
}
|
|
65
|
-
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
66
62
|
}
|
|
67
|
-
function createRspackTargets(configFilePath, projectRoot, options, context) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
'
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
return { targets, metadata: {} };
|
|
119
|
-
});
|
|
63
|
+
async function createRspackTargets(configFilePath, projectRoot, options, context) {
|
|
64
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
65
|
+
const rspackConfig = (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)((0, path_1.join)(context.workspaceRoot, configFilePath), (0, js_1.getRootTsConfigPath)(), true);
|
|
66
|
+
const rspackOptions = await (0, read_rspack_options_1.readRspackOptions)(rspackConfig);
|
|
67
|
+
const outputPath = normalizeOutputPath(rspackOptions.output?.path, projectRoot);
|
|
68
|
+
const targets = {};
|
|
69
|
+
targets[options.buildTargetName] = {
|
|
70
|
+
command: `rspack build`,
|
|
71
|
+
options: { cwd: projectRoot, args: ['--node-env=production'] },
|
|
72
|
+
cache: true,
|
|
73
|
+
dependsOn: [`^${options.buildTargetName}`],
|
|
74
|
+
inputs: 'production' in namedInputs
|
|
75
|
+
? [
|
|
76
|
+
'production',
|
|
77
|
+
'^production',
|
|
78
|
+
{
|
|
79
|
+
externalDependencies: ['@rspack/cli'],
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
: [
|
|
83
|
+
'default',
|
|
84
|
+
'^default',
|
|
85
|
+
{
|
|
86
|
+
externalDependencies: ['@rspack/cli'],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
outputs: [outputPath],
|
|
90
|
+
};
|
|
91
|
+
targets[options.serveTargetName] = {
|
|
92
|
+
command: `rspack serve`,
|
|
93
|
+
options: {
|
|
94
|
+
cwd: projectRoot,
|
|
95
|
+
args: ['--node-env=development'],
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
targets[options.previewTargetName] = {
|
|
99
|
+
command: `rspack serve`,
|
|
100
|
+
options: {
|
|
101
|
+
cwd: projectRoot,
|
|
102
|
+
args: ['--node-env=production'],
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
targets[options.serveStaticTargetName] = {
|
|
106
|
+
executor: '@nx/web:file-server',
|
|
107
|
+
options: {
|
|
108
|
+
buildTarget: options.buildTargetName,
|
|
109
|
+
spa: true,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
return { targets, metadata: {} };
|
|
120
113
|
}
|
|
121
114
|
function normalizeOptions(options) {
|
|
122
|
-
|
|
123
|
-
options
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(_d = options.serveStaticTargetName) !== null && _d !== void 0 ? _d : (options.serveStaticTargetName = 'serve-static');
|
|
115
|
+
options ??= {};
|
|
116
|
+
options.buildTargetName ??= 'build';
|
|
117
|
+
options.serveTargetName ??= 'serve';
|
|
118
|
+
options.previewTargetName ??= 'preview';
|
|
119
|
+
options.serveStaticTargetName ??= 'serve-static';
|
|
128
120
|
return options;
|
|
129
121
|
}
|
|
130
122
|
function normalizeOutputPath(outputPath, projectRoot) {
|
|
@@ -155,4 +147,3 @@ function normalizeOutputPath(outputPath, projectRoot) {
|
|
|
155
147
|
}
|
|
156
148
|
}
|
|
157
149
|
}
|
|
158
|
-
//# sourceMappingURL=plugin.js.map
|