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

34 lines (33 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getMFProjects = getMFProjects; const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils"); function _getMfProjects(tree, CUSTOM_WEBPACK_OPTION, MODULE_FEDERATION_IDENTIFIER, projects) { return (opts, projectName) => { const webpackPath = opts[CUSTOM_WEBPACK_OPTION]?.path; if (!webpackPath || !tree.exists(webpackPath)) { return; } const webpackConfig = tree.read(webpackPath, 'utf-8'); const { tsquery } = require('@phenomnomnominal/tsquery'); const ast = tsquery.ast(webpackConfig); const moduleFederationWebpackConfig = tsquery(ast, MODULE_FEDERATION_IDENTIFIER, { visitAllChildren: true, }); if (!moduleFederationWebpackConfig || moduleFederationWebpackConfig.length === 0) { return; } projects.push(projectName); }; } function getMFProjects(tree, { legacy } = { legacy: false }) { const CUSTOM_WEBPACK_OPTION = 'customWebpackConfig'; const MODULE_FEDERATION_IDENTIFIER = legacy ? 'Identifier[name=ModuleFederationPlugin]' : 'Identifier[name=withModuleFederation]'; const projects = []; (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/angular:webpack-browser', _getMfProjects(tree, CUSTOM_WEBPACK_OPTION, MODULE_FEDERATION_IDENTIFIER, projects)); (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/angular:webpack-browser', _getMfProjects(tree, CUSTOM_WEBPACK_OPTION, MODULE_FEDERATION_IDENTIFIER, projects)); return projects; }