@nx/rollup 23.0.0-beta.17 → 23.0.0-beta.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/rollup",
3
- "version": "23.0.0-beta.17",
3
+ "version": "23.0.0-beta.19",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Rollup contains executors and generators that support building applications using Rollup.",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  "migrations": "./migrations.json"
31
31
  },
32
32
  "dependencies": {
33
- "@nx/devkit": "23.0.0-beta.17",
34
- "@nx/js": "23.0.0-beta.17",
33
+ "@nx/devkit": "23.0.0-beta.19",
34
+ "@nx/js": "23.0.0-beta.19",
35
35
  "@phenomnomnominal/tsquery": "~6.2.0",
36
36
  "@rollup/plugin-babel": "^6.0.4",
37
37
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -49,7 +49,7 @@
49
49
  "tslib": "^2.3.0"
50
50
  },
51
51
  "devDependencies": {
52
- "nx": "23.0.0-beta.17",
52
+ "nx": "23.0.0-beta.19",
53
53
  "source-map-js": "^1.2.0"
54
54
  },
55
55
  "publishConfig": {
@@ -1 +1 @@
1
- {"version":3,"file":"remove-use-legacy-typescript-plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/rollup/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EAIL,MAAM,YAAY,CAAC;AAgBpB,yBAA+B,IAAI,EAAE,IAAI,iBAyFxC"}
1
+ {"version":3,"file":"remove-use-legacy-typescript-plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/rollup/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EAIL,MAAM,YAAY,CAAC;AAgBpB,yBAA+B,IAAI,EAAE,IAAI,iBAwGxC"}
@@ -12,6 +12,10 @@ const ROLLUP_CONFIG_NAMES = [
12
12
  const PROPERTY_NAME = 'useLegacyTypescriptPlugin';
13
13
  async function default_1(tree) {
14
14
  const projects = (0, devkit_1.getProjects)(tree);
15
+ // Track whether the migration actually stripped any legacy config so we
16
+ // only strip the orphan devDep when it was needed (a user could have
17
+ // installed `rollup-plugin-typescript2` for their own custom rollup setup).
18
+ let anyChange = false;
15
19
  for (const [projectName] of projects) {
16
20
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
17
21
  let projectJsonChanged = false;
@@ -38,12 +42,15 @@ async function default_1(tree) {
38
42
  }
39
43
  if (projectJsonChanged) {
40
44
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
45
+ anyChange = true;
41
46
  }
42
47
  (0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
43
48
  const basename = filePath.split('/').pop();
44
49
  if (!ROLLUP_CONFIG_NAMES.includes(basename))
45
50
  return;
46
- stripFromRollupConfig(tree, filePath);
51
+ if (stripFromRollupConfig(tree, filePath)) {
52
+ anyChange = true;
53
+ }
47
54
  });
48
55
  }
49
56
  // Strip from nx.json targetDefaults (keyed by target name or executor name).
@@ -72,21 +79,27 @@ async function default_1(tree) {
72
79
  }
73
80
  if (nxJsonChanged) {
74
81
  (0, devkit_1.updateNxJson)(tree, nxJson);
82
+ anyChange = true;
75
83
  }
76
84
  }
85
+ // Only strip the orphan devDep when we actually stripped a legacy config.
86
+ // Skipping otherwise preserves a user's own dep on rollup-plugin-typescript2.
87
+ if (anyChange) {
88
+ (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['rollup-plugin-typescript2']);
89
+ }
77
90
  await (0, devkit_1.formatFiles)(tree);
78
91
  }
