@nx/angular 16.8.0-beta.4 → 16.8.0-beta.5
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/mf/mf.js +31 -36
- package/package.json +10 -10
- package/plugins/component-testing.js +48 -40
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.js +4 -6
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +4 -6
- package/src/builders/utilities/buildable-libs.js +1 -2
- package/src/builders/utilities/module-federation.js +2 -3
- package/src/builders/utilities/webpack.js +16 -21
- package/src/builders/webpack-browser/webpack-browser.impl.js +13 -13
- package/src/builders/webpack-dev-server/lib/normalize-options.js +8 -1
- package/src/builders/webpack-dev-server/webpack-dev-server.impl.js +24 -18
- package/src/builders/webpack-server/webpack-server.impl.js +5 -7
- package/src/executors/browser-esbuild/browser-esbuild.impl.js +19 -23
- package/src/executors/browser-esbuild/lib/buildable-libs.js +1 -2
- package/src/executors/delegate-build/delegate-build.impl.js +9 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +4 -7
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.transform.js +4 -5
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +158 -156
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/options.di.js +6 -3
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ngc/compile-source-files.js +118 -118
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/styles/stylesheet-processor.js +96 -103
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ts/cache-compiler-host.js +20 -12
- package/src/executors/ng-packagr-lite/ng-packagr-lite.impl.js +18 -21
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +6 -9
- package/src/executors/package/ng-packagr-adjustments/ng-package/options.di.js +6 -3
- package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +122 -122
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +96 -103
- package/src/executors/package/ng-packagr-adjustments/ts/cache-compiler-host.js +21 -13
- package/src/executors/package/ng-packagr-adjustments/utils/ng-compiler-cli.js +5 -8
- package/src/executors/package/package.impl.js +33 -38
- package/src/executors/utilities/angular-version-utils.js +1 -1
- package/src/executors/utilities/tailwindcss.js +2 -2
- package/src/executors/utilities/typescript.js +23 -28
- package/src/generators/add-linting/add-linting.js +76 -74
- package/src/generators/add-linting/lib/create-eslint-configuration.js +12 -4
- package/src/generators/application/application.js +56 -55
- package/src/generators/application/lib/add-e2e.js +36 -40
- package/src/generators/application/lib/add-linting.js +12 -15
- package/src/generators/application/lib/add-proxy-config.js +4 -1
- package/src/generators/application/lib/add-unit-test-runner.js +15 -18
- package/src/generators/application/lib/create-files.js +44 -47
- package/src/generators/application/lib/enable-strict-type-checking.js +2 -2
- package/src/generators/application/lib/normalize-options.js +37 -25
- package/src/generators/application/lib/set-app-strict-default.js +1 -2
- package/src/generators/application/lib/update-editor-tsconfig.js +1 -2
- package/src/generators/component/component.js +40 -43
- package/src/generators/component/lib/normalize-options.js +15 -5
- package/src/generators/component-cypress-spec/component-cypress-spec.js +25 -28
- package/src/generators/component-story/component-story.js +19 -22
- package/src/generators/convert-to-with-mf/convert-to-with-mf.js +19 -22
- package/src/generators/convert-to-with-mf/lib/get-webpack-config-path.js +3 -4
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +103 -106
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +59 -62
- package/src/generators/directive/directive.js +21 -24
- package/src/generators/directive/lib/normalize-options.js +11 -5
- package/src/generators/host/host.js +77 -67
- package/src/generators/host/lib/add-ssr.js +32 -35
- package/src/generators/init/init.js +101 -92
- package/src/generators/library/lib/add-standalone-component.js +18 -13
- package/src/generators/library/lib/enable-strict-type-checking.js +17 -5
- package/src/generators/library/lib/normalize-options.js +68 -53
- package/src/generators/library/library.js +89 -92
- package/src/generators/library-secondary-entry-point/lib/add-files.js +5 -1
- package/src/generators/library-secondary-entry-point/lib/normalize-options.js +6 -3
- package/src/generators/library-secondary-entry-point/lib/update-linting-file-patterns.js +1 -2
- package/src/generators/library-secondary-entry-point/library-secondary-entry-point.js +6 -9
- package/src/generators/move/lib/normalize-schema.js +5 -1
- package/src/generators/move/lib/update-module-name.js +1 -1
- package/src/generators/move/lib/update-ng-package.js +1 -2
- package/src/generators/move/lib/update-secondary-entry-points.js +1 -2
- package/src/generators/move/move.js +9 -12
- package/src/generators/ng-add/migrate-from-angular-cli.js +54 -53
- package/src/generators/ng-add/migrators/builders/angular-devkit-karma.migrator.js +4 -3
- package/src/generators/ng-add/migrators/builders/angular-devkit-ng-packagr.migrator.js +11 -12
- package/src/generators/ng-add/migrators/builders/angular-eslint-lint.migrator.js +39 -42
- package/src/generators/ng-add/migrators/builders/builder.migrator.js +1 -2
- package/src/generators/ng-add/migrators/migrator.js +7 -11
- package/src/generators/ng-add/migrators/projects/app.migrator.js +39 -43
- package/src/generators/ng-add/migrators/projects/e2e.migrator.js +115 -91
- package/src/generators/ng-add/migrators/projects/lib.migrator.js +23 -31
- package/src/generators/ng-add/migrators/projects/project.migrator.js +10 -14
- package/src/generators/ng-add/ng-add.js +5 -8
- package/src/generators/ng-add/utilities/dependencies.js +2 -3
- package/src/generators/ng-add/utilities/format-files-task.js +1 -1
- package/src/generators/ng-add/utilities/projects.js +1 -1
- package/src/generators/ng-add/utilities/workspace.js +25 -36
- package/src/generators/ngrx/lib/add-imports-to-module.js +1 -2
- package/src/generators/ngrx/lib/add-ngrx-to-package-json.js +1 -3
- package/src/generators/ngrx/lib/generate-files.js +11 -2
- package/src/generators/ngrx/lib/normalize-options.js +9 -4
- package/src/generators/ngrx/lib/validate-options.js +3 -3
- package/src/generators/ngrx/ngrx.js +18 -21
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.actions.ts__tmpl__ +1 -1
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.effects.spec.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.effects.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.facade.spec.ts__tmpl__ +6 -6
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.facade.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.reducer.spec.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.reducer.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.selectors.spec.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.selectors.ts__tmpl__ +1 -1
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/lib/add-exports-barrel.js +4 -1
- package/src/generators/ngrx-feature-store/lib/add-imports.js +1 -1
- package/src/generators/ngrx-feature-store/lib/add-ngrx-to-package-json.js +1 -3
- package/src/generators/ngrx-feature-store/lib/generate-files.js +20 -4
- package/src/generators/ngrx-feature-store/lib/normalize-options.d.ts +1 -0
- package/src/generators/ngrx-feature-store/lib/normalize-options.js +22 -3
- package/src/generators/ngrx-feature-store/lib/validate-options.js +2 -2
- package/src/generators/ngrx-feature-store/ngrx-feature-store.js +18 -21
- package/src/generators/ngrx-root-store/lib/add-ngrx-to-package-json.js +8 -6
- package/src/generators/ngrx-root-store/lib/normalize-options.js +8 -4
- package/src/generators/ngrx-root-store/lib/validate-options.js +2 -2
- package/src/generators/ngrx-root-store/ngrx-root-store.js +27 -30
- package/src/generators/pipe/lib/normalize-options.js +9 -3
- package/src/generators/pipe/pipe.js +21 -24
- package/src/generators/remote/lib/add-ssr.js +46 -47
- package/src/generators/remote/lib/find-next-available-port.js +1 -2
- package/src/generators/remote/remote.js +52 -49
- package/src/generators/scam/lib/convert-component-to-scam.js +1 -2
- package/src/generators/scam/lib/normalize-options.js +11 -4
- package/src/generators/scam/scam.js +15 -12
- package/src/generators/scam-directive/lib/normalize-options.js +12 -4
- package/src/generators/scam-directive/scam-directive.js +13 -10
- package/src/generators/scam-pipe/lib/normalize-options.js +12 -4
- package/src/generators/scam-pipe/scam-pipe.js +13 -10
- package/src/generators/scam-to-standalone/scam-to-standalone.js +23 -26
- package/src/generators/setup-mf/lib/add-cypress-workaround.js +1 -1
- package/src/generators/setup-mf/lib/add-remote-to-host.js +4 -1
- package/src/generators/setup-mf/lib/change-build-target.js +10 -4
- package/src/generators/setup-mf/lib/generate-config.js +1 -1
- package/src/generators/setup-mf/lib/get-remotes-with-ports.js +1 -2
- package/src/generators/setup-mf/lib/normalize-options.js +5 -2
- package/src/generators/setup-mf/lib/set-tsconfig-target.js +7 -1
- package/src/generators/setup-mf/lib/setup-host-if-dynamic.js +1 -2
- package/src/generators/setup-mf/lib/setup-serve-target.js +10 -3
- package/src/generators/setup-mf/setup-mf.js +32 -35
- package/src/generators/setup-ssr/lib/generate-files.js +8 -5
- package/src/generators/setup-ssr/lib/normalize-options.js +9 -10
- package/src/generators/setup-ssr/lib/update-project-config.js +21 -17
- package/src/generators/setup-ssr/setup-ssr.js +26 -27
- package/src/generators/setup-tailwind/lib/add-tailwind-config-path-to-project.js +6 -4
- package/src/generators/setup-tailwind/lib/detect-tailwind-installed-version.js +1 -2
- package/src/generators/setup-tailwind/lib/normalize-options.js +4 -1
- package/src/generators/setup-tailwind/lib/update-application-styles.js +5 -6
- package/src/generators/setup-tailwind/setup-tailwind.js +20 -23
- package/src/generators/stories/lib/get-e2e-project.js +1 -1
- package/src/generators/stories/stories.js +43 -50
- package/src/generators/storybook-configuration/lib/assert-compatible-storybook-version.js +1 -1
- package/src/generators/storybook-configuration/lib/generate-stories.js +10 -13
- package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +12 -15
- package/src/generators/storybook-configuration/storybook-configuration.js +20 -16
- package/src/generators/utils/create-ts-config.js +1 -1
- package/src/generators/utils/entry-point.js +1 -2
- package/src/generators/utils/export-scam.js +1 -1
- package/src/generators/utils/insert-ngmodule-import.js +1 -1
- package/src/generators/utils/path.js +3 -3
- package/src/generators/utils/project.js +2 -3
- package/src/generators/utils/selector.js +1 -1
- package/src/generators/utils/storybook-ast/component-info.js +1 -2
- package/src/generators/utils/storybook-ast/entry-point.js +1 -2
- package/src/generators/utils/storybook-ast/module-info.js +1 -2
- package/src/generators/utils/storybook-ast/tree-utilities.js +1 -1
- package/src/generators/utils/testing.js +141 -139
- package/src/generators/utils/validations.js +1 -1
- package/src/generators/utils/version-utils.js +5 -7
- package/src/generators/web-worker/lib/normalize-options.js +6 -3
- package/src/generators/web-worker/web-worker.js +25 -28
- package/src/migrations/update-14-2-0/remove-show-circular-dependencies-option.js +10 -13
- package/src/migrations/update-14-2-0/update-angular-cli.js +14 -18
- package/src/migrations/update-14-2-0/update-libraries-secondary-entrypoints.js +22 -26
- package/src/migrations/update-14-2-0/update-ngcc-target.js +10 -14
- package/src/migrations/update-14-2-0/update-router-initial-navigation.js +31 -39
- package/src/migrations/update-14-2-0/update-tsconfig-target.js +48 -56
- package/src/migrations/update-14-5-0/migrate-mfe-to-mf.js +14 -17
- package/src/migrations/update-14-5-2/update-angular-cli.js +14 -18
- package/src/migrations/update-14-6-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-0-0/add-karma-inputs.js +27 -32
- package/src/migrations/update-15-0-0/switch-to-jasmine-marbles.js +62 -68
- package/src/migrations/update-15-2-0/remove-browserlist-config.js +34 -37
- package/src/migrations/update-15-2-0/remove-platform-server-exports.js +49 -52
- package/src/migrations/update-15-2-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-2-0/update-karma-main-file.js +11 -12
- package/src/migrations/update-15-2-0/update-typescript-target.js +40 -39
- package/src/migrations/update-15-2-0/update-workspace-config.js +16 -19
- package/src/migrations/update-15-5-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-7-0/install-required-packages.js +26 -28
- package/src/migrations/update-15-8-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-9-0/update-file-server-executor.js +31 -35
- package/src/migrations/update-15-9-0/update-testing-tsconfig.js +17 -22
- package/src/migrations/update-16-0-0/remove-karma-defaults.js +15 -18
- package/src/migrations/update-16-0-0/remove-library-generator-simple-module-name-option.js +22 -25
- package/src/migrations/update-16-0-0/remove-protractor-defaults.js +15 -18
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-1-0/extract-standalone-config-from-bootstrap.js +38 -42
- package/src/migrations/update-16-1-0/remove-ngcc-invocation.js +15 -19
- package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.js +49 -52
- package/src/migrations/update-16-1-0/update-angular-cli.js +14 -18
- package/src/migrations/update-16-1-0/update-server-executor-config.js +13 -16
- package/src/migrations/update-16-2-0/switch-data-persistence-operators-imports-to-ngrx-router-store.js +25 -29
- package/src/migrations/update-16-4-0/rename-angular-eslint-accesibility-rules.js +13 -16
- package/src/migrations/update-16-4-0/update-angular-cli.js +14 -18
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +19 -24
- package/src/migrations/update-16-7-0/update-angular-cli.js +14 -18
- package/src/migrations/utils/projects.js +9 -15
- package/src/utils/get-mf-projects.js +1 -2
- package/src/utils/mf/utils.js +43 -44
- package/src/utils/mf/with-module-federation-ssr.js +39 -24
- package/src/utils/mf/with-module-federation.js +40 -21
- package/src/utils/nx-devkit/ast-utils.js +2 -3
- package/src/utils/version-utils.js +2 -4
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.nxWritePackageTransform = void 0;
|
|
11
|
-
const tslib_1 = require("tslib");
|
|
12
11
|
const devkit_1 = require("@nx/devkit");
|
|
13
12
|
const node_1 = require("ng-packagr/lib/graph/node");
|
|
14
13
|
const transform_1 = require("ng-packagr/lib/graph/transform");
|
|
@@ -18,8 +17,7 @@ const glob_1 = require("ng-packagr/lib/utils/glob");
|
|
|
18
17
|
const path_1 = require("ng-packagr/lib/utils/path");
|
|
19
18
|
const path = require("path");
|
|
20
19
|
const angular_version_utils_1 = require("../../../../utilities/angular-version-utils");
|
|
21
|
-
const nxWritePackageTransform = (options) => (0, transform_1.transformFromPromise)((graph) =>
|
|
22
|
-
var _a;
|
|
20
|
+
const nxWritePackageTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
|
|
23
21
|
const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
|
|
24
22
|
const ngEntryPoint = entryPoint.data.entryPoint;
|
|
25
23
|
const ngPackageNode = graph.find(nodes_1.isPackage);
|
|
@@ -29,7 +27,7 @@ const nxWritePackageTransform = (options) => (0, transform_1.transformFromPromis
|
|
|
29
27
|
if (!ngEntryPoint.isSecondaryEntryPoint) {
|
|
30
28
|
devkit_1.logger.log('Copying assets');
|
|
31
29
|
try {
|
|
32
|
-
|
|
30
|
+
await copyAssets(graph, entryPoint, ngPackageNode, angularVersion);
|
|
33
31
|
}
|
|
34
32
|
catch (error) {
|
|
35
33
|
throw error;
|
|
@@ -41,17 +39,22 @@ const nxWritePackageTransform = (options) => (0, transform_1.transformFromPromis
|
|
|
41
39
|
try {
|
|
42
40
|
devkit_1.logger.info('Writing package manifest');
|
|
43
41
|
const relativeUnixFromDestPath = (filePath) => (0, path_1.ensureUnixPath)(path.relative(ngEntryPoint.destinationPath, filePath));
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
await writePackageJson(ngEntryPoint, ngPackage, {
|
|
43
|
+
// backward compat for Angular < 16
|
|
44
|
+
...(angularVersion.major < 16
|
|
45
|
+
? {
|
|
46
|
+
module: relativeUnixFromDestPath(destinationFiles.esm2020),
|
|
47
|
+
es2020: relativeUnixFromDestPath(destinationFiles.esm2020),
|
|
48
|
+
esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),
|
|
49
|
+
}
|
|
50
|
+
: {
|
|
51
|
+
module: relativeUnixFromDestPath(destinationFiles.esm2022),
|
|
52
|
+
}),
|
|
53
|
+
typings: relativeUnixFromDestPath(destinationFiles.declarations),
|
|
54
|
+
exports: generatePackageExports(ngEntryPoint, graph, angularVersion),
|
|
53
55
|
// webpack v4+ specific flag to enable advanced optimizations and code splitting
|
|
54
|
-
sideEffects:
|
|
56
|
+
sideEffects: ngEntryPoint.packageJson.sideEffects ?? false,
|
|
57
|
+
}, !!options.watch);
|
|
55
58
|
}
|
|
56
59
|
catch (error) {
|
|
57
60
|
throw error;
|
|
@@ -63,94 +66,91 @@ const nxWritePackageTransform = (options) => (0, transform_1.transformFromPromis
|
|
|
63
66
|
// https://github.com/ng-packagr/ng-packagr/issues/2069
|
|
64
67
|
const primary = ngPackageNode.data.primary;
|
|
65
68
|
const packageJsonPath = path.join(primary.destinationPath, 'package.json');
|
|
66
|
-
if (
|
|
67
|
-
const packageJson = JSON.parse(
|
|
69
|
+
if (await (0, fs_1.exists)(packageJsonPath)) {
|
|
70
|
+
const packageJson = JSON.parse(await (0, fs_1.readFile)(packageJsonPath, { encoding: 'utf8' }));
|
|
68
71
|
packageJson.version = generateWatchVersion();
|
|
69
|
-
|
|
72
|
+
await (0, fs_1.writeFile)(path.join(primary.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
devkit_1.logger.info(`Built ${ngEntryPoint.moduleId}`);
|
|
73
76
|
return graph;
|
|
74
|
-
})
|
|
77
|
+
});
|
|
75
78
|
exports.nxWritePackageTransform = nxWritePackageTransform;
|
|
76
|
-
function copyAssets(graph, entryPointNode, ngPackageNode, angularVersion) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (typeof assetPath === 'object') {
|
|
90
|
-
asset = Object.assign({}, assetPath);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
const [isDir, isFile] = yield (0, fs_1.stat)(path.join(ngPackage.src, assetPath))
|
|
94
|
-
.then((stats) => [stats.isDirectory(), stats.isFile()])
|
|
95
|
-
.catch(() => [false, false]);
|
|
96
|
-
if (isDir) {
|
|
97
|
-
asset = { glob: '**/*', input: assetPath, output: assetPath };
|
|
98
|
-
}
|
|
99
|
-
else if (isFile) {
|
|
100
|
-
// filenames are their own glob
|
|
101
|
-
asset = {
|
|
102
|
-
glob: path.basename(assetPath),
|
|
103
|
-
input: path.dirname(assetPath),
|
|
104
|
-
output: path.dirname(assetPath),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
asset = { glob: assetPath, input: '/', output: '/' };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
asset.input = path.join(ngPackage.src, asset.input);
|
|
112
|
-
asset.output = path.join(ngPackage.dest, asset.output);
|
|
113
|
-
const isAncestorPath = (target, datum) => path.relative(datum, target).startsWith('..');
|
|
114
|
-
if (isAncestorPath(asset.input, ngPackage.src)) {
|
|
115
|
-
throw new Error('Cannot read assets from a location outside of the project root.');
|
|
116
|
-
}
|
|
117
|
-
if (isAncestorPath(asset.output, ngPackage.dest)) {
|
|
118
|
-
throw new Error('Cannot write assets to a location outside of the output path.');
|
|
119
|
-
}
|
|
120
|
-
assets.push(asset);
|
|
79
|
+
async function copyAssets(graph, entryPointNode, ngPackageNode, angularVersion) {
|
|
80
|
+
const ngPackage = ngPackageNode.data;
|
|
81
|
+
const globsForceIgnored = [
|
|
82
|
+
'.gitkeep',
|
|
83
|
+
'**/.DS_Store',
|
|
84
|
+
'**/Thumbs.db',
|
|
85
|
+
`${ngPackage.dest}/**`,
|
|
86
|
+
];
|
|
87
|
+
const assets = [];
|
|
88
|
+
for (const assetPath of ngPackage.assets) {
|
|
89
|
+
let asset;
|
|
90
|
+
if (typeof assetPath === 'object') {
|
|
91
|
+
asset = { ...assetPath };
|
|
121
92
|
}
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
93
|
+
else {
|
|
94
|
+
const [isDir, isFile] = await (0, fs_1.stat)(path.join(ngPackage.src, assetPath))
|
|
95
|
+
.then((stats) => [stats.isDirectory(), stats.isFile()])
|
|
96
|
+
.catch(() => [false, false]);
|
|
97
|
+
if (isDir) {
|
|
98
|
+
asset = { glob: '**/*', input: assetPath, output: assetPath };
|
|
99
|
+
}
|
|
100
|
+
else if (isFile) {
|
|
101
|
+
// filenames are their own glob
|
|
102
|
+
asset = {
|
|
103
|
+
glob: path.basename(assetPath),
|
|
104
|
+
input: path.dirname(assetPath),
|
|
105
|
+
output: path.dirname(assetPath),
|
|
106
|
+
};
|
|
133
107
|
}
|
|
134
108
|
else {
|
|
135
|
-
|
|
136
|
-
globOptions.onlyFiles = true;
|
|
137
|
-
globOptions.followSymbolicLinks = asset.followSymlinks;
|
|
109
|
+
asset = { glob: assetPath, input: '/', output: '/' };
|
|
138
110
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
111
|
+
}
|
|
112
|
+
asset.input = path.join(ngPackage.src, asset.input);
|
|
113
|
+
asset.output = path.join(ngPackage.dest, asset.output);
|
|
114
|
+
const isAncestorPath = (target, datum) => path.relative(datum, target).startsWith('..');
|
|
115
|
+
if (isAncestorPath(asset.input, ngPackage.src)) {
|
|
116
|
+
throw new Error('Cannot read assets from a location outside of the project root.');
|
|
117
|
+
}
|
|
118
|
+
if (isAncestorPath(asset.output, ngPackage.dest)) {
|
|
119
|
+
throw new Error('Cannot write assets to a location outside of the output path.');
|
|
120
|
+
}
|
|
121
|
+
assets.push(asset);
|
|
122
|
+
}
|
|
123
|
+
for (const asset of assets) {
|
|
124
|
+
const globOptions = {
|
|
125
|
+
cwd: asset.input,
|
|
126
|
+
ignore: [...(asset.ignore ?? []), ...globsForceIgnored],
|
|
127
|
+
dot: true,
|
|
128
|
+
};
|
|
129
|
+
if (angularVersion.major < 16) {
|
|
130
|
+
// versions lower than v16 support these properties
|
|
131
|
+
globOptions.cache = ngPackageNode.cache.globCache;
|
|
132
|
+
globOptions.nodir = true;
|
|
133
|
+
globOptions.follow = asset.followSymlinks;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// starting in v16 these properties are supported
|
|
137
|
+
globOptions.onlyFiles = true;
|
|
138
|
+
globOptions.followSymbolicLinks = asset.followSymlinks;
|
|
139
|
+
}
|
|
140
|
+
const filePaths = await (0, glob_1.globFiles)(asset.glob, globOptions);
|
|
141
|
+
for (const filePath of filePaths) {
|
|
142
|
+
const fileSrcFullPath = path.join(asset.input, filePath);
|
|
143
|
+
const fileDestFullPath = path.join(asset.output, filePath);
|
|
144
|
+
const nodeUri = (0, nodes_1.fileUrl)((0, path_1.ensureUnixPath)(fileSrcFullPath));
|
|
145
|
+
let node = graph.get(nodeUri);
|
|
146
|
+
if (!node) {
|
|
147
|
+
node = new node_1.Node(nodeUri);
|
|
148
|
+
graph.put(node);
|
|
151
149
|
}
|
|
150
|
+
entryPointNode.dependsOn(node);
|
|
151
|
+
await (0, fs_1.copyFile)(fileSrcFullPath, fileDestFullPath);
|
|
152
152
|
}
|
|
153
|
-
}
|
|
153
|
+
}
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Creates and writes a `package.json` file of the entry point used by the `node_module`
|
|
@@ -167,74 +167,77 @@ function copyAssets(graph, entryPointNode, ngPackageNode, angularVersion) {
|
|
|
167
167
|
* @param entryPoint An entry point of an Angular package / library
|
|
168
168
|
* @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`
|
|
169
169
|
*/
|
|
170
|
-
function writePackageJson(entryPoint, pkg, additionalProperties, isWatchMode) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
else if ((_c = packageJson.peerDependencies) === null || _c === void 0 ? void 0 : _c.tslib) {
|
|
193
|
-
devkit_1.logger.warn(`'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`);
|
|
194
|
-
packageJson.dependencies = Object.assign(Object.assign({}, (packageJson.dependencies || {})), { tslib: packageJson.peerDependencies.tslib });
|
|
195
|
-
delete packageJson.peerDependencies.tslib;
|
|
196
|
-
}
|
|
197
|
-
// Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts
|
|
198
|
-
// in the node_modules folder of an application
|
|
199
|
-
const allowedList = pkg.allowedNonPeerDependencies.map((value) => new RegExp(value));
|
|
200
|
-
try {
|
|
201
|
-
checkNonPeerDependencies(packageJson, 'dependencies', allowedList);
|
|
170
|
+
async function writePackageJson(entryPoint, pkg, additionalProperties, isWatchMode) {
|
|
171
|
+
// set additional properties
|
|
172
|
+
const packageJson = { ...entryPoint.packageJson, ...additionalProperties };
|
|
173
|
+
// read tslib version from `@angular/compiler` so that our tslib
|
|
174
|
+
// version at least matches that of angular if we use require('tslib').version
|
|
175
|
+
// it will get what installed and not the minimum version nor if it is a `~` or `^`
|
|
176
|
+
// this is only required for primary
|
|
177
|
+
if (isWatchMode) {
|
|
178
|
+
// Needed because of Webpack's 5 `cachemanagedpaths`
|
|
179
|
+
// https://github.com/angular/angular-cli/issues/20962
|
|
180
|
+
packageJson.version = generateWatchVersion();
|
|
181
|
+
}
|
|
182
|
+
if (!packageJson.peerDependencies?.tslib &&
|
|
183
|
+
!packageJson.dependencies?.tslib) {
|
|
184
|
+
const { peerDependencies: angularPeerDependencies = {}, dependencies: angularDependencies = {}, } = require('@angular/compiler/package.json');
|
|
185
|
+
const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;
|
|
186
|
+
if (tsLibVersion) {
|
|
187
|
+
packageJson.dependencies = {
|
|
188
|
+
...packageJson.dependencies,
|
|
189
|
+
tslib: tsLibVersion,
|
|
190
|
+
};
|
|
202
191
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
192
|
+
}
|
|
193
|
+
else if (packageJson.peerDependencies?.tslib) {
|
|
194
|
+
devkit_1.logger.warn(`'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`);
|
|
195
|
+
packageJson.dependencies = {
|
|
196
|
+
...(packageJson.dependencies || {}),
|
|
197
|
+
tslib: packageJson.peerDependencies.tslib,
|
|
198
|
+
};
|
|
199
|
+
delete packageJson.peerDependencies.tslib;
|
|
200
|
+
}
|
|
201
|
+
// Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts
|
|
202
|
+
// in the node_modules folder of an application
|
|
203
|
+
const allowedList = pkg.allowedNonPeerDependencies.map((value) => new RegExp(value));
|
|
204
|
+
try {
|
|
205
|
+
checkNonPeerDependencies(packageJson, 'dependencies', allowedList);
|
|
206
|
+
}
|
|
207
|
+
catch (e) {
|
|
208
|
+
await (0, fs_1.rmdir)(entryPoint.destinationPath, { recursive: true });
|
|
209
|
+
throw e;
|
|
210
|
+
}
|
|
211
|
+
// Removes scripts from package.json after build
|
|
212
|
+
if (packageJson.scripts) {
|
|
213
|
+
if (pkg.keepLifecycleScripts !== true) {
|
|
214
|
+
devkit_1.logger.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);
|
|
215
|
+
delete packageJson.scripts;
|
|
206
216
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (pkg.keepLifecycleScripts !== true) {
|
|
210
|
-
devkit_1.logger.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);
|
|
211
|
-
delete packageJson.scripts;
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
devkit_1.logger.warn(`You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`);
|
|
215
|
-
}
|
|
217
|
+
else {
|
|
218
|
+
devkit_1.logger.warn(`You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`);
|
|
216
219
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
220
|
+
}
|
|
221
|
+
// keep the dist package.json clean
|
|
222
|
+
// this will not throw if ngPackage field does not exist
|
|
223
|
+
delete packageJson.ngPackage;
|
|
224
|
+
const packageJsonPropertiesToDelete = [
|
|
225
|
+
'stylelint',
|
|
226
|
+
'prettier',
|
|
227
|
+
'browserslist',
|
|
228
|
+
'devDependencies',
|
|
229
|
+
'jest',
|
|
230
|
+
'workspaces',
|
|
231
|
+
'husky',
|
|
232
|
+
];
|
|
233
|
+
for (const prop of packageJsonPropertiesToDelete) {
|
|
234
|
+
if (prop in packageJson) {
|
|
235
|
+
delete packageJson[prop];
|
|
236
|
+
devkit_1.logger.info(`Removing ${prop} section in package.json.`);
|
|
234
237
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
}
|
|
239
|
+
packageJson.name = entryPoint.moduleId;
|
|
240
|
+
await (0, fs_1.writeFile)(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));
|
|
238
241
|
}
|
|
239
242
|
function checkNonPeerDependencies(packageJson, property, allowed) {
|
|
240
243
|
if (!packageJson[property]) {
|
|
@@ -256,8 +259,7 @@ function generatePackageExports({ destinationPath, packageJson }, graph, angular
|
|
|
256
259
|
? JSON.parse(JSON.stringify(packageJson.exports))
|
|
257
260
|
: {};
|
|
258
261
|
const insertMappingOrError = (subpath, mapping) => {
|
|
259
|
-
|
|
260
|
-
(_a = exports[subpath]) !== null && _a !== void 0 ? _a : (exports[subpath] = {});
|
|
262
|
+
exports[subpath] ??= {};
|
|
261
263
|
const subpathExport = exports[subpath];
|
|
262
264
|
// Go through all conditions that should be inserted. If the condition is already
|
|
263
265
|
// manually set of the subpath export, we throw an error. In general, we allow for
|
|
@@ -20,10 +20,13 @@ exports.nxProvideOptions = nxProvideOptions;
|
|
|
20
20
|
exports.NX_DEFAULT_OPTIONS_PROVIDER = (0, exports.nxProvideOptions)();
|
|
21
21
|
function normalizeOptions(options = {}) {
|
|
22
22
|
const ciEnv = process.env['CI'];
|
|
23
|
-
const isCI =
|
|
23
|
+
const isCI = ciEnv?.toLowerCase() === 'true' || ciEnv === '1';
|
|
24
24
|
const { cacheEnabled = !isCI, cacheDirectory = findCachePath() } = options;
|
|
25
|
-
return
|
|
26
|
-
|
|
25
|
+
return {
|
|
26
|
+
...options,
|
|
27
|
+
cacheEnabled,
|
|
28
|
+
cacheDirectory,
|
|
29
|
+
};
|
|
27
30
|
}
|
|
28
31
|
function findCachePath() {
|
|
29
32
|
const name = 'ng-packagr';
|