@nx/react 23.0.0-beta.2 → 23.0.0-beta.21
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/generators.json +16 -3
- 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 +18 -18
- package/plugins/component-testing/index.js +7 -7
- package/plugins/component-testing/webpack-fallback.js +2 -2
- package/plugins/storybook/index.js +3 -3
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts.map +1 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +6 -4
- package/src/executors/module-federation-dev-server/schema.json +1 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts.map +1 -1
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +7 -5
- package/src/executors/module-federation-ssr-dev-server/schema.json +1 -0
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts.map +1 -1
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +6 -4
- package/src/executors/module-federation-static-server/schema.json +1 -0
- package/src/generators/_utils/mf-dependencies.d.ts +8 -0
- package/src/generators/_utils/mf-dependencies.d.ts.map +1 -0
- package/src/generators/_utils/mf-dependencies.js +84 -0
- package/src/generators/_utils/mf-versions.d.ts +12 -0
- package/src/generators/_utils/mf-versions.d.ts.map +1 -0
- package/src/generators/_utils/mf-versions.js +29 -0
- package/src/generators/_utils/normalize.d.ts +20 -0
- package/src/generators/_utils/normalize.d.ts.map +1 -0
- package/src/generators/_utils/normalize.js +48 -0
- package/src/generators/application/application.d.ts.map +1 -1
- package/src/generators/application/application.js +32 -18
- package/src/generators/application/lib/add-e2e.d.ts.map +1 -1
- package/src/generators/application/lib/add-linting.js +10 -11
- package/src/generators/application/lib/add-project.d.ts.map +1 -1
- package/src/generators/application/lib/add-project.js +10 -0
- package/src/generators/application/lib/add-routing.js +2 -2
- package/src/generators/application/lib/bundlers/add-vite.d.ts.map +1 -1
- package/src/generators/application/lib/bundlers/add-vite.js +10 -2
- package/src/generators/application/lib/create-application-files.d.ts +1 -1
- package/src/generators/application/lib/create-application-files.js +2 -2
- package/src/generators/application/lib/normalize-options.js +5 -5
- package/src/generators/component/component.js +2 -2
- package/src/generators/component/lib/normalize-options.d.ts.map +1 -1
- package/src/generators/component/lib/normalize-options.js +5 -6
- package/src/generators/component/schema.d.ts +2 -7
- package/src/generators/component/schema.json +0 -5
- package/src/generators/component-story/component-story.d.ts.map +1 -1
- package/src/generators/component-story/component-story.js +3 -4
- package/src/generators/component-test/component-test.d.ts.map +1 -1
- package/src/generators/component-test/component-test.js +3 -4
- package/src/generators/consumer/consumer.d.ts +5 -0
- package/src/generators/consumer/consumer.d.ts.map +1 -0
- package/src/generators/consumer/consumer.js +135 -0
- package/src/generators/consumer/files/_common/src/App.tsx__tmpl__ +53 -0
- package/src/generators/consumer/files/_common/src/bootstrap.tsx__tmpl__ +12 -0
- package/src/generators/consumer/files/_common/src/index.ts__tmpl__ +4 -0
- package/src/generators/consumer/files/_common/src/mf.ts__tmpl__ +35 -0
- package/src/generators/consumer/files/_common/tsconfig.json__tmpl__ +17 -0
- package/src/generators/consumer/files/rsbuild/index.html__tmpl__ +12 -0
- package/src/generators/consumer/files/rsbuild/package.json__tmpl__ +23 -0
- package/src/generators/consumer/files/rsbuild/rsbuild.config.ts__tmpl__ +25 -0
- package/src/generators/consumer/files/rspack/index.html__tmpl__ +12 -0
- package/src/generators/consumer/files/rspack/package.json__tmpl__ +23 -0
- package/src/generators/consumer/files/rspack/rspack.config.ts__tmpl__ +59 -0
- package/src/generators/consumer/files/vite/index.html__tmpl__ +12 -0
- package/src/generators/consumer/files/vite/package.json__tmpl__ +24 -0
- package/src/generators/consumer/files/vite/vite.config.ts__tmpl__ +27 -0
- package/src/generators/consumer/schema.d.ts +8 -0
- package/src/generators/consumer/schema.json +43 -0
- package/src/generators/cypress-component-configuration/lib/add-files.d.ts +1 -1
- package/src/generators/cypress-component-configuration/lib/add-files.d.ts.map +1 -1
- package/src/generators/cypress-component-configuration/lib/add-files.js +4 -4
- package/src/generators/federate-module/federate-module.d.ts.map +1 -1
- package/src/generators/federate-module/federate-module.js +4 -2
- package/src/generators/federate-module/lib/utils.js +2 -2
- package/src/generators/hook/hook.d.ts.map +1 -1
- package/src/generators/hook/hook.js +5 -6
- package/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +2 -2
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +2 -2
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/host/host.d.ts.map +1 -1
- package/src/generators/host/host.js +7 -5
- package/src/generators/host/lib/add-module-federation-files.d.ts.map +1 -1
- package/src/generators/host/lib/add-module-federation-files.js +3 -3
- package/src/generators/host/lib/normalize-host-name.js +2 -2
- package/src/generators/host/lib/update-module-federation-tsconfig.js +2 -2
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +2 -2
- package/src/generators/library/lib/add-linting.js +7 -8
- package/src/generators/library/lib/add-rollup-build-target.d.ts.map +1 -1
- package/src/generators/library/lib/add-rollup-build-target.js +6 -0
- package/src/generators/library/lib/install-common-dependencies.js +2 -2
- package/src/generators/library/lib/normalize-options.d.ts.map +1 -1
- package/src/generators/library/lib/normalize-options.js +7 -7
- package/src/generators/library/lib/update-app-routes.js +2 -2
- package/src/generators/library/library.d.ts.map +1 -1
- package/src/generators/library/library.js +14 -18
- package/src/generators/provider/files/_common/src/__componentName__.tsx__tmpl__ +11 -0
- package/src/generators/provider/files/_common/src/bootstrap.tsx__tmpl__ +12 -0
- package/src/generators/provider/files/_common/src/index.ts__tmpl__ +5 -0
- package/src/generators/provider/files/_common/tsconfig.json__tmpl__ +17 -0
- package/src/generators/provider/files/rsbuild/index.html__tmpl__ +12 -0
- package/src/generators/provider/files/rsbuild/package.json__tmpl__ +22 -0
- package/src/generators/provider/files/rsbuild/rsbuild.config.ts__tmpl__ +31 -0
- package/src/generators/provider/files/rspack/index.html__tmpl__ +12 -0
- package/src/generators/provider/files/rspack/package.json__tmpl__ +22 -0
- package/src/generators/provider/files/rspack/rspack.config.ts__tmpl__ +69 -0
- package/src/generators/provider/files/vite/index.html__tmpl__ +12 -0
- package/src/generators/provider/files/vite/package.json__tmpl__ +23 -0
- package/src/generators/provider/files/vite/vite.config.ts__tmpl__ +37 -0
- package/src/generators/provider/provider.d.ts +5 -0
- package/src/generators/provider/provider.d.ts.map +1 -0
- package/src/generators/provider/provider.js +92 -0
- package/src/generators/provider/schema.d.ts +9 -0
- package/src/generators/provider/schema.json +46 -0
- package/src/generators/redux/redux.d.ts.map +1 -1
- package/src/generators/redux/redux.js +7 -8
- package/src/generators/redux/schema.d.ts +1 -1
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
- package/src/generators/remote/lib/setup-package-json-exports-for-remote.js +2 -2
- package/src/generators/remote/lib/update-host-with-remote.js +4 -5
- package/src/generators/remote/remote.d.ts.map +1 -1
- package/src/generators/remote/remote.js +9 -7
- package/src/generators/setup-ssr/setup-ssr.d.ts.map +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +5 -7
- package/src/generators/stories/stories.js +5 -6
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts.map +1 -1
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +2 -2
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.d.ts.map +1 -1
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.js +2 -2
- package/src/migrations/update-22-0-0/add-svgr-to-webpack-config.d.ts.map +1 -1
- package/src/migrations/update-22-0-0/add-svgr-to-webpack-config.js +2 -2
- package/src/migrations/update-23-0-0/remove-nx-react-webpack-plugin-import.d.ts +3 -0
- package/src/migrations/update-23-0-0/remove-nx-react-webpack-plugin-import.d.ts.map +1 -0
- package/src/migrations/update-23-0-0/remove-nx-react-webpack-plugin-import.js +128 -0
- package/src/module-federation/ast-utils.js +2 -2
- package/src/plugins/router-plugin.d.ts.map +1 -1
- package/src/plugins/router-plugin.js +14 -23
- package/src/rules/update-module-federation-project.js +3 -3
- package/src/utils/add-mf-env-to-inputs.d.ts.map +1 -1
- package/src/utils/add-mf-env-to-inputs.js +15 -8
- package/src/utils/ast-utils.js +15 -15
- package/src/utils/component-props.js +3 -3
- package/src/utils/create-ts-config.js +3 -3
- package/src/utils/ct-utils.d.ts +1 -1
- package/src/utils/ct-utils.d.ts.map +1 -1
- package/src/utils/ct-utils.js +6 -6
- package/src/utils/module-federation-deprecation.d.ts +13 -0
- package/src/utils/module-federation-deprecation.d.ts.map +1 -0
- package/src/utils/module-federation-deprecation.js +46 -0
- package/src/utils/normalize-remote.js +2 -2
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/tailwind.js +2 -2
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addModuleFederationFiles = addModuleFederationFiles;
|
|
4
4
|
exports.remoteGenerator = remoteGenerator;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
7
|
const devkit_1 = require("@nx/devkit");
|
|
7
8
|
const path_1 = require("path");
|
|
8
|
-
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
9
9
|
const js_1 = require("@nx/js");
|
|
10
|
-
const
|
|
10
|
+
const internal_2 = require("@nx/js/internal");
|
|
11
11
|
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
|
12
12
|
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
13
13
|
const normalize_remote_1 = require("../../utils/normalize-remote");
|
|
14
14
|
const maybe_js_1 = require("../../utils/maybe-js");
|
|
15
|
+
const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
|
|
15
16
|
const versions_1 = require("../../utils/versions");
|
|
16
17
|
const application_1 = tslib_1.__importDefault(require("../application/application"));
|
|
17
18
|
const create_application_files_1 = require("../application/lib/create-application-files");
|
|
@@ -57,7 +58,7 @@ function addModuleFederationFiles(host, options) {
|
|
|
57
58
|
host.delete(pathToWebpackProdConfig);
|
|
58
59
|
}
|
|
59
60
|
// Delete TypeScript prod config in TS solution setup - not needed in Crystal
|
|
60
|
-
if ((0,
|
|
61
|
+
if ((0, internal_2.isUsingTsSolutionSetup)(host)) {
|
|
61
62
|
const pathToTsProdConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, options.bundler === 'rspack'
|
|
62
63
|
? 'rspack.config.prod.ts'
|
|
63
64
|
: 'webpack.config.prod.ts');
|
|
@@ -68,6 +69,7 @@ function addModuleFederationFiles(host, options) {
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
async function remoteGenerator(host, schema) {
|
|
72
|
+
(0, module_federation_deprecation_1.warnReactRemoteGeneratorDeprecation)();
|
|
71
73
|
const tasks = [];
|
|
72
74
|
const name = await (0, normalize_remote_1.normalizeRemoteName)(host, schema.name, schema);
|
|
73
75
|
const options = {
|
|
@@ -93,7 +95,7 @@ async function remoteGenerator(host, schema) {
|
|
|
93
95
|
throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
|
-
await (0,
|
|
98
|
+
await (0, internal_1.ensureRootProjectName)(options, 'application');
|
|
97
99
|
const isValidRemote = (0, js_1.isValidVariable)(options.projectName);
|
|
98
100
|
if (!isValidRemote.isValid) {
|
|
99
101
|
throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
|
|
@@ -105,7 +107,7 @@ async function remoteGenerator(host, schema) {
|
|
|
105
107
|
});
|
|
106
108
|
tasks.push(initAppTask);
|
|
107
109
|
// In TS solution setup, update package.json to use simple name instead of scoped name
|
|
108
|
-
if ((0,
|
|
110
|
+
if ((0, internal_2.isUsingTsSolutionSetup)(host)) {
|
|
109
111
|
const remotePackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
|
|
110
112
|
if (host.exists(remotePackageJsonPath)) {
|
|
111
113
|
(0, devkit_1.updateJson)(host, remotePackageJsonPath, (json) => {
|
|
@@ -124,7 +126,7 @@ async function remoteGenerator(host, schema) {
|
|
|
124
126
|
addModuleFederationFiles(host, options);
|
|
125
127
|
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
126
128
|
// Conditionally setup TS path or package.json exports based on TS solution setup
|
|
127
|
-
if ((0,
|
|
129
|
+
if ((0, internal_2.isUsingTsSolutionSetup)(host)) {
|
|
128
130
|
(0, setup_package_json_exports_for_remote_1.setupPackageJsonExportsForRemote)(host, options);
|
|
129
131
|
}
|
|
130
132
|
else {
|
|
@@ -160,7 +162,7 @@ async function remoteGenerator(host, schema) {
|
|
|
160
162
|
}
|
|
161
163
|
if (options.host && options.dynamic) {
|
|
162
164
|
const hostConfig = (0, devkit_1.readProjectConfiguration)(host, schema.host);
|
|
163
|
-
const pathToMFManifest = (0, devkit_1.joinPathFragments)((0,
|
|
165
|
+
const pathToMFManifest = (0, devkit_1.joinPathFragments)((0, internal_2.getProjectSourceRoot)(hostConfig, host), 'assets/module-federation.manifest.json');
|
|
164
166
|
(0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.projectName, options.devServerPort, pathToMFManifest);
|
|
165
167
|
}
|
|
166
168
|
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/setup-ssr/setup-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,IAAI,EAGL,MAAM,YAAY,CAAC;AAcpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA2CvC,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"setup-ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/setup-ssr/setup-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,IAAI,EAGL,MAAM,YAAY,CAAC;AAcpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA2CvC,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mDAgNlE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupSsrGenerator = setupSsrGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
+
const internal_2 = require("@nx/js/internal");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
10
|
let tsModule;
|
|
11
11
|
function readEntryFile(host, path) {
|
|
12
12
|
if (!tsModule) {
|
|
13
|
-
tsModule = (0,
|
|
13
|
+
tsModule = (0, internal_2.ensureTypescript)();
|
|
14
14
|
}
|
|
15
15
|
const content = host.read(path, 'utf-8');
|
|
16
16
|
return {
|
|
@@ -44,7 +44,7 @@ async function setupSsrGenerator(tree, options) {
|
|
|
44
44
|
].map((importPath) => {
|
|
45
45
|
return {
|
|
46
46
|
importPath,
|
|
47
|
-
filePath: (0, devkit_1.joinPathFragments)((0,
|
|
47
|
+
filePath: (0, devkit_1.joinPathFragments)((0, internal_2.getProjectSourceRoot)(projectConfig, tree), `${importPath}.tsx`),
|
|
48
48
|
};
|
|
49
49
|
});
|
|
50
50
|
const appComponentInfo = appImportCandidates.find((candidate) => tree.exists(candidate.filePath));
|
|
@@ -160,9 +160,6 @@ async function setupSsrGenerator(tree, options) {
|
|
|
160
160
|
'server',
|
|
161
161
|
];
|
|
162
162
|
}
|
|
163
|
-
nxJson.targetDefaults ??= {};
|
|
164
|
-
nxJson.targetDefaults['server'] ??= {};
|
|
165
|
-
nxJson.targetDefaults.server.cache = true;
|
|
166
163
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), projectRoot, {
|
|
167
164
|
tmpl: '',
|
|
168
165
|
port: Number(options?.serverPort) || 4200,
|
|
@@ -183,6 +180,7 @@ async function setupSsrGenerator(tree, options) {
|
|
|
183
180
|
const changes = (0, devkit_1.applyChangesToString)(content, (0, ast_utils_1.addStaticRouter)(serverEntry, source));
|
|
184
181
|
tree.write(serverEntry, changes);
|
|
185
182
|
}
|
|
183
|
+
(0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'server', cache: true });
|
|
186
184
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
187
185
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
188
186
|
express: versions_1.expressVersion,
|
|
@@ -6,8 +6,7 @@ exports.createAllStories = createAllStories;
|
|
|
6
6
|
exports.storiesGenerator = storiesGenerator;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
|
-
const
|
|
10
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
9
|
+
const internal_1 = require("@nx/js/internal");
|
|
11
10
|
const minimatch_1 = require("minimatch");
|
|
12
11
|
const path_1 = require("path");
|
|
13
12
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
@@ -16,7 +15,7 @@ const component_story_1 = tslib_1.__importDefault(require("../component-story/co
|
|
|
16
15
|
let tsModule;
|
|
17
16
|
async function projectRootPath(tree, config) {
|
|
18
17
|
let projectDir;
|
|
19
|
-
if ((0,
|
|
18
|
+
if ((0, internal_1.getProjectType)(tree, config.root, config.projectType) === 'application') {
|
|
20
19
|
const isNextJs = await isNextJsProject(tree, config);
|
|
21
20
|
if (isNextJs) {
|
|
22
21
|
// Next.js apps
|
|
@@ -34,11 +33,11 @@ async function projectRootPath(tree, config) {
|
|
|
34
33
|
else {
|
|
35
34
|
projectDir = '.';
|
|
36
35
|
}
|
|
37
|
-
return (0, devkit_1.joinPathFragments)((0,
|
|
36
|
+
return (0, devkit_1.joinPathFragments)((0, internal_1.getProjectSourceRoot)(config, tree), projectDir);
|
|
38
37
|
}
|
|
39
38
|
function containsComponentDeclaration(tree, componentPath) {
|
|
40
39
|
if (!tsModule) {
|
|
41
|
-
tsModule = (0,
|
|
40
|
+
tsModule = (0, internal_1.ensureTypescript)();
|
|
42
41
|
}
|
|
43
42
|
const contents = tree.read(componentPath, 'utf-8');
|
|
44
43
|
if (contents === null) {
|
|
@@ -50,7 +49,7 @@ function containsComponentDeclaration(tree, componentPath) {
|
|
|
50
49
|
}
|
|
51
50
|
async function createAllStories(tree, schema, projectConfiguration) {
|
|
52
51
|
const { isTheFileAStory } = await Promise.resolve().then(() => tslib_1.__importStar(require('@nx/storybook/src/utils/utilities')));
|
|
53
|
-
const sourceRoot = (0,
|
|
52
|
+
const sourceRoot = (0, internal_1.getProjectSourceRoot)(projectConfiguration, tree);
|
|
54
53
|
let componentPaths = [];
|
|
55
54
|
const projectPath = await projectRootPath(tree, projectConfiguration);
|
|
56
55
|
(0, devkit_1.visitNotIgnoredFiles)(tree, projectPath, (path) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-with-mf-import-to-new-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrate-with-mf-import-to-new-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAQpB,wBAA8B,mBAAmB,CAAC,IAAI,EAAE,IAAI,iBAqD3D"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = migrateWithMfImport;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
8
|
const NX_RSPACK_MODULE_FEDERATION_IMPORT_SELECTOR = 'ImportDeclaration > StringLiteral[value=@nx/react/module-federation], VariableStatement CallExpression:has(Identifier[name=require]) > StringLiteral[value=@nx/react/module-federation]';
|
|
9
9
|
const NEW_IMPORT_PATH = `'@nx/module-federation/webpack'`;
|
|
10
10
|
async function migrateWithMfImport(tree) {
|
|
11
11
|
const projects = new Set();
|
|
12
|
-
(0,
|
|
12
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', (options, project, target) => {
|
|
13
13
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
14
14
|
projects.add(projectConfig.root);
|
|
15
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-nx-module-federation-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-20-3-0/ensure-nx-module-federation-package.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ensure-nx-module-federation-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-20-3-0/ensure-nx-module-federation-package.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAGpB,wBAA8B,eAAe,CAAC,IAAI,EAAE,IAAI,iBAqBvD"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = ensureMfPackage;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const versions_1 = require("../../utils/versions");
|
|
7
7
|
async function ensureMfPackage(tree) {
|
|
8
8
|
const projects = new Set();
|
|
9
|
-
(0,
|
|
9
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', (options, project, target) => {
|
|
10
10
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
11
11
|
projects.add(projectConfig.root);
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-svgr-to-webpack-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-22-0-0/add-svgr-to-webpack-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-svgr-to-webpack-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-22-0-0/add-svgr-to-webpack-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAgHpB,wBAA8B,sBAAsB,CAAC,IAAI,EAAE,IAAI,iBAsZ9D"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = addSvgrToWebpackConfig;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
7
7
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
8
8
|
const ts = tslib_1.__importStar(require("typescript"));
|
|
9
9
|
const withSvgrFunctionForWithReact = `
|
|
@@ -115,7 +115,7 @@ function withSvgr(svgrOptions = {}) {
|
|
|
115
115
|
async function addSvgrToWebpackConfig(tree) {
|
|
116
116
|
const projects = new Map();
|
|
117
117
|
// Find all React webpack projects using either withReact OR NxReactWebpackPlugin
|
|
118
|
-
(0,
|
|
118
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nx/webpack:webpack', (options, project, target) => {
|
|
119
119
|
if (!options.webpackConfig)
|
|
120
120
|
return;
|
|
121
121
|
const webpackConfigPath = options.webpackConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-nx-react-webpack-plugin-import.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/migrations/update-23-0-0/remove-nx-react-webpack-plugin-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAwB,MAAM,YAAY,CAAC;AA8BrE,wBAA8B,gCAAgC,CAAC,IAAI,EAAE,IAAI,iBAuHxE"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = removeNxReactWebpackPluginImport;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const DEPRECATED_SYMBOL = 'NxReactWebpackPlugin';
|
|
7
|
+
const DEPRECATED_PACKAGE = '@nx/react';
|
|
8
|
+
const NEW_PACKAGE = '@nx/react/webpack-plugin';
|
|
9
|
+
// ES module import: import { NxReactWebpackPlugin[, ...] } from '@nx/react'
|
|
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 { NxReactWebpackPlugin[, ...] } = require('@nx/react')
|
|
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 removeNxReactWebpackPluginImport(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
|
+
}
|
|
@@ -6,11 +6,11 @@ exports.addRemoteRoute = addRemoteRoute;
|
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
8
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
9
|
-
const
|
|
9
|
+
const internal_1 = require("@nx/js/internal");
|
|
10
10
|
let tsModule;
|
|
11
11
|
function addRemoteToConfig(source, app) {
|
|
12
12
|
if (!tsModule) {
|
|
13
|
-
tsModule = (0,
|
|
13
|
+
tsModule = (0, internal_1.ensureTypescript)();
|
|
14
14
|
}
|
|
15
15
|
const assignments = (0, js_1.findNodes)(source, tsModule.SyntaxKind.PropertyAssignment);
|
|
16
16
|
const remotesAssignment = assignments.find((s) => s.name.getText() === 'remotes');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/react/src/plugins/router-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router-plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/react/src/plugins/router-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,aAAa,EAQnB,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,wBAAwB;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAUD,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,wBAAwB,CA2FjE,CAAC"}
|
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const fs_1 = require("fs");
|
|
7
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
8
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
9
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
10
9
|
const js_1 = require("@nx/js");
|
|
11
10
|
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
12
|
-
const
|
|
13
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
14
|
-
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
11
|
+
const internal_2 = require("@nx/js/internal");
|
|
15
12
|
const pmCommand = (0, devkit_1.getPackageManagerCommand)();
|
|
16
13
|
const reactRouterConfigBlob = '**/react-router.config.{ts,js,cjs,cts,mjs,mts}';
|
|
17
|
-
function readTargetsCache(cachePath) {
|
|
18
|
-
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, fs_1.existsSync)(cachePath)
|
|
19
|
-
? (0, devkit_1.readJsonFile)(cachePath)
|
|
20
|
-
: {};
|
|
21
|
-
}
|
|
22
|
-
function writeTargetsToCache(cachePath, results) {
|
|
23
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
24
|
-
}
|
|
25
14
|
exports.createNodesV2 = [
|
|
26
15
|
reactRouterConfigBlob,
|
|
27
16
|
async (configFiles, options, context) => {
|
|
28
17
|
const optionsHash = (0, devkit_internals_1.hashObject)(options);
|
|
29
18
|
const normalizedOptions = normalizeOptions(options);
|
|
30
19
|
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `react-router-${optionsHash}.hash`);
|
|
31
|
-
const targetsCache =
|
|
32
|
-
const isUsingTsSolutionSetup = (0,
|
|
20
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
21
|
+
const isUsingTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)();
|
|
33
22
|
const { roots: projectRoots, configFiles: validConfigFiles } = configFiles.reduce((acc, configFile) => {
|
|
34
23
|
const potentialRoot = (0, path_1.dirname)(configFile);
|
|
35
24
|
if (checkIfConfigFileShouldBeProject(potentialRoot, context)) {
|
|
@@ -42,14 +31,16 @@ exports.createNodesV2 = [
|
|
|
42
31
|
configFiles: [],
|
|
43
32
|
});
|
|
44
33
|
const lockfile = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
45
|
-
const hashes = await (0,
|
|
34
|
+
const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, { ...normalizedOptions, isUsingTsSolutionSetup }, context, projectRoots.map((_) => [lockfile]));
|
|
46
35
|
try {
|
|
47
36
|
return await (0, devkit_1.createNodesFromFiles)(async (configFile, _, context, idx) => {
|
|
48
37
|
const projectRoot = (0, path_1.dirname)(configFile);
|
|
49
38
|
const siblingFiles = (0, fs_1.readdirSync)((0, devkit_1.joinPathFragments)(context.workspaceRoot, projectRoot));
|
|
50
39
|
const hash = hashes[idx] + configFile;
|
|
51
|
-
|
|
52
|
-
await buildReactRouterTargets(configFile, projectRoot, normalizedOptions, context, siblingFiles, isUsingTsSolutionSetup));
|
|
40
|
+
if (!targetsCache.has(hash)) {
|
|
41
|
+
targetsCache.set(hash, await buildReactRouterTargets(configFile, projectRoot, normalizedOptions, context, siblingFiles, isUsingTsSolutionSetup));
|
|
42
|
+
}
|
|
43
|
+
const { projectType, metadata, targets } = targetsCache.get(hash);
|
|
53
44
|
const project = {
|
|
54
45
|
root: projectRoot,
|
|
55
46
|
targets,
|
|
@@ -66,16 +57,16 @@ exports.createNodesV2 = [
|
|
|
66
57
|
}, validConfigFiles, options, context);
|
|
67
58
|
}
|
|
68
59
|
finally {
|
|
69
|
-
|
|
60
|
+
targetsCache.writeToDisk();
|
|
70
61
|
}
|
|
71
62
|
},
|
|
72
63
|
];
|
|
73
64
|
async function buildReactRouterTargets(configFilePath, projectRoot, options, context, siblingFiles, isUsingTsSolutionSetup) {
|
|
74
|
-
const namedInputs = (0,
|
|
65
|
+
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
75
66
|
const configPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
76
67
|
if (require.cache[configPath])
|
|
77
|
-
(0,
|
|
78
|
-
const reactRouterConfig = await (0,
|
|
68
|
+
(0, internal_1.clearRequireCache)();
|
|
69
|
+
const reactRouterConfig = await (0, internal_1.loadConfigFile)(configPath);
|
|
79
70
|
const isLibMode = reactRouterConfig?.ssr !== undefined && reactRouterConfig.ssr === false;
|
|
80
71
|
const { buildDirectory, serverBuildPath } = await getBuildPaths(reactRouterConfig, isLibMode);
|
|
81
72
|
const targets = {};
|
|
@@ -85,7 +76,7 @@ async function buildReactRouterTargets(configFilePath, projectRoot, options, con
|
|
|
85
76
|
targets[options.startTargetName] = await startTarget(projectRoot, serverBuildPath, options.buildTargetName, isUsingTsSolutionSetup);
|
|
86
77
|
}
|
|
87
78
|
targets[options.typecheckTargetName] = await typecheckTarget(projectRoot, options.typecheckTargetName, namedInputs, siblingFiles, isUsingTsSolutionSetup);
|
|
88
|
-
(0,
|
|
79
|
+
(0, internal_2.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmCommand);
|
|
89
80
|
const metadata = {};
|
|
90
81
|
return {
|
|
91
82
|
targets,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateModuleFederationProject = updateModuleFederationProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const maybe_js_1 = require("../utils/maybe-js");
|
|
6
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/js/internal");
|
|
7
7
|
function updateModuleFederationProject(host, options, isHost = false) {
|
|
8
8
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
9
9
|
projectConfig.targets ??= {};
|
|
@@ -14,7 +14,7 @@ function updateModuleFederationProject(host, options, isHost = false) {
|
|
|
14
14
|
webpackConfig: `${options.appProjectRoot}/webpack.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
|
|
15
15
|
};
|
|
16
16
|
projectConfig.targets.build.configurations ??= {};
|
|
17
|
-
if (!(0,
|
|
17
|
+
if (!(0, internal_1.isUsingTsSolutionSetup)(host)) {
|
|
18
18
|
projectConfig.targets.build.configurations.production = {
|
|
19
19
|
...(projectConfig.targets.build.configurations?.production ?? {}),
|
|
20
20
|
webpackConfig: `${options.appProjectRoot}/webpack.config.prod.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
|
|
@@ -62,7 +62,7 @@ function updateModuleFederationProject(host, options, isHost = false) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
// Typechecks must be performed first before build and serve to generate remote d.ts files.
|
|
65
|
-
if ((0,
|
|
65
|
+
if ((0, internal_1.isUsingTsSolutionSetup)(host)) {
|
|
66
66
|
projectConfig.targets.build ??= {};
|
|
67
67
|
projectConfig.targets.serve ??= {};
|
|
68
68
|
projectConfig.targets.build.dependsOn = ['^build', 'typecheck'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-mf-env-to-inputs.d.ts","sourceRoot":"","sources":["../../../../../packages/react/src/utils/add-mf-env-to-inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAA4B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"add-mf-env-to-inputs.d.ts","sourceRoot":"","sources":["../../../../../packages/react/src/utils/add-mf-env-to-inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAA4B,MAAM,YAAY,CAAC;AAMjE,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,QAAQ,GAAG,SAAS,QAkC9B"}
|
|
@@ -2,24 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
function addMfEnvToTargetDefaultInputs(tree, bundler) {
|
|
6
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
+
const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
|
|
7
8
|
const executor = bundler === 'rspack' ? '@nx/rspack:rspack' : '@nx/webpack:webpack';
|
|
8
9
|
const mfEnvVar = 'NX_MF_DEV_REMOTES';
|
|
9
|
-
nxJson.targetDefaults
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const existing = (0, internal_1.normalizeTargetDefaults)(nxJson.targetDefaults).find((e) => e.executor === executor &&
|
|
11
|
+
e.target === undefined &&
|
|
12
|
+
e.projects === undefined &&
|
|
13
|
+
e.plugin === undefined);
|
|
14
|
+
const inputs = [...(existing?.inputs ?? ['production', '^production'])];
|
|
13
15
|
let mfEnvVarExists = false;
|
|
14
|
-
for (const input of
|
|
16
|
+
for (const input of inputs) {
|
|
15
17
|
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
|
16
18
|
mfEnvVarExists = true;
|
|
17
19
|
break;
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
if (!mfEnvVarExists) {
|
|
21
|
-
|
|
23
|
+
inputs.push({ env: mfEnvVar });
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
(0, internal_1.upsertTargetDefault)(tree, nxJson, {
|
|
26
|
+
executor,
|
|
27
|
+
cache: true,
|
|
28
|
+
inputs,
|
|
29
|
+
dependsOn: existing?.dependsOn ?? ['^build'],
|
|
30
|
+
});
|
|
24
31
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
25
32
|
}
|