@nx/react 17.0.5 → 17.0.6
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 +4 -9
- package/generators.json +1 -1
- package/index.d.ts +0 -1
- package/index.js +1 -3
- package/migrations.json +0 -21
- package/package.json +7 -7
- package/plugins/component-testing/index.js +24 -52
- package/plugins/component-testing/webpack-fallback.js +1 -1
- package/plugins/storybook/index.js +2 -6
- package/plugins/storybook/merge-plugins.d.ts +1 -1
- package/plugins/webpack.d.ts +3 -1
- package/plugins/webpack.js +11 -3
- package/plugins/with-react.d.ts +4 -2
- package/plugins/with-react.js +58 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -13
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +58 -173
- package/src/executors/module-federation-dev-server/schema.json +1 -13
- package/src/generators/application/application.js +18 -41
- package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/base-webpack/src/index.html +2 -0
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +5 -46
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +13 -54
- package/src/generators/application/lib/add-e2e.js +7 -25
- package/src/generators/application/lib/add-jest.js +2 -2
- package/src/generators/application/lib/add-project.d.ts +2 -2
- package/src/generators/application/lib/add-project.js +15 -12
- package/src/generators/application/lib/add-routing.d.ts +1 -1
- package/src/generators/application/lib/add-routing.js +8 -4
- package/src/generators/application/lib/create-application-files.js +1 -30
- package/src/generators/application/lib/install-common-dependencies.js +1 -15
- package/src/generators/application/lib/normalize-options.js +1 -35
- package/src/generators/application/lib/set-defaults.js +0 -1
- package/src/generators/application/lib/update-jest-config.js +8 -8
- package/src/generators/application/schema.d.ts +0 -5
- package/src/generators/application/schema.json +3 -7
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +22 -39
- package/src/generators/component/lib/normalize-options.js +2 -4
- package/src/generators/component/schema.d.ts +4 -6
- package/src/generators/component/schema.json +7 -7
- package/src/generators/component-cypress-spec/schema.json +1 -1
- package/src/generators/component-story/schema.json +1 -1
- package/src/generators/component-test/schema.json +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +1 -2
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +7 -18
- package/src/generators/cypress-component-configuration/lib/add-files.js +6 -1
- package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
- package/src/generators/federate-module/federate-module.js +2 -2
- package/src/generators/federate-module/schema.d.ts +1 -1
- package/src/generators/federate-module/schema.json +3 -4
- package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -15
- package/src/generators/hook/schema.d.ts +4 -4
- package/src/generators/hook/schema.json +5 -5
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +2 -17
- package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +2 -5
- package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +2 -5
- package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +2 -17
- package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +1 -0
- package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -2
- package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/host/host.js +1 -15
- package/src/generators/host/lib/add-module-federation-files.d.ts +1 -2
- package/src/generators/host/lib/add-module-federation-files.js +11 -24
- package/src/generators/host/lib/setup-ssr-for-host.js +0 -1
- package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -7
- package/src/generators/host/schema.d.ts +2 -5
- package/src/generators/host/schema.json +6 -16
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +49 -10
- package/src/generators/init/schema.d.ts +6 -1
- package/src/generators/init/schema.json +22 -5
- package/src/generators/library/lib/add-linting.js +2 -2
- package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
- package/src/generators/library/lib/add-rollup-build-target.js +8 -16
- package/src/generators/library/lib/install-common-dependencies.js +5 -13
- package/src/generators/library/lib/maybe-js.d.ts +2 -0
- package/src/generators/library/lib/normalize-options.js +5 -34
- package/src/generators/library/lib/update-app-routes.js +1 -1
- package/src/generators/library/library.js +6 -17
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +3 -3
- package/src/generators/redux/schema.d.ts +1 -1
- package/src/generators/redux/schema.json +2 -2
- package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -4
- package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +1 -4
- package/src/generators/remote/lib/setup-ssr-for-remote.js +1 -5
- package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -2
- package/src/generators/remote/lib/update-host-with-remote.js +1 -10
- package/src/generators/remote/remote.js +2 -22
- package/src/generators/remote/schema.d.ts +2 -3
- package/src/generators/remote/schema.json +6 -17
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +7 -23
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/stories/stories.js +5 -17
- package/src/generators/storybook-configuration/configuration.d.ts +0 -2
- package/src/generators/storybook-configuration/configuration.js +15 -37
- package/src/generators/storybook-configuration/schema.d.ts +1 -2
- package/src/generators/storybook-configuration/schema.json +7 -7
- package/src/module-federation/ast-utils.js +1 -1
- package/src/module-federation/utils.js +1 -8
- package/src/module-federation/with-module-federation-ssr.js +0 -3
- package/src/module-federation/with-module-federation.d.ts +3 -3
- package/src/module-federation/with-module-federation.js +4 -14
- package/src/rules/update-module-federation-project.d.ts +0 -2
- package/src/rules/update-module-federation-project.js +3 -12
- package/src/utils/assertion.js +0 -1
- package/src/utils/ct-utils.d.ts +1 -6
- package/src/utils/ct-utils.js +9 -39
- package/src/utils/get-in-source-vitest-tests-template.js +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/typings/style.d.ts +0 -1
- package/mf/dynamic-federation.d.ts +0 -4
- package/mf/dynamic-federation.js +0 -75
- package/mf/index.d.ts +0 -1
- package/mf/index.js +0 -7
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +0 -4
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +0 -86
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +0 -8
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +0 -13
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +0 -33
- package/src/generators/application/files/style-tailwind/src/styles.css +0 -1
- package/src/generators/host/files/common/src/main.js__tmpl__ +0 -10
- package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -10
- package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
- package/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -11
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +0 -2
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +0 -26
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
- package/src/utils/add-mf-env-to-inputs.d.ts +0 -2
- package/src/utils/add-mf-env-to-inputs.js +0 -27
- package/src/utils/has-vite-plugin.d.ts +0 -2
- package/src/utils/has-vite-plugin.js +0 -11
- package/src/utils/has-webpack-plugin.d.ts +0 -2
- package/src/utils/has-webpack-plugin.js +0 -11
- package/src/utils/maybe-js.d.ts +0 -3
- /package/src/generators/host/files/common/src/app/{__fileName__.js__tmpl__ → __fileName__.tsx__tmpl__} +0 -0
- /package/src/{utils → generators/library/lib}/maybe-js.js +0 -0
- /package/src/generators/remote/files/{common/src/main.js__tmpl__ → module-federation/src/main.ts__tmpl__} +0 -0
- /package/src/generators/remote/files/{common/src/remote-entry.js__tmpl__ → module-federation/src/remote-entry.ts__tmpl__} +0 -0
- /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/main.ts__tmpl__ +0 -0
- /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/remote-entry.ts__tmpl__ +0 -0
package/src/utils/ct-utils.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isComponent = exports.
|
|
3
|
+
exports.isComponent = exports.getBundlerFromTarget = exports.addCTTargetWithBuildTarget = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
6
6
|
const ast_utils_1 = require("./ast-utils");
|
|
7
7
|
let tsModule;
|
|
8
8
|
const allowedFileExt = new RegExp(/\.[jt]sx?/);
|
|
9
9
|
const isSpecFile = new RegExp(/(spec|test)\./);
|
|
10
|
-
async function
|
|
10
|
+
async function addCTTargetWithBuildTarget(tree, options) {
|
|
11
11
|
let found = { target: options.buildTarget, config: undefined };
|
|
12
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
13
12
|
// Specifically undefined as a workaround for Remix to pass an empty string as the buildTarget
|
|
14
13
|
if (options.buildTarget === undefined) {
|
|
15
14
|
const { findBuildConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/find-target-options'));
|
|
@@ -20,37 +19,16 @@ async function configureCypressCT(tree, options) {
|
|
|
20
19
|
});
|
|
21
20
|
assertValidConfig(found?.config);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!executor || !options.validExecutorNames.has(executor)) {
|
|
29
|
-
throw new Error(`Cypress Component Testing is not currently supported for this project. Please check https://github.com/nrwl/nx/issues/21546 for more information.`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const { addDefaultCTConfig, getProjectCypressConfigPath } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
|
|
33
|
-
const ctConfigOptions = {
|
|
34
|
-
bundler: options.bundler ?? (await getActualBundler(tree, options, found)),
|
|
22
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
23
|
+
projectConfig.targets['component-test'].options = {
|
|
24
|
+
...projectConfig.targets['component-test'].options,
|
|
25
|
+
devServerTarget: found.target,
|
|
26
|
+
skipServe: true,
|
|
35
27
|
};
|
|
36
|
-
|
|
37
|
-
'@nx/cypress:cypress') {
|
|
38
|
-
projectConfig.targets['component-test'].options = {
|
|
39
|
-
...projectConfig.targets['component-test'].options,
|
|
40
|
-
devServerTarget: found.target,
|
|
41
|
-
skipServe: true,
|
|
42
|
-
};
|
|
43
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
ctConfigOptions.buildTarget = found.target;
|
|
47
|
-
}
|
|
48
|
-
const cypressConfigFilePath = getProjectCypressConfigPath(tree, projectConfig.root);
|
|
49
|
-
const updatedCyConfig = await addDefaultCTConfig(tree.read(cypressConfigFilePath, 'utf-8'), ctConfigOptions);
|
|
50
|
-
tree.write(cypressConfigFilePath, `import { nxComponentTestingPreset } from '@nx/react/plugins/component-testing';\n${updatedCyConfig}`);
|
|
28
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
51
29
|
return found;
|
|
52
30
|
}
|
|
53
|
-
exports.
|
|
31
|
+
exports.addCTTargetWithBuildTarget = addCTTargetWithBuildTarget;
|
|
54
32
|
function assertValidConfig(config) {
|
|
55
33
|
if (!config) {
|
|
56
34
|
throw new Error('Unable to find a valid build configuration. Try passing in a target for an app. --build-target=<project>:<target>[:<configuration>]');
|
|
@@ -71,14 +49,6 @@ async function getBundlerFromTarget(found, tree) {
|
|
|
71
49
|
: 'webpack';
|
|
72
50
|
}
|
|
73
51
|
exports.getBundlerFromTarget = getBundlerFromTarget;
|
|
74
|
-
async function getActualBundler(tree, options, found) {
|
|
75
|
-
// Specifically undefined to allow Remix workaround of passing an empty string
|
|
76
|
-
const actualBundler = options.buildTarget !== undefined && options.bundler
|
|
77
|
-
? options.bundler
|
|
78
|
-
: await getBundlerFromTarget(found, tree);
|
|
79
|
-
return actualBundler;
|
|
80
|
-
}
|
|
81
|
-
exports.getActualBundler = getActualBundler;
|
|
82
52
|
function isComponent(tree, filePath) {
|
|
83
53
|
if (!tsModule) {
|
|
84
54
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
@@ -8,7 +8,7 @@ if (import.meta.vitest) {
|
|
|
8
8
|
// For more information please visit the Vitest docs site here: https://vitest.dev/guide/in-source.html
|
|
9
9
|
|
|
10
10
|
const { it, expect, beforeEach } = import.meta.vitest;
|
|
11
|
-
let render:
|
|
11
|
+
let render: any;
|
|
12
12
|
|
|
13
13
|
beforeEach(async () => {
|
|
14
14
|
render = (await import('@testing-library/react')).render;
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const babelLoaderVersion = "^9.1.2";
|
|
|
8
8
|
export declare const typesReactVersion = "18.2.33";
|
|
9
9
|
export declare const typesReactDomVersion = "18.2.14";
|
|
10
10
|
export declare const typesReactIsVersion = "18.2.2";
|
|
11
|
-
export declare const typesNodeVersion = "18.
|
|
11
|
+
export declare const typesNodeVersion = "18.14.2";
|
|
12
12
|
export declare const babelPresetReactVersion = "^7.14.5";
|
|
13
13
|
export declare const babelCoreVersion = "^7.14.5";
|
|
14
14
|
export declare const styledComponentsVersion = "5.3.6";
|
package/src/utils/versions.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.babelLoaderVersion = '^9.1.2';
|
|
|
12
12
|
exports.typesReactVersion = '18.2.33';
|
|
13
13
|
exports.typesReactDomVersion = '18.2.14';
|
|
14
14
|
exports.typesReactIsVersion = '18.2.2';
|
|
15
|
-
exports.typesNodeVersion = '18.
|
|
15
|
+
exports.typesNodeVersion = '18.14.2';
|
|
16
16
|
exports.babelPresetReactVersion = '^7.14.5';
|
|
17
17
|
exports.babelCoreVersion = '^7.14.5';
|
|
18
18
|
exports.styledComponentsVersion = '5.3.6';
|
package/typings/style.d.ts
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export type ResolveRemoteUrlFunction = (remoteName: string) => string | Promise<string>;
|
|
2
|
-
export declare function setRemoteUrlResolver(_resolveRemoteUrl: ResolveRemoteUrlFunction): void;
|
|
3
|
-
export declare function setRemoteDefinitions(definitions: Record<string, string>): void;
|
|
4
|
-
export declare function loadRemoteModule(remoteName: string, moduleName: string): Promise<any>;
|
package/mf/dynamic-federation.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadRemoteModule = exports.setRemoteDefinitions = exports.setRemoteUrlResolver = void 0;
|
|
4
|
-
let remoteUrlDefinitions;
|
|
5
|
-
let resolveRemoteUrl;
|
|
6
|
-
const remoteModuleMap = new Map();
|
|
7
|
-
const remoteContainerMap = new Map();
|
|
8
|
-
let initialSharingScopeCreated = false;
|
|
9
|
-
function setRemoteUrlResolver(_resolveRemoteUrl) {
|
|
10
|
-
resolveRemoteUrl = _resolveRemoteUrl;
|
|
11
|
-
}
|
|
12
|
-
exports.setRemoteUrlResolver = setRemoteUrlResolver;
|
|
13
|
-
function setRemoteDefinitions(definitions) {
|
|
14
|
-
remoteUrlDefinitions = definitions;
|
|
15
|
-
}
|
|
16
|
-
exports.setRemoteDefinitions = setRemoteDefinitions;
|
|
17
|
-
async function loadRemoteModule(remoteName, moduleName) {
|
|
18
|
-
const remoteModuleKey = `${remoteName}:${moduleName}`;
|
|
19
|
-
if (remoteModuleMap.has(remoteModuleKey)) {
|
|
20
|
-
return remoteModuleMap.get(remoteModuleKey);
|
|
21
|
-
}
|
|
22
|
-
const container = remoteContainerMap.has(remoteName)
|
|
23
|
-
? remoteContainerMap.get(remoteName)
|
|
24
|
-
: await loadRemoteContainer(remoteName);
|
|
25
|
-
const factory = await container.get(moduleName);
|
|
26
|
-
const Module = factory();
|
|
27
|
-
remoteModuleMap.set(remoteModuleKey, Module);
|
|
28
|
-
return Module;
|
|
29
|
-
}
|
|
30
|
-
exports.loadRemoteModule = loadRemoteModule;
|
|
31
|
-
const fetchRemoteModule = (url, remoteName) => {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
const script = document.createElement('script');
|
|
34
|
-
script.src = url;
|
|
35
|
-
script.type = 'text/javascript';
|
|
36
|
-
script.async = true;
|
|
37
|
-
script.onload = () => {
|
|
38
|
-
const proxy = {
|
|
39
|
-
get: (request) => window[remoteName].get(request),
|
|
40
|
-
init: (arg) => {
|
|
41
|
-
try {
|
|
42
|
-
window[remoteName].init(arg);
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
console.error(`Failed to initialize remote ${remoteName}`, e);
|
|
46
|
-
reject(e);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
resolve(proxy);
|
|
51
|
-
};
|
|
52
|
-
script.onerror = () => reject(new Error(`Remote ${remoteName} not found`));
|
|
53
|
-
document.head.appendChild(script);
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
async function loadRemoteContainer(remoteName) {
|
|
57
|
-
if (!resolveRemoteUrl && !remoteUrlDefinitions) {
|
|
58
|
-
throw new Error('Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.');
|
|
59
|
-
}
|
|
60
|
-
if (!initialSharingScopeCreated) {
|
|
61
|
-
initialSharingScopeCreated = true;
|
|
62
|
-
await __webpack_init_sharing__('default');
|
|
63
|
-
}
|
|
64
|
-
const remoteUrl = remoteUrlDefinitions
|
|
65
|
-
? remoteUrlDefinitions[remoteName]
|
|
66
|
-
: await resolveRemoteUrl(remoteName);
|
|
67
|
-
let containerUrl = remoteUrl;
|
|
68
|
-
if (!remoteUrl.endsWith('.mjs') && !remoteUrl.endsWith('.js')) {
|
|
69
|
-
containerUrl = `${remoteUrl}${remoteUrl.endsWith('/') ? '' : '/'}remoteEntry.js`;
|
|
70
|
-
}
|
|
71
|
-
const container = await fetchRemoteModule(containerUrl, remoteName);
|
|
72
|
-
await container.init(__webpack_share_scopes__.default);
|
|
73
|
-
remoteContainerMap.set(remoteName, container);
|
|
74
|
-
return container;
|
|
75
|
-
}
|
package/mf/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { loadRemoteModule, setRemoteDefinitions, setRemoteUrlResolver, } from './dynamic-federation';
|
package/mf/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setRemoteUrlResolver = exports.setRemoteDefinitions = exports.loadRemoteModule = void 0;
|
|
4
|
-
var dynamic_federation_1 = require("./dynamic-federation");
|
|
5
|
-
Object.defineProperty(exports, "loadRemoteModule", { enumerable: true, get: function () { return dynamic_federation_1.loadRemoteModule; } });
|
|
6
|
-
Object.defineProperty(exports, "setRemoteDefinitions", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteDefinitions; } });
|
|
7
|
-
Object.defineProperty(exports, "setRemoteUrlResolver", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteUrlResolver; } });
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyReactConfig = void 0;
|
|
4
|
-
function applyReactConfig(options, config = {}) {
|
|
5
|
-
if (!process.env['NX_TASK_TARGET_PROJECT'])
|
|
6
|
-
return;
|
|
7
|
-
addHotReload(config);
|
|
8
|
-
if (options.svgr !== false) {
|
|
9
|
-
removeSvgLoaderIfPresent(config);
|
|
10
|
-
// TODO(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
|
|
11
|
-
// It should be:
|
|
12
|
-
// use: [{
|
|
13
|
-
// test: /\.svg$/i,
|
|
14
|
-
// type: 'asset',
|
|
15
|
-
// resourceQuery: /react/, // *.svg?react
|
|
16
|
-
// },
|
|
17
|
-
// {
|
|
18
|
-
// test: /\.svg$/i,
|
|
19
|
-
// issuer: /\.[jt]sx?$/,
|
|
20
|
-
// resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
|
|
21
|
-
// use: ['@svgr/webpack'],
|
|
22
|
-
// }],
|
|
23
|
-
// See:
|
|
24
|
-
// - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
|
|
25
|
-
// - Vite: https://www.npmjs.com/package/vite-plugin-svgr
|
|
26
|
-
// - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
|
|
27
|
-
// Note: We also need a migration for any projects that are using SVGR to convert
|
|
28
|
-
// `import { ReactComponent as X } from './x.svg` to
|
|
29
|
-
// `import X from './x.svg?react';
|
|
30
|
-
config.module.rules.push({
|
|
31
|
-
test: /\.svg$/,
|
|
32
|
-
issuer: /\.(js|ts|md)x?$/,
|
|
33
|
-
use: [
|
|
34
|
-
{
|
|
35
|
-
loader: require.resolve('@svgr/webpack'),
|
|
36
|
-
options: {
|
|
37
|
-
svgo: false,
|
|
38
|
-
titleProp: true,
|
|
39
|
-
ref: true,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
loader: require.resolve('file-loader'),
|
|
44
|
-
options: {
|
|
45
|
-
name: '[name].[hash].[ext]',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
// enable webpack node api
|
|
52
|
-
config.node = {
|
|
53
|
-
__dirname: true,
|
|
54
|
-
__filename: true,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
exports.applyReactConfig = applyReactConfig;
|
|
58
|
-
function addHotReload(config) {
|
|
59
|
-
if (config.mode === 'development' && config['devServer']?.hot) {
|
|
60
|
-
// add `react-refresh/babel` to babel loader plugin
|
|
61
|
-
const babelLoader = config.module.rules.find((rule) => rule &&
|
|
62
|
-
typeof rule !== 'string' &&
|
|
63
|
-
rule.loader?.toString().includes('babel-loader'));
|
|
64
|
-
if (babelLoader && typeof babelLoader !== 'string') {
|
|
65
|
-
babelLoader.options['plugins'] = [
|
|
66
|
-
...(babelLoader.options['plugins'] || []),
|
|
67
|
-
[
|
|
68
|
-
require.resolve('react-refresh/babel'),
|
|
69
|
-
{
|
|
70
|
-
skipEnvCheck: true,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
76
|
-
config.plugins.push(new ReactRefreshPlugin());
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
// We remove potentially conflicting rules that target SVGs because we use @svgr/webpack loader
|
|
80
|
-
// See https://github.com/nrwl/nx/issues/14383
|
|
81
|
-
function removeSvgLoaderIfPresent(config) {
|
|
82
|
-
const svgLoaderIdx = config.module.rules.findIndex((rule) => typeof rule === 'object' && rule.test.toString().includes('svg'));
|
|
83
|
-
if (svgLoaderIdx === -1)
|
|
84
|
-
return;
|
|
85
|
-
config.module.rules.splice(svgLoaderIdx, 1);
|
|
86
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NxReactWebpackPlugin = void 0;
|
|
4
|
-
const apply_react_config_1 = require("./lib/apply-react-config");
|
|
5
|
-
class NxReactWebpackPlugin {
|
|
6
|
-
constructor(options = {}) {
|
|
7
|
-
this.options = options;
|
|
8
|
-
}
|
|
9
|
-
apply(compiler) {
|
|
10
|
-
(0, apply_react_config_1.applyReactConfig)(this.options, compiler.options);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.NxReactWebpackPlugin = NxReactWebpackPlugin;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<% if (classComponent) { %>
|
|
2
|
-
import { Component } from 'react';
|
|
3
|
-
<% } if (!minimal) { %>
|
|
4
|
-
import NxWelcome from "./nx-welcome";
|
|
5
|
-
<% } %>
|
|
6
|
-
|
|
7
|
-
<% if (classComponent) { %>
|
|
8
|
-
export class App extends Component {
|
|
9
|
-
render() {
|
|
10
|
-
<% } else { %>
|
|
11
|
-
export function App() {
|
|
12
|
-
<% } %>
|
|
13
|
-
return (
|
|
14
|
-
<div>
|
|
15
|
-
<% if (!minimal) { %>
|
|
16
|
-
<NxWelcome title="<%= projectName %>"/>
|
|
17
|
-
<% } else { %>
|
|
18
|
-
<h1>
|
|
19
|
-
<span> Hello there, </span>
|
|
20
|
-
Welcome <%= projectName %> 👋
|
|
21
|
-
</h1>
|
|
22
|
-
<% } %>
|
|
23
|
-
</div>);
|
|
24
|
-
<% if (classComponent) { %>
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
<% } else { %>
|
|
28
|
-
}
|
|
29
|
-
<% } %>
|
|
30
|
-
|
|
31
|
-
export default App;
|
|
32
|
-
|
|
33
|
-
<% if (inSourceTests === true) { %> <%- inSourceVitestTests %> <% } %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/* You can add global styles to this file, and also import other style files */
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<% if (dynamic) { %>
|
|
2
|
-
import { setRemoteDefinitions } from '@nx/react/mf';
|
|
3
|
-
|
|
4
|
-
fetch('/assets/module-federation.manifest.json')
|
|
5
|
-
.then((res) => res.json())
|
|
6
|
-
.then(definitions => setRemoteDefinitions(definitions))
|
|
7
|
-
.then(() => import('./bootstrap').catch(err => console.error(err)));
|
|
8
|
-
<% } else { %>
|
|
9
|
-
import('./bootstrap').catch(err => console.error(err));
|
|
10
|
-
<% } %>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"types": [
|
|
6
|
-
"node",
|
|
7
|
-
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
-
"@nx/react/typings/image.d.ts"
|
|
9
|
-
]
|
|
10
|
-
},
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*.js",
|
|
13
|
-
"src/**/*.jsx",
|
|
14
|
-
"src/**/*.ts",
|
|
15
|
-
"src/**/*.tsx",
|
|
16
|
-
"webpack.config.ts",
|
|
17
|
-
"webpack.prod.config.ts"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
<% if (!minimal) { %>
|
|
3
|
-
import NxWelcome from "./nx-welcome";
|
|
4
|
-
<% } %>
|
|
5
|
-
import { Link, Route, Routes } from 'react-router-dom';
|
|
6
|
-
<% if (dynamic) { %>
|
|
7
|
-
import { loadRemoteModule } from '@nx/react/mf';
|
|
8
|
-
<% } %>
|
|
9
|
-
|
|
10
|
-
<% if (remotes.length > 0) { %>
|
|
11
|
-
<% remotes.forEach(function(r) { %>
|
|
12
|
-
<% if (dynamic) { %>
|
|
13
|
-
const <%= r.className %> = React.lazy(() => loadRemoteModule('<%= r.fileName %>', './Module'))
|
|
14
|
-
<% } else { %>
|
|
15
|
-
const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module'));
|
|
16
|
-
<% } %>
|
|
17
|
-
<% }); %>
|
|
18
|
-
<% } %>
|
|
19
|
-
|
|
20
|
-
export function App() {
|
|
21
|
-
return (
|
|
22
|
-
<React.Suspense fallback={null}>
|
|
23
|
-
<ul>
|
|
24
|
-
<li><Link to="/">Home</Link></li>
|
|
25
|
-
<% remotes.forEach(function(r) { %>
|
|
26
|
-
<li><Link to="/<%=r.fileName%>"><%=r.className%></Link></li>
|
|
27
|
-
<% }); %>
|
|
28
|
-
</ul>
|
|
29
|
-
<Routes>
|
|
30
|
-
<% if (!minimal) { %>
|
|
31
|
-
<Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
|
|
32
|
-
<% } %>
|
|
33
|
-
<% remotes.forEach(function(r) { %>
|
|
34
|
-
<Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
|
|
35
|
-
<% }); %>
|
|
36
|
-
</Routes>
|
|
37
|
-
</React.Suspense>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default App;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<% if (dynamic) { %>
|
|
2
|
-
import { setRemoteDefinitions } from '@nx/react/mf';
|
|
3
|
-
|
|
4
|
-
fetch('/assets/module-federation.manifest.json')
|
|
5
|
-
.then((res) => res.json())
|
|
6
|
-
.then(definitions => setRemoteDefinitions(definitions))
|
|
7
|
-
.then(() => import('./bootstrap').catch(err => console.error(err)));
|
|
8
|
-
<% } else { %>
|
|
9
|
-
import('./bootstrap').catch(err => console.error(err));
|
|
10
|
-
<% } %>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"types": [
|
|
6
|
-
"node",
|
|
7
|
-
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
-
"@nx/react/typings/image.d.ts"
|
|
9
|
-
]
|
|
10
|
-
},
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*.js",
|
|
13
|
-
"src/**/*.jsx",
|
|
14
|
-
"src/**/*.ts",
|
|
15
|
-
"src/**/*.tsx",
|
|
16
|
-
"webpack.config.ts",
|
|
17
|
-
"webpack.prod.config.ts"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"types": [
|
|
6
|
-
"node",
|
|
7
|
-
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
-
"@nx/react/typings/image.d.ts"
|
|
9
|
-
]
|
|
10
|
-
},
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*.js",
|
|
13
|
-
"src/**/*.jsx",
|
|
14
|
-
"src/**/*.ts",
|
|
15
|
-
"src/**/*.tsx",
|
|
16
|
-
"webpack.config.ts",
|
|
17
|
-
"webpack.prod.config.ts"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addRemoteToDynamicHost = void 0;
|
|
4
|
-
function addRemoteToDynamicHost(tree, remoteName, remotePort, pathToMfManifest) {
|
|
5
|
-
const current = tree.read(pathToMfManifest, 'utf8');
|
|
6
|
-
tree.write(pathToMfManifest, JSON.stringify({
|
|
7
|
-
...JSON.parse(current),
|
|
8
|
-
[remoteName]: `http://localhost:${remotePort}`,
|
|
9
|
-
}));
|
|
10
|
-
}
|
|
11
|
-
exports.addRemoteToDynamicHost = addRemoteToDynamicHost;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
5
|
-
async function default_1(tree) {
|
|
6
|
-
if (!hasModuleFederationProject(tree)) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
|
|
10
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
11
|
-
}
|
|
12
|
-
exports.default = default_1;
|
|
13
|
-
function hasModuleFederationProject(tree) {
|
|
14
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
15
|
-
for (const project of projects.values()) {
|
|
16
|
-
const targets = project.targets || {};
|
|
17
|
-
for (const [_, target] of Object.entries(targets)) {
|
|
18
|
-
if (target.executor === '@nx/webpack:webpack' &&
|
|
19
|
-
(tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
|
|
20
|
-
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
async function default_1(tree) {
|
|
5
|
-
if (!hasModuleFederationProject(tree)) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
ensureTargetDefaultsContainProductionInputs(tree);
|
|
9
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
}
|
|
11
|
-
exports.default = default_1;
|
|
12
|
-
function ensureTargetDefaultsContainProductionInputs(tree) {
|
|
13
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
14
|
-
const webpackExecutor = '@nx/webpack:webpack';
|
|
15
|
-
const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
|
|
16
|
-
nxJson.targetDefaults[webpackExecutor] ??= {};
|
|
17
|
-
nxJson.targetDefaults[webpackExecutor].inputs ??= [
|
|
18
|
-
'production',
|
|
19
|
-
'^production',
|
|
20
|
-
{ env: mfEnvVar },
|
|
21
|
-
];
|
|
22
|
-
if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('production')) {
|
|
23
|
-
nxJson.targetDefaults[webpackExecutor].inputs.push('production');
|
|
24
|
-
}
|
|
25
|
-
if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('^production')) {
|
|
26
|
-
nxJson.targetDefaults[webpackExecutor].inputs.push('^production');
|
|
27
|
-
}
|
|
28
|
-
let mfEnvVarExists = false;
|
|
29
|
-
for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
|
|
30
|
-
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
|
31
|
-
mfEnvVarExists = true;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (!mfEnvVarExists) {
|
|
36
|
-
nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
|
|
37
|
-
}
|
|
38
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
39
|
-
}
|
|
40
|
-
function hasModuleFederationProject(tree) {
|
|
41
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
42
|
-
for (const project of projects.values()) {
|
|
43
|
-
const targets = project.targets || {};
|
|
44
|
-
for (const [_, target] of Object.entries(targets)) {
|
|
45
|
-
if (target.executor === '@nx/webpack:webpack' &&
|
|
46
|
-
(tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
|
|
47
|
-
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addMfEnvToTargetDefaultInputs = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function addMfEnvToTargetDefaultInputs(tree) {
|
|
6
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
-
const webpackExecutor = '@nx/webpack:webpack';
|
|
8
|
-
const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
|
|
9
|
-
nxJson.targetDefaults ??= {};
|
|
10
|
-
nxJson.targetDefaults[webpackExecutor] ??= {};
|
|
11
|
-
nxJson.targetDefaults[webpackExecutor].inputs ??= [
|
|
12
|
-
'production',
|
|
13
|
-
'^production',
|
|
14
|
-
];
|
|
15
|
-
let mfEnvVarExists = false;
|
|
16
|
-
for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
|
|
17
|
-
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
|
18
|
-
mfEnvVarExists = true;
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (!mfEnvVarExists) {
|
|
23
|
-
nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
|
|
24
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasVitePlugin = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function hasVitePlugin(tree) {
|
|
6
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
-
return !!nxJson.plugins?.some((p) => typeof p === 'string'
|
|
8
|
-
? p === '@nx/vite/plugin'
|
|
9
|
-
: p.plugin === '@nx/vite/plugin');
|
|
10
|
-
}
|
|
11
|
-
exports.hasVitePlugin = hasVitePlugin;
|