@nx/react 17.0.3 → 17.0.4
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 +9 -4
- package/generators.json +1 -1
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/mf/dynamic-federation.d.ts +4 -0
- package/mf/dynamic-federation.js +75 -0
- package/mf/index.d.ts +1 -0
- package/mf/index.js +7 -0
- package/migrations.json +21 -0
- package/package.json +7 -7
- package/plugins/component-testing/index.js +52 -24
- package/plugins/component-testing/webpack-fallback.js +1 -1
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +4 -0
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +86 -0
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +8 -0
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +13 -0
- package/plugins/storybook/index.js +6 -2
- package/plugins/storybook/merge-plugins.d.ts +1 -1
- package/plugins/webpack.d.ts +1 -3
- package/plugins/webpack.js +3 -11
- package/plugins/with-react.d.ts +2 -4
- package/plugins/with-react.js +2 -58
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +12 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +149 -51
- package/src/executors/module-federation-dev-server/schema.json +9 -1
- package/src/generators/application/application.js +41 -18
- package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/src/index.html +0 -2
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +46 -5
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +54 -13
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +33 -0
- package/src/generators/application/files/style-tailwind/src/styles.css +1 -0
- package/src/generators/application/lib/add-e2e.js +25 -7
- 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 +12 -15
- package/src/generators/application/lib/add-routing.d.ts +1 -1
- package/src/generators/application/lib/add-routing.js +4 -8
- package/src/generators/application/lib/create-application-files.js +30 -1
- package/src/generators/application/lib/install-common-dependencies.js +15 -1
- package/src/generators/application/lib/normalize-options.js +35 -1
- package/src/generators/application/lib/set-defaults.js +1 -0
- package/src/generators/application/lib/update-jest-config.js +8 -8
- package/src/generators/application/schema.d.ts +5 -0
- package/src/generators/application/schema.json +7 -3
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +39 -22
- package/src/generators/component/lib/normalize-options.js +4 -2
- package/src/generators/component/schema.d.ts +6 -4
- 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 +2 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +18 -7
- package/src/generators/cypress-component-configuration/lib/add-files.js +1 -6
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- 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 +4 -3
- 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/common/src/main.js__tmpl__ +10 -0
- package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +41 -0
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +10 -0
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +17 -2
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +5 -2
- package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +5 -2
- package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +17 -2
- package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +2 -1
- package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/host/host.js +15 -1
- package/src/generators/host/lib/add-module-federation-files.d.ts +2 -1
- package/src/generators/host/lib/add-module-federation-files.js +24 -11
- package/src/generators/host/lib/setup-ssr-for-host.js +1 -0
- package/src/generators/host/lib/update-module-federation-e2e-project.js +7 -5
- package/src/generators/host/schema.d.ts +5 -2
- package/src/generators/host/schema.json +16 -6
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +10 -49
- package/src/generators/init/schema.d.ts +1 -6
- package/src/generators/init/schema.json +5 -22
- package/src/generators/library/lib/add-linting.js +2 -2
- package/src/generators/library/lib/add-rollup-build-target.d.ts +2 -1
- package/src/generators/library/lib/add-rollup-build-target.js +16 -8
- package/src/generators/library/lib/install-common-dependencies.js +13 -5
- package/src/generators/library/lib/normalize-options.js +34 -5
- package/src/generators/library/lib/update-app-routes.js +1 -1
- package/src/generators/library/library.js +17 -6
- package/src/generators/library/schema.d.ts +1 -0
- 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__ +4 -1
- 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-ssr-ts/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +4 -1
- package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +2 -0
- package/src/generators/remote/lib/add-remote-to-dynamic-host.js +11 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js +5 -1
- package/src/generators/remote/lib/setup-tspath-for-remote.js +2 -1
- package/src/generators/remote/lib/update-host-with-remote.js +10 -1
- package/src/generators/remote/remote.js +22 -2
- package/src/generators/remote/schema.d.ts +3 -2
- package/src/generators/remote/schema.json +17 -6
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +23 -7
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/stories/stories.js +17 -5
- package/src/generators/storybook-configuration/configuration.d.ts +2 -0
- package/src/generators/storybook-configuration/configuration.js +37 -15
- package/src/generators/storybook-configuration/schema.d.ts +2 -1
- package/src/generators/storybook-configuration/schema.json +7 -7
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +26 -0
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +2 -0
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
- package/src/module-federation/ast-utils.js +1 -1
- package/src/module-federation/utils.js +8 -1
- package/src/module-federation/with-module-federation-ssr.js +3 -0
- package/src/module-federation/with-module-federation.d.ts +3 -3
- package/src/module-federation/with-module-federation.js +14 -4
- package/src/rules/update-module-federation-project.d.ts +2 -0
- package/src/rules/update-module-federation-project.js +12 -3
- package/src/utils/add-mf-env-to-inputs.d.ts +2 -0
- package/src/utils/add-mf-env-to-inputs.js +27 -0
- package/src/utils/assertion.js +1 -0
- package/src/utils/ct-utils.d.ts +6 -1
- package/src/utils/ct-utils.js +39 -9
- package/src/utils/get-in-source-vitest-tests-template.js +1 -1
- package/src/utils/has-vite-plugin.d.ts +2 -0
- package/src/utils/has-vite-plugin.js +11 -0
- package/src/utils/has-webpack-plugin.d.ts +2 -0
- package/src/utils/has-webpack-plugin.js +11 -0
- package/src/utils/maybe-js.d.ts +3 -0
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/typings/style.d.ts +1 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +0 -3
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +0 -6
- package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +0 -1
- package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +0 -1
- package/src/generators/library/lib/maybe-js.d.ts +0 -2
- /package/src/generators/host/files/common/src/app/{__fileName__.tsx__tmpl__ → __fileName__.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{module-federation/src/main.ts__tmpl__ → common/src/main.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{module-federation/src/remote-entry.ts__tmpl__ → common/src/remote-entry.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{module-federation-ts → common-ts}/src/main.ts__tmpl__ +0 -0
- /package/src/generators/remote/files/{module-federation-ts → common-ts}/src/remote-entry.ts__tmpl__ +0 -0
- /package/src/{generators/library/lib → utils}/maybe-js.js +0 -0
|
@@ -5,9 +5,16 @@ const module_federation_1 = require("@nx/webpack/src/utils/module-federation");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
7
7
|
function getFunctionDeterminateRemoteUrl(isServer = false) {
|
|
8
|
-
const target =
|
|
8
|
+
const target = 'serve';
|
|
9
9
|
const remoteEntry = isServer ? 'server/remoteEntry.js' : 'remoteEntry.js';
|
|
10
10
|
return function (remote) {
|
|
11
|
+
const mappedStaticRemotesFromEnv = process.env
|
|
12
|
+
.NX_MF_DEV_SERVER_STATIC_REMOTES
|
|
13
|
+
? JSON.parse(process.env.NX_MF_DEV_SERVER_STATIC_REMOTES)
|
|
14
|
+
: undefined;
|
|
15
|
+
if (mappedStaticRemotesFromEnv && mappedStaticRemotesFromEnv[remote]) {
|
|
16
|
+
return `${mappedStaticRemotesFromEnv[remote]}/${remoteEntry}`;
|
|
17
|
+
}
|
|
11
18
|
let remoteConfiguration = null;
|
|
12
19
|
try {
|
|
13
20
|
remoteConfiguration = (0, project_graph_1.readCachedProjectConfiguration)(remote);
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withModuleFederationForSSR = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
async function withModuleFederationForSSR(options) {
|
|
6
|
+
if (global.NX_GRAPH_CREATION) {
|
|
7
|
+
return (config) => config;
|
|
8
|
+
}
|
|
6
9
|
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options, {
|
|
7
10
|
isServer: true,
|
|
8
11
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModuleFederationConfig } from '@nx/webpack/src/utils/module-federation';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AsyncNxComposableWebpackPlugin } from '@nx/webpack';
|
|
3
3
|
/**
|
|
4
4
|
* @param {ModuleFederationConfig} options
|
|
5
|
-
* @return {Promise<
|
|
5
|
+
* @return {Promise<AsyncNxComposableWebpackPlugin>}
|
|
6
6
|
*/
|
|
7
|
-
export declare function withModuleFederation(options: ModuleFederationConfig): Promise<
|
|
7
|
+
export declare function withModuleFederation(options: ModuleFederationConfig): Promise<AsyncNxComposableWebpackPlugin>;
|
|
@@ -3,24 +3,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withModuleFederation = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
|
|
6
|
+
const isVarOrWindow = (libType) => libType === 'var' || libType === 'window';
|
|
6
7
|
/**
|
|
7
8
|
* @param {ModuleFederationConfig} options
|
|
8
|
-
* @return {Promise<
|
|
9
|
+
* @return {Promise<AsyncNxComposableWebpackPlugin>}
|
|
9
10
|
*/
|
|
10
11
|
async function withModuleFederation(options) {
|
|
12
|
+
if (global.NX_GRAPH_CREATION) {
|
|
13
|
+
return (config) => config;
|
|
14
|
+
}
|
|
11
15
|
const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
|
|
16
|
+
const isGlobal = isVarOrWindow(options.library?.type);
|
|
12
17
|
return (config, ctx) => {
|
|
13
18
|
config.output.uniqueName = options.name;
|
|
14
19
|
config.output.publicPath = 'auto';
|
|
15
|
-
if (
|
|
20
|
+
if (isGlobal) {
|
|
16
21
|
config.output.scriptType = 'text/javascript';
|
|
17
22
|
}
|
|
18
23
|
config.optimization = {
|
|
19
24
|
runtimeChunk: false,
|
|
20
25
|
};
|
|
26
|
+
if (config.mode === 'development' &&
|
|
27
|
+
Object.keys(mappedRemotes).length > 1 &&
|
|
28
|
+
!options.exposes) {
|
|
29
|
+
config.optimization.runtimeChunk = 'single';
|
|
30
|
+
}
|
|
21
31
|
config.experiments = {
|
|
22
32
|
...config.experiments,
|
|
23
|
-
outputModule: !
|
|
33
|
+
outputModule: !isGlobal,
|
|
24
34
|
};
|
|
25
35
|
config.plugins.push(new ModuleFederationPlugin({
|
|
26
36
|
name: options.name,
|
|
@@ -37,7 +47,7 @@ async function withModuleFederation(options) {
|
|
|
37
47
|
* { appX: 'appX@http://localhost:3001/remoteEntry.js' }
|
|
38
48
|
* { appY: 'appY@http://localhost:3002/remoteEntry.js' }
|
|
39
49
|
*/
|
|
40
|
-
...(
|
|
50
|
+
...(isGlobal ? { remoteType: 'script' } : {}),
|
|
41
51
|
}), sharedLibraries.getReplacementPlugin());
|
|
42
52
|
return config;
|
|
43
53
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
export declare function updateModuleFederationProject(host: Tree, options: {
|
|
3
|
+
js?: boolean;
|
|
3
4
|
projectName: string;
|
|
4
5
|
appProjectRoot: string;
|
|
5
6
|
devServerPort?: number;
|
|
6
7
|
typescriptConfiguration?: boolean;
|
|
8
|
+
dynamic?: boolean;
|
|
7
9
|
}): GeneratorCallback;
|
|
@@ -3,17 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateModuleFederationProject = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../utils/versions");
|
|
6
|
+
const maybe_js_1 = require("../utils/maybe-js");
|
|
6
7
|
function updateModuleFederationProject(host, options) {
|
|
7
8
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
8
9
|
projectConfig.targets.build.options = {
|
|
9
10
|
...projectConfig.targets.build.options,
|
|
10
|
-
main: `${options.appProjectRoot}/src/main.ts
|
|
11
|
-
webpackConfig: `${options.appProjectRoot}/webpack.config.${options.typescriptConfiguration ? 'ts' : 'js'}`,
|
|
11
|
+
main: (0, maybe_js_1.maybeJs)(options, `${options.appProjectRoot}/src/main.ts`),
|
|
12
|
+
webpackConfig: `${options.appProjectRoot}/webpack.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
|
|
12
13
|
};
|
|
13
14
|
projectConfig.targets.build.configurations.production = {
|
|
14
15
|
...projectConfig.targets.build.configurations.production,
|
|
15
|
-
webpackConfig: `${options.appProjectRoot}/webpack.config.prod.${options.typescriptConfiguration ? 'ts' : 'js'}`,
|
|
16
|
+
webpackConfig: `${options.appProjectRoot}/webpack.config.prod.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
|
|
16
17
|
};
|
|
18
|
+
// If host should be configured to use dynamic federation
|
|
19
|
+
if (options.dynamic) {
|
|
20
|
+
const pathToProdWebpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.prod.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`);
|
|
21
|
+
if (host.exists(pathToProdWebpackConfig)) {
|
|
22
|
+
host.delete(pathToProdWebpackConfig);
|
|
23
|
+
}
|
|
24
|
+
delete projectConfig.targets.build.configurations.production?.webpackConfig;
|
|
25
|
+
}
|
|
17
26
|
projectConfig.targets.serve.executor =
|
|
18
27
|
'@nx/react:module-federation-dev-server';
|
|
19
28
|
projectConfig.targets.serve.options.port = options.devServerPort;
|
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
package/src/utils/assertion.js
CHANGED
package/src/utils/ct-utils.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { type FoundTarget } from '@nx/cypress/src/utils/find-target-options';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function configureCypressCT(tree: Tree, options: {
|
|
4
4
|
project: string;
|
|
5
5
|
buildTarget: string;
|
|
6
|
+
bundler: 'vite' | 'webpack';
|
|
6
7
|
validExecutorNames: Set<string>;
|
|
7
8
|
}): Promise<FoundTarget>;
|
|
8
9
|
export declare function getBundlerFromTarget(found: FoundTarget, tree: Tree): Promise<'vite' | 'webpack'>;
|
|
10
|
+
export declare function getActualBundler(tree: Tree, options: {
|
|
11
|
+
buildTarget?: string;
|
|
12
|
+
bundler?: 'vite' | 'webpack';
|
|
13
|
+
}, found: FoundTarget): Promise<"vite" | "webpack">;
|
|
9
14
|
export declare function isComponent(tree: Tree, filePath: string): boolean;
|
package/src/utils/ct-utils.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isComponent = exports.getBundlerFromTarget = exports.
|
|
3
|
+
exports.isComponent = exports.getActualBundler = exports.getBundlerFromTarget = exports.configureCypressCT = 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 configureCypressCT(tree, options) {
|
|
11
11
|
let found = { target: options.buildTarget, config: undefined };
|
|
12
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
12
13
|
// Specifically undefined as a workaround for Remix to pass an empty string as the buildTarget
|
|
13
14
|
if (options.buildTarget === undefined) {
|
|
14
15
|
const { findBuildConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/find-target-options'));
|
|
@@ -19,16 +20,37 @@ async function addCTTargetWithBuildTarget(tree, options) {
|
|
|
19
20
|
});
|
|
20
21
|
assertValidConfig(found?.config);
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
else if (options.buildTarget) {
|
|
24
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
25
|
+
const { project, target } = (0, devkit_1.parseTargetString)(options.buildTarget, projectGraph);
|
|
26
|
+
const buildTargetProject = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
27
|
+
const executor = buildTargetProject.targets?.[target]?.executor;
|
|
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)),
|
|
27
35
|
};
|
|
28
|
-
|
|
36
|
+
if (projectConfig.targets?.['component-test']?.executor ===
|
|
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}`);
|
|
29
51
|
return found;
|
|
30
52
|
}
|
|
31
|
-
exports.
|
|
53
|
+
exports.configureCypressCT = configureCypressCT;
|
|
32
54
|
function assertValidConfig(config) {
|
|
33
55
|
if (!config) {
|
|
34
56
|
throw new Error('Unable to find a valid build configuration. Try passing in a target for an app. --build-target=<project>:<target>[:<configuration>]');
|
|
@@ -49,6 +71,14 @@ async function getBundlerFromTarget(found, tree) {
|
|
|
49
71
|
: 'webpack';
|
|
50
72
|
}
|
|
51
73
|
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;
|
|
52
82
|
function isComponent(tree, filePath) {
|
|
53
83
|
if (!tsModule) {
|
|
54
84
|
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: typeof import('@testing-library/react').render;
|
|
12
12
|
|
|
13
13
|
beforeEach(async () => {
|
|
14
14
|
render = (await import('@testing-library/react')).render;
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasWebpackPlugin = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function hasWebpackPlugin(tree) {
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
+
return !!nxJson.plugins?.some((p) => typeof p === 'string'
|
|
8
|
+
? p === '@nx/webpack/plugin'
|
|
9
|
+
: p.plugin === '@nx/webpack/plugin');
|
|
10
|
+
}
|
|
11
|
+
exports.hasWebpackPlugin = hasWebpackPlugin;
|
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.16.9";
|
|
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.16.9';
|
|
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 +0,0 @@
|
|
|
1
|
-
import('./bootstrap');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import('./bootstrap');
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/generators/remote/files/{module-federation-ts → common-ts}/src/remote-entry.ts__tmpl__
RENAMED
|
File without changes
|
|
File without changes
|