UNPKG

@nx/angular

Version:

The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: - Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypre

449 lines (433 loc) • 12.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ERROR_SHARED_PACKAGES_DOESNT_MATCH = exports.ERROR_NAME_DOESNT_MATCH = exports.OLD_OBJECT_SHARED_SYNTAX = exports.STANDARD_REMOTE_MFE_CONFIG = exports.STANDARD_HOST_MFE_CONFIG = void 0; exports.STANDARD_HOST_MFE_CONFIG = `const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin'); const mf = require('@angular-architects/module-federation/webpack'); const path = require('path'); const share = mf.share; /** * We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser * builder as it will generate a temporary tsconfig file which contains any required remappings of * shared libraries. * A remapping will occur when a library is buildable, as webpack needs to know the location of the * built files for the buildable library. * This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains * the location of the generated temporary tsconfig file. */ const tsConfigPath = process.env.NX_TSCONFIG_PATH ?? path.join(__dirname, '../../tsconfig.base.json'); const workspaceRootPath = path.join(__dirname, '../../'); const sharedMappings = new mf.SharedMappings(); sharedMappings.register( tsConfigPath, [ /* mapped paths to share */ ], workspaceRootPath ); module.exports = { output: { uniqueName: 'host1', publicPath: 'auto', }, optimization: { runtimeChunk: false, }, experiments: { outputModule: true, }, resolve: { alias: { ...sharedMappings.getAliases(), }, }, plugins: [ new ModuleFederationPlugin({ remotes: { remote1: 'http://localhost:4201/remoteEntry.mjs', }, shared: share({ '@angular/core': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/common': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/common/http': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/router': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, rxjs: { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, ...sharedMappings.getDescriptors(), }), library: { type: 'module', }, }), sharedMappings.getPlugin(), ], }; `; exports.STANDARD_REMOTE_MFE_CONFIG = `const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin'); const mf = require('@angular-architects/module-federation/webpack'); const path = require('path'); const share = mf.share; /** * We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser * builder as it will generate a temporary tsconfig file which contains any required remappings of * shared libraries. * A remapping will occur when a library is buildable, as webpack needs to know the location of the * built files for the buildable library. * This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains * the location of the generated temporary tsconfig file. */ const tsConfigPath = process.env.NX_TSCONFIG_PATH ?? path.join(__dirname, '../../tsconfig.base.json'); const workspaceRootPath = path.join(__dirname, '../../'); const sharedMappings = new mf.SharedMappings(); sharedMappings.register( tsConfigPath, [ /* mapped paths to share */ ], workspaceRootPath ); module.exports = { output: { uniqueName: 'remote1', publicPath: 'auto', }, optimization: { runtimeChunk: false, }, experiments: { outputModule: true, }, resolve: { alias: { ...sharedMappings.getAliases(), }, }, plugins: [ new ModuleFederationPlugin({ name: 'remote1', filename: 'remoteEntry.js', exposes: { './Module': 'apps/remote1/src/app/remote-entry/entry.module.ts', }, shared: share({ '@angular/core': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/common': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/common/http': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/router': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, rxjs: { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, ...sharedMappings.getDescriptors(), }), library: { type: 'module', }, }), sharedMappings.getPlugin(), ], }; `; exports.OLD_OBJECT_SHARED_SYNTAX = `const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin'); const mf = require('@angular-architects/module-federation/webpack'); const path = require('path'); const share = mf.share; /** * We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser * builder as it will generate a temporary tsconfig file which contains any required remappings of * shared libraries. * A remapping will occur when a library is buildable, as webpack needs to know the location of the * built files for the buildable library. * This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains * the location of the generated temporary tsconfig file. */ const tsConfigPath = process.env.NX_TSCONFIG_PATH ?? path.join(__dirname, '../../tsconfig.base.json'); const workspaceRootPath = path.join(__dirname, '../../'); const sharedMappings = new mf.SharedMappings(); sharedMappings.register( tsConfigPath, [ /* mapped paths to share */ ], workspaceRootPath ); module.exports = { output: { uniqueName: 'remote1', publicPath: 'auto', }, optimization: { runtimeChunk: false, }, experiments: { outputModule: true, }, resolve: { alias: { ...sharedMappings.getAliases(), }, }, plugins: [ new ModuleFederationPlugin({ name: 'remote1', filename: 'remoteEntry.js', exposes: { './Module': 'apps/remote1/src/app/remote-entry/entry.module.ts', }, shared: { '@angular/core': { singleton: true, strictVersion: true, }, '@angular/common': { singleton: true, strictVersion: true, }, '@angular/common/http': { singleton: true, strictVersion: true, }, '@angular/router': { singleton: true, strictVersion: true, }, rxjs: { singleton: true, strictVersion: true, }, ...sharedMappings.getDescriptors(), }, library: { type: 'module', }, }), sharedMappings.getPlugin(), ], };`; exports.ERROR_NAME_DOESNT_MATCH = `const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin'); const mf = require('@angular-architects/module-federation/webpack'); const path = require('path'); const share = mf.share; /** * We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser * builder as it will generate a temporary tsconfig file which contains any required remappings of * shared libraries. * A remapping will occur when a library is buildable, as webpack needs to know the location of the * built files for the buildable library. * This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains * the location of the generated temporary tsconfig file. */ const tsConfigPath = process.env.NX_TSCONFIG_PATH ?? path.join(__dirname, '../../tsconfig.base.json'); const workspaceRootPath = path.join(__dirname, '../../'); const sharedMappings = new mf.SharedMappings(); sharedMappings.register( tsConfigPath, [ /* mapped paths to share */ ], workspaceRootPath ); module.exports = { output: { uniqueName: 'somethingelse', publicPath: 'auto', }, optimization: { runtimeChunk: false, }, experiments: { outputModule: true, }, resolve: { alias: { ...sharedMappings.getAliases(), }, }, plugins: [ new ModuleFederationPlugin({ name: 'remote1', filename: 'remoteEntry.js', exposes: { './Module': 'apps/remote1/src/app/remote-entry/entry.module.ts', }, shared: share({ '@angular/core': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/common': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/common/http': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/router': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, rxjs: { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, ...sharedMappings.getDescriptors(), }), library: { type: 'module', }, }), sharedMappings.getPlugin(), ], }; `; exports.ERROR_SHARED_PACKAGES_DOESNT_MATCH = `const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin'); const mf = require('@angular-architects/module-federation/webpack'); const path = require('path'); const share = mf.share; /** * We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser * builder as it will generate a temporary tsconfig file which contains any required remappings of * shared libraries. * A remapping will occur when a library is buildable, as webpack needs to know the location of the * built files for the buildable library. * This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains * the location of the generated temporary tsconfig file. */ const tsConfigPath = process.env.NX_TSCONFIG_PATH ?? path.join(__dirname, '../../tsconfig.base.json'); const workspaceRootPath = path.join(__dirname, '../../'); const sharedMappings = new mf.SharedMappings(); sharedMappings.register( tsConfigPath, [ /* mapped paths to share */ ], workspaceRootPath ); module.exports = { output: { uniqueName: 'host1', publicPath: 'auto', }, optimization: { runtimeChunk: false, }, experiments: { outputModule: true, }, resolve: { alias: { ...sharedMappings.getAliases(), }, }, plugins: [ new ModuleFederationPlugin({ remotes: { remote1: 'http://localhost:4201/remoteEntry.mjs', }, shared: share({ '@angular/core': { singleton: true, strictVersion: true, requiredVersion: '13.0.0', includeSecondaries: true, }, '@angular/common': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/common/http': { singleton: true, strictVersion: false, requiredVersion: 'auto', includeSecondaries: true, }, '@angular/router': { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, rxjs: { singleton: true, strictVersion: true, requiredVersion: 'auto', includeSecondaries: true, }, ...sharedMappings.getDescriptors(), }), library: { type: 'module', }, }), sharedMappings.getPlugin(), ], }; `;