79
92
  function stripFromRollupConfig(tree, filePath) {
80
93
  const original = tree.read(filePath, 'utf-8');
81
94
  if (!original?.includes(PROPERTY_NAME))
82
- return;
95
+ return false;
83
96
  // Filter by the property NAME (not any descendant Identifier) so we don't
84
97
  // strip `{ alias: useLegacyTypescriptPlugin }` where the identifier appears as a value.
85
98
  // Also handle shorthand `{ useLegacyTypescriptPlugin }` — strip the entry, leave
86
99
  // the variable declaration behind (not our problem).
87
100
  const matches = (0, tsquery_1.query)((0, tsquery_1.ast)(original), 'PropertyAssignment, ShorthandPropertyAssignment').filter((p) => p.name && p.name.text === PROPERTY_NAME);
88
101
  if (matches.length === 0)
89
- return;
102
+ return false;
90
103
  // Walk in reverse so each splice doesn't shift the offsets of remaining matches
91
104
  // (a file may legitimately contain multiple withNx({...}) calls, e.g. multi-format
92
105
  // configs returning more than one rollup options object).
@@ -108,4 +121,5 @@ function stripFromRollupConfig(tree, filePath) {
108
121
  updated = updated.slice(0, start) + updated.slice(end);
109
122
  }
110
123
  tree.write(filePath, updated);
124
+ return true;
111
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/rollup/src/plugins/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,kBAAkB,EAGvB,aAAa,EAKd,MAAM,YAAY,CAAC;AASpB;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAMD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CAmC1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/rollup/src/plugins/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,kBAAkB,EAIvB,aAAa,EAKd,MAAM,YAAY,CAAC;AASpB;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAMD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CAgE1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
@@ -29,7 +29,27 @@ exports.createNodes = [
29
29
  const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
30
30
  const lockFileName = (0, js_1.getLockFileName)(packageManager);
31
31
  try {
32
- return await (0, devkit_1.createNodesFromFiles)((configFile, _, context) => createNodesInternal(configFile, normalizedOptions, context, targetsCache, isTsSolutionSetup, pmc, lockFileName), configFilePaths, normalizedOptions, context);
32
+ const { entries, preErrors } = await filterRollupConfigs(configFilePaths, context);
33
+ const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), normalizedOptions, context, entries.map(() => [lockFileName]));
34
+ let results = [];
35
+ let nodeErrors = [];
36
+ try {
37
+ results = await (0, devkit_1.createNodesFromFiles)((configFile, _, ctx, idx) => createNodesInternal(configFile, normalizedOptions, ctx, targetsCache, isTsSolutionSetup, pmc, projectHashes[idx]), entries.map((e) => e.configFile), normalizedOptions, context);
38
+ }
39
+ catch (e) {
40
+ if (e instanceof devkit_1.AggregateCreateNodesError) {
41
+ results = e.partialResults ?? [];
42
+ nodeErrors = e.errors;
43
+ }
44
+ else {
45
+ throw e;
46
+ }
47
+ }
48
+ const allErrors = [...preErrors, ...nodeErrors];
49
+ if (allErrors.length > 0) {
50
+ throw new devkit_1.AggregateCreateNodesError(allErrors, results);
51
+ }
52
+ return results;
33
53
  }
34
54
  finally {
35
55
  targetsCache.writeToDisk();
@@ -37,16 +57,8 @@ exports.createNodes = [
37
57
  },
38
58
  ];
39
59
  exports.createNodesV2 = exports.createNodes;
40
- async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc, lockFileName) {
60
+ async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc, hash) {
41
61
  const projectRoot = (0, path_1.dirname)(configFilePath);
42
- const fullyQualifiedProjectRoot = (0, path_1.join)(context.workspaceRoot, projectRoot);
43
- // Do not create a project if package.json and project.json do not exist
44
- const siblingFiles = (0, fs_1.readdirSync)(fullyQualifiedProjectRoot);
45
- if (!siblingFiles.includes('package.json') &&
46
- !siblingFiles.includes('project.json')) {
47
- return {};
48
- }
49
- const hash = await (0, internal_1.calculateHashForCreateNodes)(projectRoot, options, context, [lockFileName]);
50
62
  if (!targetsCache.has(hash)) {
51
63
  targetsCache.set(hash, await buildRollupTarget(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc));
52
64
  }
@@ -146,6 +158,28 @@ function getOutputs(rollupConfigs, projectRoot) {
146
158
  }
147
159
  return Array.from(outputs);
148
160
  }
161
+ async function filterRollupConfigs(configFiles, context) {
162
+ const preErrors = [];
163
+ const candidates = await Promise.all(configFiles.map(async (configFile) => {
164
+ try {
165
+ const projectRoot = (0, path_1.dirname)(configFile);
166
+ const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
167
+ if (!siblingFiles.includes('package.json') &&
168
+ !siblingFiles.includes('project.json')) {
169
+ return null;
170
+ }
171
+ return { configFile, projectRoot };
172
+ }
173
+ catch (e) {
174
+ preErrors.push([configFile, e]);
175
+ return null;
176
+ }
177
+ }));
178
+ return {
179
+ entries: candidates.filter((c) => c !== null),
180
+ preErrors,
181
+ };
182
+ }
149
183
  function normalizeOptions(options) {
150
184
  return {
151
185
  buildTargetName: options.buildTargetName ?? 'build',