@nx/angular 23.2.0-rc.2 → 23.2.1

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.
@@ -7,4 +7,8 @@
7
7
  * - Fake the FESM2022 outputs pointing them to the ESM2022 outputs.
8
8
  */
9
9
  import type { NgPackagrOptions } from 'ng-packagr/src/lib/ng-package/options.di';
10
+ import { type NgEntryPointType } from './entry-point';
10
11
  export declare const writeBundlesTransform: (_options: NgPackagrOptions) => import("ng-packagr/src/lib/graph/transform").Transform;
12
+ export declare function removeSourceMappingUrl(content: string): string;
13
+ export declare function remapDeclarationMapSources(originalPath: string, newPath: string, content: string): string;
14
+ export declare function normalizeEsm2022Path(path: string, entryPoint: NgEntryPointType): string;
@@ -9,9 +9,13 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.writeBundlesTransform = void 0;
12
+ exports.removeSourceMappingUrl = removeSourceMappingUrl;
13
+ exports.remapDeclarationMapSources = remapDeclarationMapSources;
14
+ exports.normalizeEsm2022Path = normalizeEsm2022Path;
12
15
  const transform_1 = require("ng-packagr/src/lib/graph/transform");
13
16
  const nodes_1 = require("ng-packagr/src/lib/ng-package/nodes");
14
17
  const package_1 = require("ng-packagr/src/lib/ng-package/package");
18
+ const path_1 = require("ng-packagr/src/lib/utils/path");
15
19
  const promises_1 = require("node:fs/promises");
16
20
  const node_path_1 = require("node:path");
17
21
  const entry_point_1 = require("./entry-point");
