@nx/angular 24.0.0-beta.2 → 24.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/executors.d.ts +0 -2
- package/dist/executors.js +0 -2
- package/dist/generators.d.ts +0 -4
- package/dist/generators.js +0 -4
- package/dist/src/generators/add-linting/add-linting.js +0 -2
- package/dist/src/generators/add-linting/schema.d.ts +0 -1
- package/dist/src/generators/application/application.js +1 -2
- package/dist/src/generators/application/lib/add-e2e.js +0 -6
- package/dist/src/generators/application/lib/add-linting.js +0 -1
- package/dist/src/generators/application/lib/add-unit-test-runner.js +0 -2
- package/dist/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/dist/src/generators/application/lib/normalize-options.js +1 -8
- package/dist/src/generators/application/schema.d.ts +0 -1
- package/dist/src/generators/application/schema.json +1 -1
- package/dist/src/generators/convert-to-rspack/convert-to-rspack.js +3 -4
- package/dist/src/generators/convert-to-rspack/lib/get-custom-webpack-config.d.ts +1 -2
- package/dist/src/generators/convert-to-rspack/lib/get-custom-webpack-config.js +0 -63
- package/dist/src/generators/convert-to-rspack/lib/validate-no-module-federation.d.ts +2 -0
- package/dist/src/generators/convert-to-rspack/lib/validate-no-module-federation.js +32 -0
- package/dist/src/generators/cypress-component-configuration/cypress-component-configuration.js +3 -15
- package/dist/src/generators/init/init.js +1 -2
- package/dist/src/generators/init/schema.d.ts +0 -2
- package/dist/src/generators/library/schema.d.ts +0 -1
- package/dist/src/generators/ng-add/migrators/builders/angular-eslint-lint.migrator.js +12 -1
- package/dist/src/generators/ng-add/migrators/projects/e2e.migrator.js +12 -16
- package/dist/src/generators/ng-add/utilities/workspace.js +1 -3
- package/dist/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +0 -2
- package/dist/src/generators/utils/add-jest.d.ts +0 -1
- package/dist/src/generators/utils/add-jest.js +0 -2
- package/dist/src/generators/utils/add-vitest.d.ts +0 -1
- package/dist/src/generators/utils/add-vitest.js +0 -1
- package/dist/src/generators/utils/testing.d.ts +0 -4
- package/dist/src/generators/utils/testing.js +0 -12
- package/dist/src/utils/backward-compatible-versions.js +0 -8
- package/dist/src/utils/versions.d.ts +0 -4
- package/dist/src/utils/versions.js +1 -5
- package/executors.json +0 -10
- package/generators.json +0 -35
- package/package.json +11 -20
- package/dist/.npmignore +0 -2
- package/dist/fesm2022/nx-angular-mf.mjs +0 -193
- package/dist/fesm2022/nx-angular-mf.mjs.map +0 -1
- package/dist/mf/package.json +0 -4
- package/dist/src/builders/utilities/module-federation.d.ts +0 -11
- package/dist/src/builders/utilities/module-federation.js +0 -109
- package/dist/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
- package/dist/src/executors/module-federation-dev-server/lib/index.js +0 -5
- package/dist/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +0 -2
- package/dist/src/executors/module-federation-dev-server/lib/normalize-options.js +0 -22
- package/dist/src/executors/module-federation-dev-server/lib/start-dev-remotes.d.ts +0 -5
- package/dist/src/executors/module-federation-dev-server/lib/start-dev-remotes.js +0 -29
- package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -4
- package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -111
- package/dist/src/executors/module-federation-dev-server/schema.d.ts +0 -38
- package/dist/src/executors/module-federation-dev-server/schema.json +0 -171
- package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +0 -2
- package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +0 -20
- package/dist/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.d.ts +0 -5
- package/dist/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.js +0 -30
- package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +0 -4
- package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -110
- package/dist/src/executors/module-federation-ssr-dev-server/schema.d.ts +0 -17
- package/dist/src/executors/module-federation-ssr-dev-server/schema.json +0 -124
- package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.d.ts +0 -4
- package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.js +0 -36
- package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.test-data.d.ts +0 -5
- package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.test-data.js +0 -448
- package/dist/src/generators/convert-to-with-mf/lib/check-name-matches.d.ts +0 -2
- package/dist/src/generators/convert-to-with-mf/lib/check-name-matches.js +0 -22
- package/dist/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.d.ts +0 -2
- package/dist/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.js +0 -45
- package/dist/src/generators/convert-to-with-mf/lib/get-webpack-config-path.d.ts +0 -2
- package/dist/src/generators/convert-to-with-mf/lib/get-webpack-config-path.js +0 -18
- package/dist/src/generators/convert-to-with-mf/lib/index.d.ts +0 -6
- package/dist/src/generators/convert-to-with-mf/lib/index.js +0 -9
- package/dist/src/generators/convert-to-with-mf/lib/is-host-remote-config.d.ts +0 -5
- package/dist/src/generators/convert-to-with-mf/lib/is-host-remote-config.js +0 -57
- package/dist/src/generators/convert-to-with-mf/lib/parse-ast-webpack-config.d.ts +0 -2
- package/dist/src/generators/convert-to-with-mf/lib/parse-ast-webpack-config.js +0 -13
- package/dist/src/generators/convert-to-with-mf/lib/write-new-webpack-config.d.ts +0 -3
- package/dist/src/generators/convert-to-with-mf/lib/write-new-webpack-config.js +0 -50
- package/dist/src/generators/convert-to-with-mf/schema.d.ts +0 -4
- package/dist/src/generators/convert-to-with-mf/schema.json +0 -33
- package/dist/src/generators/federate-module/federate-module.d.ts +0 -4
- package/dist/src/generators/federate-module/federate-module.js +0 -49
- package/dist/src/generators/federate-module/lib/add-file-to-remote-tsconfig.d.ts +0 -2
- package/dist/src/generators/federate-module/lib/add-file-to-remote-tsconfig.js +0 -14
- package/dist/src/generators/federate-module/lib/add-path-to-exposes.d.ts +0 -8
- package/dist/src/generators/federate-module/lib/add-path-to-exposes.js +0 -77
- package/dist/src/generators/federate-module/lib/add-path-to-ts-config.d.ts +0 -8
- package/dist/src/generators/federate-module/lib/add-path-to-ts-config.js +0 -11
- package/dist/src/generators/federate-module/lib/add-remote.d.ts +0 -7
- package/dist/src/generators/federate-module/lib/add-remote.js +0 -42
- package/dist/src/generators/federate-module/lib/check-remote-exists.d.ts +0 -2
- package/dist/src/generators/federate-module/lib/check-remote-exists.js +0 -21
- package/dist/src/generators/federate-module/lib/index.d.ts +0 -4
- package/dist/src/generators/federate-module/lib/index.js +0 -7
- package/dist/src/generators/federate-module/schema.d.ts +0 -13
- package/dist/src/generators/federate-module/schema.json +0 -83
- package/dist/src/generators/host/files/common/src/main.server.ts__tmpl__ +0 -78
- package/dist/src/generators/host/files/js/webpack.server.config.js__tmpl__ +0 -8
- package/dist/src/generators/host/files/ts/webpack.server.config.ts__tmpl__ +0 -9
- package/dist/src/generators/host/host.d.ts +0 -4
- package/dist/src/generators/host/host.js +0 -133
- package/dist/src/generators/host/lib/index.d.ts +0 -2
- package/dist/src/generators/host/lib/index.js +0 -5
- package/dist/src/generators/host/lib/update-ssr-setup.d.ts +0 -3
- package/dist/src/generators/host/lib/update-ssr-setup.js +0 -54
- package/dist/src/generators/host/lib/validate-options.d.ts +0 -3
- package/dist/src/generators/host/lib/validate-options.js +0 -12
- package/dist/src/generators/host/schema.d.ts +0 -36
- package/dist/src/generators/host/schema.json +0 -195
- package/dist/src/generators/remote/files/base/webpack.server.config.js__tmpl__ +0 -9
- package/dist/src/generators/remote/files/base-ts/webpack.server.config.ts__tmpl__ +0 -9
- package/dist/src/generators/remote/files/common/src/main.server.ts__tmpl__ +0 -84
- package/dist/src/generators/remote/files/standalone/src/bootstrap.server.ts__tmpl__ +0 -12
- package/dist/src/generators/remote/lib/find-next-available-port.d.ts +0 -2
- package/dist/src/generators/remote/lib/find-next-available-port.js +0 -16
- package/dist/src/generators/remote/lib/index.d.ts +0 -3
- package/dist/src/generators/remote/lib/index.js +0 -6
- package/dist/src/generators/remote/lib/update-ssr-setup.d.ts +0 -9
- package/dist/src/generators/remote/lib/update-ssr-setup.js +0 -82
- package/dist/src/generators/remote/lib/validate-options.d.ts +0 -3
- package/dist/src/generators/remote/lib/validate-options.js +0 -12
- package/dist/src/generators/remote/remote.d.ts +0 -4
- package/dist/src/generators/remote/remote.js +0 -114
- package/dist/src/generators/remote/schema.d.ts +0 -34
- package/dist/src/generators/remote/schema.json +0 -184
- package/dist/src/generators/setup-mf/files/entry-module-files/__entryModuleFileName__.ts__tmpl__ +0 -18
- package/dist/src/generators/setup-mf/files/entry-module-files/entry.routes.ts__tmpl__ +0 -4
- package/dist/src/generators/setup-mf/files/entry-module-files/entry__componentFileSuffix__.ts__tmpl__ +0 -10
- package/dist/src/generators/setup-mf/files/host-files/__appFileName__.spec.ts__tmpl__ +0 -42
- package/dist/src/generators/setup-mf/files/standalone-entry-component-files/entry.routes.ts__tmpl__ +0 -4
- package/dist/src/generators/setup-mf/files/standalone-entry-component-files/entry__componentFileSuffix__.ts__tmpl__ +0 -11
- package/dist/src/generators/setup-mf/files/ts-webpack/module-federation.config.ts__tmpl__ +0 -27
- package/dist/src/generators/setup-mf/files/ts-webpack/tsconfig.lint.json__tmpl__ +0 -12
- package/dist/src/generators/setup-mf/files/ts-webpack/webpack.config.ts__tmpl__ +0 -9
- package/dist/src/generators/setup-mf/files/ts-webpack/webpack.prod.config.ts__tmpl__ +0 -21
- package/dist/src/generators/setup-mf/files/webpack/module-federation.config.js__tmpl__ +0 -23
- package/dist/src/generators/setup-mf/files/webpack/webpack.config.js__tmpl__ +0 -9
- package/dist/src/generators/setup-mf/files/webpack/webpack.prod.config.js__tmpl__ +0 -21
- package/dist/src/generators/setup-mf/lib/add-cypress-workaround.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/add-cypress-workaround.js +0 -52
- package/dist/src/generators/setup-mf/lib/add-remote-entry.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/add-remote-entry.js +0 -27
- package/dist/src/generators/setup-mf/lib/add-remote-to-host.d.ts +0 -9
- package/dist/src/generators/setup-mf/lib/add-remote-to-host.js +0 -127
- package/dist/src/generators/setup-mf/lib/change-build-target.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/change-build-target.js +0 -24
- package/dist/src/generators/setup-mf/lib/fix-bootstrap.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/fix-bootstrap.js +0 -40
- package/dist/src/generators/setup-mf/lib/generate-config.d.ts +0 -6
- package/dist/src/generators/setup-mf/lib/generate-config.js +0 -32
- package/dist/src/generators/setup-mf/lib/get-remotes-with-ports.d.ts +0 -6
- package/dist/src/generators/setup-mf/lib/get-remotes-with-ports.js +0 -20
- package/dist/src/generators/setup-mf/lib/index.d.ts +0 -15
- package/dist/src/generators/setup-mf/lib/index.js +0 -18
- package/dist/src/generators/setup-mf/lib/move-angular-plugin-to-dependencies.d.ts +0 -2
- package/dist/src/generators/setup-mf/lib/move-angular-plugin-to-dependencies.js +0 -15
- package/dist/src/generators/setup-mf/lib/normalize-options.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/normalize-options.js +0 -26
- package/dist/src/generators/setup-mf/lib/remove-dead-code-from-remote.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/remove-dead-code-from-remote.js +0 -61
- package/dist/src/generators/setup-mf/lib/setup-host-if-dynamic.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/setup-host-if-dynamic.js +0 -20
- package/dist/src/generators/setup-mf/lib/setup-serve-target.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/setup-serve-target.js +0 -39
- package/dist/src/generators/setup-mf/lib/setup-tspath-for-remote.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/setup-tspath-for-remote.js +0 -15
- package/dist/src/generators/setup-mf/lib/update-host-app-routes.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/update-host-app-routes.js +0 -39
- package/dist/src/generators/setup-mf/lib/update-tsconfig.d.ts +0 -3
- package/dist/src/generators/setup-mf/lib/update-tsconfig.js +0 -18
- package/dist/src/generators/setup-mf/schema.d.ts +0 -35
- package/dist/src/generators/setup-mf/schema.json +0 -99
- package/dist/src/generators/setup-mf/setup-mf.d.ts +0 -4
- package/dist/src/generators/setup-mf/setup-mf.js +0 -90
- package/dist/src/generators/utils/add-mf-env-to-inputs.d.ts +0 -2
- package/dist/src/generators/utils/add-mf-env-to-inputs.js +0 -36
- package/dist/src/generators/utils/assert-mf-utils.d.ts +0 -1
- package/dist/src/generators/utils/assert-mf-utils.js +0 -8
- package/dist/src/utils/get-mf-projects.d.ts +0 -4
- package/dist/src/utils/get-mf-projects.js +0 -31
- package/dist/src/utils/module-federation-deprecation.d.ts +0 -4
- package/dist/src/utils/module-federation-deprecation.js +0 -29
- package/dist/types/nx-angular-mf.d.ts +0 -72
- package/dist/types/nx-angular-mf.d.ts.map +0 -1
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { withModuleFederation } from '@nx/module-federation/angular';
|
|
2
|
-
import config from './module-federation.config';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
6
|
-
* The DTS Plugin can be enabled by setting dts: true
|
|
7
|
-
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
8
|
-
*/
|
|
9
|
-
export default withModuleFederation({
|
|
10
|
-
...config,
|
|
11
|
-
/*
|
|
12
|
-
* Remote overrides for production.
|
|
13
|
-
* Each entry is a pair of a unique name and the URL where it is deployed.
|
|
14
|
-
*
|
|
15
|
-
* e.g.
|
|
16
|
-
* remotes: [
|
|
17
|
-
* ['app1', 'https://app1.example.com'],
|
|
18
|
-
* ['app2', 'https://app2.example.com'],
|
|
19
|
-
* ]
|
|
20
|
-
*/
|
|
21
|
-
}, { dts: false });
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
|
|
3
|
-
**/
|
|
4
|
-
module.exports = {
|
|
5
|
-
name: '<%= name %>',<% if(type === 'host') { %>
|
|
6
|
-
/**
|
|
7
|
-
* To use a remote that does not exist in your current Nx Workspace
|
|
8
|
-
* You can use the tuple-syntax to define your remote
|
|
9
|
-
*
|
|
10
|
-
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
|
|
11
|
-
*
|
|
12
|
-
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
|
|
13
|
-
* following content:
|
|
14
|
-
*
|
|
15
|
-
* declare module 'my-external-remote';
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
remotes: [<% if (federationType === 'static') { remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); } %>]<% } %><% if(type === 'remote') { %>
|
|
19
|
-
exposes: {<% if(standalone) { %>
|
|
20
|
-
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
|
21
|
-
'./Module': '<%= projectRoot %>/src/app/remote-entry/<%= entryModuleFileName %>.ts',<% } %>
|
|
22
|
-
},<% } %>
|
|
23
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const { withModuleFederation } = require('@nx/module-federation/angular');
|
|
2
|
-
const config = require('./module-federation.config');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
6
|
-
* The DTS Plugin can be enabled by setting dts: true
|
|
7
|
-
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
8
|
-
*/
|
|
9
|
-
module.exports = withModuleFederation(config, { dts: false });
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { withModuleFederation } = require('@nx/module-federation/angular');
|
|
2
|
-
const config = require('./module-federation.config');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
6
|
-
* The DTS Plugin can be enabled by setting dts: true
|
|
7
|
-
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
8
|
-
*/
|
|
9
|
-
module.exports = withModuleFederation({
|
|
10
|
-
...config,
|
|
11
|
-
/*
|
|
12
|
-
* Remote overrides for production.
|
|
13
|
-
* Each entry is a pair of a unique name and the URL where it is deployed.
|
|
14
|
-
*
|
|
15
|
-
* e.g.
|
|
16
|
-
* remotes: [
|
|
17
|
-
* ['app1', 'https://app1.example.com'],
|
|
18
|
-
* ['app2', 'https://app2.example.com'],
|
|
19
|
-
* ]
|
|
20
|
-
*/
|
|
21
|
-
}, { dts: false });
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This is a temporary workaround to prevent cypress erroring
|
|
3
|
-
// as Angular attempt to figure out how to fix HMR when styles.js
|
|
4
|
-
// is attached to the index.html with type=module
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.addCypressOnErrorWorkaround = addCypressOnErrorWorkaround;
|
|
7
|
-
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const internal_1 = require("@nx/js/internal");
|
|
9
|
-
function addCypressOnErrorWorkaround(tree, schema) {
|
|
10
|
-
if (!schema.e2eProjectName) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const e2eProjectName = schema.e2eProjectName;
|
|
14
|
-
let e2eProject;
|
|
15
|
-
try {
|
|
16
|
-
e2eProject = (0, devkit_1.readProjectConfiguration)(tree, e2eProjectName);
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
devkit_1.logger.warn((0, devkit_1.stripIndents) `Could not find an associated e2e project for ${schema.appName} with name ${e2eProjectName}.
|
|
20
|
-
If there is an associated e2e project for this application, and it uses Cypress, you will need to add a workaround to allow Cypress to test correctly.
|
|
21
|
-
An error will be thrown in the console when you serve the application, coming from styles.js. It is an error that can be safely ignored and will not reach production due to how production builds of Angular are created.
|
|
22
|
-
You can find how to implement that workaround here: https://docs.cypress.io/api/events/catalog-of-events#Uncaught-Exceptions
|
|
23
|
-
`);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (e2eProject.targets?.e2e?.executor !== '@nx/cypress:cypress') {
|
|
27
|
-
try {
|
|
28
|
-
// don't ensure package is installed, if it's not installed, we don't need to add the workaround
|
|
29
|
-
const { CYPRESS_CONFIG_FILE_NAME_PATTERN, } = require('@nx/cypress/internal');
|
|
30
|
-
if (!(0, devkit_1.glob)(tree, [`${e2eProject.root}/${CYPRESS_CONFIG_FILE_NAME_PATTERN}`])
|
|
31
|
-
.length) {
|
|
32
|
-
// Not a cypress e2e project, skip
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
// assume cypress is not installed
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const commandToAdd = `Cypress.on('uncaught:exception', err => {
|
|
42
|
-
if (err.message.includes(\`Cannot use 'import.meta' outside a module\`)) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
});`;
|
|
47
|
-
const pathToCommandsFile = (0, devkit_1.joinPathFragments)((0, internal_1.getProjectSourceRoot)(e2eProject, tree), 'support/e2e.ts');
|
|
48
|
-
const commandsContent = tree.exists(pathToCommandsFile)
|
|
49
|
-
? tree.read(pathToCommandsFile, 'utf-8')
|
|
50
|
-
: '';
|
|
51
|
-
tree.write(pathToCommandsFile, `${commandsContent}\n${commandToAdd}`);
|
|
52
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addRemoteEntry = addRemoteEntry;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const route_utils_1 = require("../../../utils/nx-devkit/route-utils");
|
|
6
|
-
function addRemoteEntry(tree, options, appRoot) {
|
|
7
|
-
const { appName, routing, prefix, standalone, componentType, componentFileSuffix, nxWelcomeComponentInfo, entryModuleFileName, } = options;
|
|
8
|
-
(0, devkit_1.generateFiles)(tree, standalone
|
|
9
|
-
? (0, devkit_1.joinPathFragments)(__dirname, '../files/standalone-entry-component-files')
|
|
10
|
-
: (0, devkit_1.joinPathFragments)(__dirname, '../files/entry-module-files'), `${appRoot}/src/app/remote-entry`, {
|
|
11
|
-
tmpl: '',
|
|
12
|
-
appName,
|
|
13
|
-
routing,
|
|
14
|
-
prefix,
|
|
15
|
-
componentType,
|
|
16
|
-
componentFileSuffix,
|
|
17
|
-
entryModuleFileName,
|
|
18
|
-
nxWelcomeFileName: nxWelcomeComponentInfo.extensionlessFileName,
|
|
19
|
-
nxWelcomeSymbolName: nxWelcomeComponentInfo.symbolName,
|
|
20
|
-
});
|
|
21
|
-
if (standalone && routing) {
|
|
22
|
-
(0, route_utils_1.addRoute)(tree, (0, devkit_1.joinPathFragments)(appRoot, 'src/app/app.routes.ts'), `{path: '', loadChildren: () => import('./remote-entry/entry.routes').then(m => m.remoteRoutes)}`);
|
|
23
|
-
}
|
|
24
|
-
else if (routing) {
|
|
25
|
-
(0, route_utils_1.addRoute)(tree, (0, devkit_1.joinPathFragments)(appRoot, 'src/app/app.routes.ts'), `{ path: '', loadChildren: () => import('./remote-entry/${entryModuleFileName}').then(m => m.RemoteEntryModule) }`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
2
|
-
export type AddRemoteOptions = {
|
|
3
|
-
host: string;
|
|
4
|
-
appName: string;
|
|
5
|
-
standalone: boolean;
|
|
6
|
-
port: number;
|
|
7
|
-
};
|
|
8
|
-
export declare function checkIsCommaNeeded(mfRemoteText: string): boolean;
|
|
9
|
-
export declare function addRemoteToHost(tree: Tree, options: AddRemoteOptions): void;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkIsCommaNeeded = checkIsCommaNeeded;
|
|
4
|
-
exports.addRemoteToHost = addRemoteToHost;
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const js_1 = require("@nx/js");
|
|
7
|
-
const internal_1 = require("@nx/js/internal");
|
|
8
|
-
const route_utils_1 = require("../../../utils/nx-devkit/route-utils");
|
|
9
|
-
let tsModule;
|
|
10
|
-
function checkIsCommaNeeded(mfRemoteText) {
|
|
11
|
-
const remoteText = mfRemoteText.replace(/\s+/g, '');
|
|
12
|
-
return !remoteText.endsWith(',]')
|
|
13
|
-
? remoteText === '[]'
|
|
14
|
-
? false
|
|
15
|
-
: true
|
|
16
|
-
: false;
|
|
17
|
-
}
|
|
18
|
-
function addRemoteToHost(tree, options) {
|
|
19
|
-
if (options.host) {
|
|
20
|
-
const hostProject = (0, devkit_1.readProjectConfiguration)(tree, options.host);
|
|
21
|
-
const pathToMFManifest = getDynamicManifestFile(tree, hostProject);
|
|
22
|
-
const hostFederationType = !!pathToMFManifest ? 'dynamic' : 'static';
|
|
23
|
-
const isHostUsingTypescriptConfig = tree.exists((0, devkit_1.joinPathFragments)(hostProject.root, 'module-federation.config.ts'));
|
|
24
|
-
if (hostFederationType === 'static') {
|
|
25
|
-
addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescriptConfig);
|
|
26
|
-
}
|
|
27
|
-
else if (hostFederationType === 'dynamic') {
|
|
28
|
-
addRemoteToDynamicHost(tree, options, pathToMFManifest, (0, internal_1.getProjectSourceRoot)(hostProject, tree));
|
|
29
|
-
}
|
|
30
|
-
addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function getDynamicManifestFile(tree, project) {
|
|
34
|
-
// {sourceRoot}/assets/module-federation.manifest.json was the generated
|
|
35
|
-
// path for the manifest file in the past. We now generate the manifest
|
|
36
|
-
// file at {root}/public/module-federation.manifest.json. This check
|
|
37
|
-
// ensures that we can still support the old path for backwards
|
|
38
|
-
// compatibility since old projects may still have the manifest file
|
|
39
|
-
// at the old path.
|
|
40
|
-
return [
|
|
41
|
-
(0, devkit_1.joinPathFragments)(project.root, 'public/module-federation.manifest.json'),
|
|
42
|
-
(0, devkit_1.joinPathFragments)((0, internal_1.getProjectSourceRoot)(project, tree), 'assets/module-federation.manifest.json'),
|
|
43
|
-
].find((path) => tree.exists(path));
|
|
44
|
-
}
|
|
45
|
-
function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescript) {
|
|
46
|
-
const hostMFConfigPath = (0, devkit_1.joinPathFragments)(hostProject.root, isHostUsingTypescript
|
|
47
|
-
? 'module-federation.config.ts'
|
|
48
|
-
: 'module-federation.config.js');
|
|
49
|
-
if (!hostMFConfigPath || !tree.exists(hostMFConfigPath)) {
|
|
50
|
-
throw new Error(`The selected host application, ${options.host}, does not contain a module-federation.config.{ts,js} or module-federation.manifest.json file. Are you sure it has been set up as a host application?`);
|
|
51
|
-
}
|
|
52
|
-
const hostMFConfig = tree.read(hostMFConfigPath, 'utf-8');
|
|
53
|
-
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
54
|
-
const webpackAst = ast(hostMFConfig);
|
|
55
|
-
const mfRemotesNode = query(webpackAst, 'ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=remotes]) > ArrayLiteralExpression')[0];
|
|
56
|
-
const endOfPropertiesPos = mfRemotesNode.getEnd() - 1;
|
|
57
|
-
const isCommaNeeded = checkIsCommaNeeded(mfRemotesNode.getText());
|
|
58
|
-
const updatedConfig = `${hostMFConfig.slice(0, endOfPropertiesPos)}${isCommaNeeded ? ',' : ''}'${options.appName}',${hostMFConfig.slice(endOfPropertiesPos)}`;
|
|
59
|
-
tree.write(hostMFConfigPath, updatedConfig);
|
|
60
|
-
}
|
|
61
|
-
function addRemoteToDynamicHost(tree, options, pathToMfManifest, hostSourceRoot) {
|
|
62
|
-
// TODO(Colum): Remove for Nx 22
|
|
63
|
-
const usingLegacyDynamicFederation = tree
|
|
64
|
-
.read(`${hostSourceRoot}/main.ts`, 'utf-8')
|
|
65
|
-
.includes('setRemoteDefinitions(');
|
|
66
|
-
(0, devkit_1.updateJson)(tree, pathToMfManifest, (manifest) => {
|
|
67
|
-
return {
|
|
68
|
-
...manifest,
|
|
69
|
-
[options.appName]: `http://localhost:${options.port}${usingLegacyDynamicFederation ? '' : '/mf-manifest.json'}`,
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
|
|
74
|
-
if (!tsModule) {
|
|
75
|
-
tsModule = (0, internal_1.ensureTypescript)();
|
|
76
|
-
}
|
|
77
|
-
const hostAppConfig = (0, devkit_1.readProjectConfiguration)(tree, options.host);
|
|
78
|
-
const sourceRoot = (0, internal_1.getProjectSourceRoot)(hostAppConfig, tree);
|
|
79
|
-
const pathToHostRootRouting = `${sourceRoot}/app/app.routes.ts`;
|
|
80
|
-
if (!tree.exists(pathToHostRootRouting)) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const hostRootRoutingFile = tree.read(pathToHostRootRouting, 'utf-8');
|
|
84
|
-
let sourceFile = tsModule.createSourceFile(pathToHostRootRouting, hostRootRoutingFile, tsModule.ScriptTarget.Latest, true);
|
|
85
|
-
// TODO(Colum): Remove for Nx 22
|
|
86
|
-
const usingLegacyDynamicFederation = hostFederationType === 'dynamic' &&
|
|
87
|
-
tree
|
|
88
|
-
.read(`${sourceRoot}/main.ts`, 'utf-8')
|
|
89
|
-
.includes('setRemoteDefinitions(');
|
|
90
|
-
if (hostFederationType === 'dynamic') {
|
|
91
|
-
sourceFile = (0, js_1.insertImport)(tree, sourceFile, pathToHostRootRouting, usingLegacyDynamicFederation ? 'loadRemoteModule' : 'loadRemote', usingLegacyDynamicFederation
|
|
92
|
-
? '@nx/angular/mf'
|
|
93
|
-
: '@module-federation/enhanced/runtime');
|
|
94
|
-
}
|
|
95
|
-
const routePathName = options.standalone ? 'Routes' : 'Module';
|
|
96
|
-
const exportedRemote = options.standalone
|
|
97
|
-
? 'remoteRoutes'
|
|
98
|
-
: 'RemoteEntryModule';
|
|
99
|
-
const remoteModulePath = `${options.appName.replace(/-/g, '_')}/${routePathName}`;
|
|
100
|
-
const routeToAdd = hostFederationType === 'dynamic'
|
|
101
|
-
? usingLegacyDynamicFederation
|
|
102
|
-
? `loadRemoteModule('${options.appName.replace(/-/g, '_')}', './${routePathName}')`
|
|
103
|
-
: `loadRemote<typeof import('${remoteModulePath}')>('${remoteModulePath}')`
|
|
104
|
-
: `import('${remoteModulePath}')`;
|
|
105
|
-
(0, route_utils_1.addRoute)(tree, pathToHostRootRouting, `{
|
|
106
|
-
path: '${options.appName}',
|
|
107
|
-
loadChildren: () => ${routeToAdd}.then(m => m!.${exportedRemote})
|
|
108
|
-
}`);
|
|
109
|
-
let pathToAppComponentTemplate = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.component.html');
|
|
110
|
-
const candidatePaths = [
|
|
111
|
-
pathToAppComponentTemplate,
|
|
112
|
-
(0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.html'),
|
|
113
|
-
];
|
|
114
|
-
for (const path of candidatePaths) {
|
|
115
|
-
if (tree.exists(path)) {
|
|
116
|
-
pathToAppComponentTemplate = path;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const appComponent = tree.read(pathToAppComponentTemplate, 'utf-8');
|
|
121
|
-
if (appComponent.includes(`<ul class="remote-menu">`) &&
|
|
122
|
-
appComponent.includes('</ul>')) {
|
|
123
|
-
const indexOfClosingMenuTag = appComponent.indexOf('</ul>');
|
|
124
|
-
const newAppComponent = `${appComponent.slice(0, indexOfClosingMenuTag)}<li><a routerLink="${options.appName}">${(0, devkit_1.names)(options.appName).className}</a></li>\n${appComponent.slice(indexOfClosingMenuTag)}`;
|
|
125
|
-
tree.write(pathToAppComponentTemplate, newAppComponent);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeBuildTarget = changeBuildTarget;
|
|
4
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function changeBuildTarget(host, options) {
|
|
7
|
-
const appConfig = (0, devkit_1.readProjectConfiguration)(host, options.appName);
|
|
8
|
-
const configExtName = options.typescriptConfiguration ? 'ts' : 'js';
|
|
9
|
-
appConfig.targets.build.executor = '@nx/angular:webpack-browser';
|
|
10
|
-
appConfig.targets.build.options = {
|
|
11
|
-
...appConfig.targets.build.options,
|
|
12
|
-
customWebpackConfig: {
|
|
13
|
-
path: `${appConfig.root}/webpack.config.${configExtName}`,
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
appConfig.targets.build.configurations.production = {
|
|
17
|
-
...appConfig.targets.build.configurations.production,
|
|
18
|
-
customWebpackConfig: {
|
|
19
|
-
path: `${appConfig.root}/webpack.prod.config.${configExtName}`,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.appName, appConfig);
|
|
23
|
-
(0, internal_1.addBuildTargetDefaults)(host, '@nx/angular:webpack-browser');
|
|
24
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fixBootstrap = fixBootstrap;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function fixBootstrap(tree, appRoot, options) {
|
|
6
|
-
const mainFilePath = (0, devkit_1.joinPathFragments)(appRoot, 'src/main.ts');
|
|
7
|
-
const bootstrapCode = tree.read(mainFilePath, 'utf-8');
|
|
8
|
-
if (options.standalone && options.mfType === 'remote') {
|
|
9
|
-
tree.write(`${appRoot}/src/bootstrap.ts`, standaloneBootstrapCode(options.componentType, options.componentFileSuffix));
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
tree.write((0, devkit_1.joinPathFragments)(appRoot, 'src/bootstrap.ts'), bootstrapCode);
|
|
13
|
-
}
|
|
14
|
-
const bootstrapImportCode = `import('./bootstrap').catch(err => console.error(err))`;
|
|
15
|
-
if (options.mfType === 'remote' || options.federationType === 'static') {
|
|
16
|
-
tree.write(mainFilePath, `${bootstrapImportCode};`);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
let manifestPath = '/assets/module-federation.manifest.json';
|
|
20
|
-
if (tree.exists((0, devkit_1.joinPathFragments)(appRoot, 'public/module-federation.manifest.json'))) {
|
|
21
|
-
manifestPath = '/module-federation.manifest.json';
|
|
22
|
-
}
|
|
23
|
-
const fetchMFManifestCode = `import { registerRemotes } from '@module-federation/enhanced/runtime';
|
|
24
|
-
|
|
25
|
-
fetch('${manifestPath}')
|
|
26
|
-
.then((res) => res.json())
|
|
27
|
-
.then((remotes: Record<string, string>) => Object.entries(remotes).map(([name, entry]) => ({ name,entry})))
|
|
28
|
-
.then(remotes => registerRemotes(remotes))
|
|
29
|
-
.then(() => ${bootstrapImportCode});`;
|
|
30
|
-
tree.write(mainFilePath, fetchMFManifestCode);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const standaloneBootstrapCode = (componentType, componentFileSuffix) => `import { bootstrapApplication } from '@angular/platform-browser';
|
|
34
|
-
import { appConfig } from './app/app.config';
|
|
35
|
-
import { RemoteEntry${componentType} } from './app/remote-entry/entry${componentFileSuffix}';
|
|
36
|
-
|
|
37
|
-
bootstrapApplication(RemoteEntry${componentType}, appConfig).catch((err) =>
|
|
38
|
-
console.error(err)
|
|
39
|
-
);
|
|
40
|
-
`;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Tree } from '@nx/devkit';
|
|
2
|
-
import type { NormalizedOptions } from '../schema';
|
|
3
|
-
export declare function generateWebpackConfig(tree: Tree, options: NormalizedOptions, appRoot: string, remotesWithPorts: {
|
|
4
|
-
remoteName: string;
|
|
5
|
-
port: number;
|
|
6
|
-
}[]): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateWebpackConfig = generateWebpackConfig;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/eslint/internal");
|
|
6
|
-
function generateWebpackConfig(tree, options, appRoot, remotesWithPorts) {
|
|
7
|
-
if (tree.exists(`${appRoot}/module-federation.config.js`) ||
|
|
8
|
-
tree.exists(`${appRoot}/webpack.config.js`) ||
|
|
9
|
-
tree.exists(`${appRoot}/webpack.prod.config.js`) ||
|
|
10
|
-
tree.exists(`${appRoot}/module-federation.config.ts`) ||
|
|
11
|
-
tree.exists(`${appRoot}/webpack.config.ts`) ||
|
|
12
|
-
tree.exists(`${appRoot}/webpack.prod.config.ts`)) {
|
|
13
|
-
devkit_1.logger.warn(`NOTE: We encountered an existing webpack config for the app ${options.appName}. We have overwritten this file with the Module Federation Config.\n
|
|
14
|
-
If this was not the outcome you expected, you can discard the changes we have made, create a backup of your current webpack config, and run the command again.`);
|
|
15
|
-
}
|
|
16
|
-
const pathToWebpackTemplateFiles = options.typescriptConfiguration
|
|
17
|
-
? 'ts-webpack'
|
|
18
|
-
: 'webpack';
|
|
19
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToWebpackTemplateFiles}`), appRoot, {
|
|
20
|
-
tmpl: '',
|
|
21
|
-
type: options.mfType,
|
|
22
|
-
federationType: options.federationType,
|
|
23
|
-
name: options.appName,
|
|
24
|
-
remotes: remotesWithPorts ?? [],
|
|
25
|
-
projectRoot: appRoot,
|
|
26
|
-
standalone: options.standalone,
|
|
27
|
-
entryModuleFileName: options.entryModuleFileName,
|
|
28
|
-
});
|
|
29
|
-
if (!(0, internal_1.isTypedLintingEnabled)(options)) {
|
|
30
|
-
tree.delete((0, devkit_1.joinPathFragments)(appRoot, 'tsconfig.lint.json'));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRemotesWithPorts = getRemotesWithPorts;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function getRemotesWithPorts(host, options) {
|
|
6
|
-
// If type is host and remotes supplied, check remotes exist
|
|
7
|
-
const remotesWithPort = [];
|
|
8
|
-
if (options.mfType === 'host' &&
|
|
9
|
-
Array.isArray(options.remotes) &&
|
|
10
|
-
options.remotes.length > 0) {
|
|
11
|
-
for (const remote of options.remotes) {
|
|
12
|
-
const remoteConfig = (0, devkit_1.readProjectConfiguration)(host, remote);
|
|
13
|
-
remotesWithPort.push({
|
|
14
|
-
remoteName: remote,
|
|
15
|
-
port: remoteConfig.targets['serve']?.options?.port ?? 4200,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return remotesWithPort;
|
|
20
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './add-cypress-workaround';
|
|
2
|
-
export * from './add-remote-entry';
|
|
3
|
-
export * from './add-remote-to-host';
|
|
4
|
-
export * from './change-build-target';
|
|
5
|
-
export * from './fix-bootstrap';
|
|
6
|
-
export * from './generate-config';
|
|
7
|
-
export * from './get-remotes-with-ports';
|
|
8
|
-
export * from './move-angular-plugin-to-dependencies';
|
|
9
|
-
export * from './normalize-options';
|
|
10
|
-
export * from './update-tsconfig';
|
|
11
|
-
export * from './setup-host-if-dynamic';
|
|
12
|
-
export * from './setup-serve-target';
|
|
13
|
-
export * from './update-host-app-routes';
|
|
14
|
-
export * from './remove-dead-code-from-remote';
|
|
15
|
-
export * from './setup-tspath-for-remote';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./add-cypress-workaround"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./add-remote-entry"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./add-remote-to-host"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./change-build-target"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./fix-bootstrap"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./generate-config"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./get-remotes-with-ports"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./move-angular-plugin-to-dependencies"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./update-tsconfig"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./setup-host-if-dynamic"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./setup-serve-target"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./update-host-app-routes"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./remove-dead-code-from-remote"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./setup-tspath-for-remote"), exports);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.moveAngularPluginToDependencies = moveAngularPluginToDependencies;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function moveAngularPluginToDependencies(tree) {
|
|
6
|
-
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
7
|
-
if (packageJson.dependencies?.['@nx/angular']) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
packageJson.dependencies ??= {};
|
|
11
|
-
packageJson.dependencies['@nx/angular'] =
|
|
12
|
-
packageJson.devDependencies['@nx/angular'];
|
|
13
|
-
delete packageJson.devDependencies['@nx/angular'];
|
|
14
|
-
(0, devkit_1.writeJson)(tree, 'package.json', packageJson);
|
|
15
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const app_components_info_1 = require("../../utils/app-components-info");
|
|
6
|
-
const artifact_types_1 = require("../../utils/artifact-types");
|
|
7
|
-
const project_1 = require("../../utils/project");
|
|
8
|
-
function normalizeOptions(tree, options) {
|
|
9
|
-
const componentType = (0, artifact_types_1.getComponentType)(tree);
|
|
10
|
-
const componentFileSuffix = componentType ? `.${componentType}` : '';
|
|
11
|
-
const moduleTypeSeparator = (0, artifact_types_1.getModuleTypeSeparator)(tree);
|
|
12
|
-
const entryModuleFileName = `entry${moduleTypeSeparator}module`;
|
|
13
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.appName);
|
|
14
|
-
return {
|
|
15
|
-
...options,
|
|
16
|
-
typescriptConfiguration: options.typescriptConfiguration ?? true,
|
|
17
|
-
federationType: options.federationType ?? 'static',
|
|
18
|
-
prefix: options.prefix ?? (0, project_1.getProjectPrefix)(tree, options.appName) ?? 'app',
|
|
19
|
-
standalone: options.standalone ?? true,
|
|
20
|
-
componentType: componentType ? (0, devkit_1.names)(componentType).className : '',
|
|
21
|
-
componentFileSuffix,
|
|
22
|
-
entryModuleFileName,
|
|
23
|
-
appComponentInfo: (0, app_components_info_1.getAppComponentInfo)(tree, componentFileSuffix, project),
|
|
24
|
-
nxWelcomeComponentInfo: (0, app_components_info_1.getNxWelcomeComponentInfo)(tree, componentFileSuffix, project),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeDeadCodeFromRemote = removeDeadCodeFromRemote;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/js/internal");
|
|
6
|
-
function removeDeadCodeFromRemote(tree, options) {
|
|
7
|
-
const projectName = options.appName;
|
|
8
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
9
|
-
const sourceRoot = (0, internal_1.getProjectSourceRoot)(project, tree);
|
|
10
|
-
const { appComponentInfo, nxWelcomeComponentInfo, entryModuleFileName } = options;
|
|
11
|
-
['css', 'less', 'scss', 'sass'].forEach((style) => {
|
|
12
|
-
const pathToComponentStyle = (0, devkit_1.joinPathFragments)(sourceRoot, `app/${appComponentInfo.extensionlessFileName}.${style}`);
|
|
13
|
-
if (tree.exists(pathToComponentStyle)) {
|
|
14
|
-
tree.delete(pathToComponentStyle);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
tree.rename(nxWelcomeComponentInfo.path, (0, devkit_1.joinPathFragments)(sourceRoot, `app/remote-entry/${nxWelcomeComponentInfo.fileName}`));
|
|
18
|
-
tree.delete((0, devkit_1.joinPathFragments)(sourceRoot, `app/${appComponentInfo.extensionlessFileName}.spec.ts`));
|
|
19
|
-
tree.delete((0, devkit_1.joinPathFragments)(sourceRoot, `app/${appComponentInfo.extensionlessFileName}.html`));
|
|
20
|
-
if (!options.standalone) {
|
|
21
|
-
const componentContents = tree.read(appComponentInfo.path, 'utf-8');
|
|
22
|
-
const isInlineTemplate = !componentContents.includes('templateUrl');
|
|
23
|
-
const component = componentContents.split(isInlineTemplate ? 'template' : 'templateUrl')[0] +
|
|
24
|
-
`template: '<router-outlet></router-outlet>'
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
export class ${appComponentInfo.symbolName} {}`;
|
|
28
|
-
tree.write(appComponentInfo.path, component);
|
|
29
|
-
let modulePath = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.module.ts');
|
|
30
|
-
if (!tree.exists(modulePath)) {
|
|
31
|
-
modulePath = (0, devkit_1.joinPathFragments)(sourceRoot, 'app/app-module.ts');
|
|
32
|
-
}
|
|
33
|
-
tree.write(modulePath, `import { NgModule } from '@angular/core';
|
|
34
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
35
|
-
import { RouterModule } from '@angular/router';
|
|
36
|
-
import { ${appComponentInfo.symbolName} } from './${appComponentInfo.extensionlessFileName}';
|
|
37
|
-
|
|
38
|
-
@NgModule({
|
|
39
|
-
declarations: [${appComponentInfo.symbolName}],
|
|
40
|
-
imports: [
|
|
41
|
-
BrowserModule,
|
|
42
|
-
RouterModule.forRoot([{
|
|
43
|
-
path: '',
|
|
44
|
-
loadChildren: () => import('./remote-entry/${entryModuleFileName}').then(m => m.RemoteEntryModule)
|
|
45
|
-
}], { initialNavigation: 'enabledBlocking' }),
|
|
46
|
-
],
|
|
47
|
-
providers: [],
|
|
48
|
-
bootstrap: [${appComponentInfo.symbolName}],
|
|
49
|
-
})
|
|
50
|
-
export class AppModule {}`);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
tree.delete(appComponentInfo.path);
|
|
54
|
-
const pathToIndexHtml = project.targets.build.options.index;
|
|
55
|
-
const indexContents = tree.read(pathToIndexHtml, 'utf-8');
|
|
56
|
-
const rootSelectorRegex = new RegExp(`${options.prefix || 'app'}-root`, 'ig');
|
|
57
|
-
const remoteEntrySelector = `${options.prefix || 'app'}-${projectName}-entry`;
|
|
58
|
-
const newIndexContents = indexContents.replace(rootSelectorRegex, remoteEntrySelector);
|
|
59
|
-
tree.write(pathToIndexHtml, newIndexContents);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupHostIfDynamic = setupHostIfDynamic;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function setupHostIfDynamic(tree, options) {
|
|
6
|
-
if (options.federationType === 'static') {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.appName);
|
|
10
|
-
const pathToMFManifest = (0, devkit_1.joinPathFragments)(project.root, 'public/module-federation.manifest.json');
|
|
11
|
-
if (!tree.exists(pathToMFManifest)) {
|
|
12
|
-
tree.write(pathToMFManifest, '{}');
|
|
13
|
-
}
|
|
14
|
-
const pathToProdWebpackConfig = (0, devkit_1.joinPathFragments)(project.root, `webpack.prod.config.${options.typescriptConfiguration ? 'ts' : 'js'}`);
|
|
15
|
-
if (tree.exists(pathToProdWebpackConfig)) {
|
|
16
|
-
tree.delete(pathToProdWebpackConfig);
|
|
17
|
-
}
|
|
18
|
-
delete project.targets.build.configurations.production?.customWebpackConfig;
|
|
19
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.appName, project);
|
|
20
|
-
}
|