@@ -34,20 +38,47 @@ const writeBundlesTransform = (_options) => {
34
38
  const entryPoint = toCustomNgEntryPoint(entryPointNode.data.entryPoint);
35
39
  entryPointNode.data.entryPoint = entryPoint;
36
40
  entryPointNode.data.destinationFiles = entryPoint.destinationFiles;
41
+ // ngc builds the flat module file in memory and never writes it to disk, so
42
+ // the declaration map emitted for it points at a source that doesn't exist.
43
+ const flatModuleDeclarations = (0, node_path_1.normalize)(entryPointNode.data.destinationFiles.declarations);
44
+ const flatModuleDeclarationsMap = `${flatModuleDeclarations}.map`;
37
45
  for (const [path, outputCache,] of entryPointNode.cache.outputCache.entries()) {
46
+ const originalPath = (0, node_path_1.normalize)(path);
47
+ if (originalPath === flatModuleDeclarationsMap) {
48
+ continue;
49
+ }
38
50
  const normalizedPath = normalizeEsm2022Path(path, entryPoint);
51
+ let content = outputCache.content;
52
+ if (originalPath === flatModuleDeclarations) {
53
+ // its declaration map is dropped above, so don't leave a reference behind
54
+ content = removeSourceMappingUrl(content);
55
+ }
56
+ else if (normalizedPath.endsWith('.d.ts.map')) {
57
+ // declaration maps under tmp-typings land one directory up, so their
58
+ // source paths need rebasing
59
+ content = remapDeclarationMapSources(path, normalizedPath, content);
60
+ }
39
61
  // Only write if content has changed
40
- if (await shouldWriteFile(normalizedPath, outputCache.content)) {
62
+ if (await shouldWriteFile(normalizedPath, content)) {
41
63
  await (0, promises_1.mkdir)((0, node_path_1.dirname)(normalizedPath), { recursive: true });
42
- await (0, promises_1.writeFile)(normalizedPath, outputCache.content);
64
+ await (0, promises_1.writeFile)(normalizedPath, content);
43
65
  }
44
66
  }
45
67
  if (!entryPointNode.cache.outputCache.size &&
46
68
  entryPoint.isSecondaryEntryPoint) {
47
69
  await (0, promises_1.mkdir)(entryPoint.destinationPath, { recursive: true });
48
70
  }
49
- // Update package node only when processing the primary entry point
50
71
  if (!entryPoint.isSecondaryEntryPoint) {
72
+ // the primary manifest reads every entry point, so adjust any that have
73
+ // not been processed yet
74
+ for (const node of graph.filter((0, nodes_1.byEntryPoint)())) {
75
+ if (node === entryPointNode) {
76
+ continue;
77
+ }
78
+ const nodeEntryPoint = toCustomNgEntryPoint(node.data.entryPoint);
79
+ node.data.entryPoint = nodeEntryPoint;
80
+ node.data.destinationFiles = nodeEntryPoint.destinationFiles;
81
+ }
51
82
  const packageNode = graph.find(nodes_1.isPackage);
52
83
  if (packageNode) {
53
84
  packageNode.data = new package_1.NgPackage(packageNode.data.src, toCustomNgEntryPoint(packageNode.data.primary), packageNode.data.secondaries.map((secondary) => toCustomNgEntryPoint(secondary)));
@@ -56,16 +87,48 @@ const writeBundlesTransform = (_options) => {
56
87
  });
57
88
  };
58
89
  exports.writeBundlesTransform = writeBundlesTransform;
90
+ function removeSourceMappingUrl(content) {
91
+ return content.replace(/\/\/# sourceMappingURL=[^\r\n]*\s*$/, '');
92
+ }
93
+ function remapDeclarationMapSources(originalPath, newPath, content) {
94
+ const originalDir = (0, node_path_1.dirname)((0, node_path_1.normalize)(originalPath));
95
+ const newDir = (0, node_path_1.dirname)((0, node_path_1.normalize)(newPath));
96
+ if (originalDir === newDir) {
97
+ return content;
98
+ }
99
+ let map;
100
+ try {
101
+ map = JSON.parse(content);
102
+ }
103
+ catch {
104
+ return content;
105
+ }
106
+ if (!map || typeof map !== 'object' || !Array.isArray(map.sources)) {
107
+ return content;
108
+ }
109
+ // ng-packagr forces `sourceRoot: ''`, so sources are relative to the map file.
110
+ // A non-empty root is prepended to each source, so rebasing them alone is wrong.
111
+ if (map.sourceRoot) {
112
+ return content;
113
+ }
114
+ map.sources = map.sources.map((source) => typeof source === 'string'
115
+ ? (0, path_1.ensureUnixPath)((0, node_path_1.relative)(newDir, (0, node_path_1.resolve)(originalDir, source)))
116
+ : source);
117
+ return JSON.stringify(map);
118
+ }
59
119
  function normalizeEsm2022Path(path, entryPoint) {
60
120
  const normalizedPath = (0, node_path_1.normalize)(path);
61
121
  if (!entryPoint.primaryDestinationPath) {
62
122
  return normalizedPath;
63
123
  }
64
- if (normalizedPath.startsWith((0, node_path_1.join)(entryPoint.primaryDestinationPath, 'tmp-esm2022'))) {
65
- return normalizedPath.replace('tmp-esm2022', 'esm2022');
124
+ // rewrite only below the destination path, which may itself contain the segment
125
+ const tmpEsm2022Dir = (0, node_path_1.join)(entryPoint.primaryDestinationPath, 'tmp-esm2022') + node_path_1.sep;
126
+ if (normalizedPath.startsWith(tmpEsm2022Dir)) {
127
+ return (0, node_path_1.join)(entryPoint.primaryDestinationPath, 'esm2022', normalizedPath.slice(tmpEsm2022Dir.length));
66
128
  }
67
- if (normalizedPath.startsWith((0, node_path_1.join)(entryPoint.primaryDestinationPath, 'tmp-typings'))) {
68
- return normalizedPath.replace('tmp-typings', '');
129
+ const tmpTypingsDir = (0, node_path_1.join)(entryPoint.primaryDestinationPath, 'tmp-typings') + node_path_1.sep;
130
+ if (normalizedPath.startsWith(tmpTypingsDir)) {
131
+ return (0, node_path_1.join)(entryPoint.primaryDestinationPath, normalizedPath.slice(tmpTypingsDir.length));
69
132
  }
70
133
  return normalizedPath;
71
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "23.2.0-rc.2",
3
+ "version": "23.2.1",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Playwright and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
@@ -79,15 +79,15 @@
79
79
  "picomatch": "4.0.4",
80
80
  "semver": "^7.6.3",
81
81
  "tslib": "^2.3.0",
82
- "@nx/devkit": "23.2.0-rc.2",
83
- "@nx/eslint": "23.2.0-rc.2",
84
- "@nx/js": "23.2.0-rc.2",
85
- "@nx/web": "23.2.0-rc.2"
82
+ "@nx/js": "23.2.1",
83
+ "@nx/web": "23.2.1",
84
+ "@nx/devkit": "23.2.1",
85
+ "@nx/eslint": "23.2.1"
86
86
  },
87
87
  "devDependencies": {
88
- "@nx/storybook": "23.2.0-rc.2",
89
- "@nx/vitest": "23.2.0-rc.2",
90
- "nx": "23.2.0-rc.2"
88
+ "@nx/storybook": "23.2.1",
89
+ "@nx/vitest": "23.2.1",
90
+ "nx": "23.2.1"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@angular/build": ">= 20.0.0 < 23.0.0",
@@ -98,11 +98,11 @@
98
98
  "ng-packagr": ">= 20.0.0 < 23.0.0",
99
99
  "rxjs": "^6.5.3 || ^7.5.0",
100
100
  "webpack-merge": "^5.8.0",
101
- "@nx/cypress": "23.2.0-rc.2",
102
- "@nx/playwright": "23.2.0-rc.2",
103
- "@nx/module-federation": "23.2.0-rc.2",
104
- "@nx/webpack": "23.2.0-rc.2",
105
- "@nx/rspack": "23.2.0-rc.2"
101
+ "@nx/cypress": "23.2.1",
102
+ "@nx/playwright": "23.2.1",
103
+ "@nx/rspack": "23.2.1",
104
+ "@nx/module-federation": "23.2.1",
105
+ "@nx/webpack": "23.2.1"
106
106
  },
107
107
  "peerDependenciesMeta": {
108
108
  "@angular/build": {