@nx/rollup 23.0.0-beta.23 → 23.0.0-beta.24
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/{index.d.ts → dist/index.d.ts} +0 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +7 -0
- package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
- package/{src → dist/src}/executors/rollup/lib/normalize.d.ts +0 -1
- package/{src → dist/src}/executors/rollup/rollup.impl.d.ts +2 -3
- package/{src → dist/src}/executors/rollup/rollup.impl.js +2 -2
- package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/configuration.js +2 -0
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +2 -0
- package/{src → dist/src}/generators/convert-to-inferred/lib/add-plugin-registrations.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/normalize-path-options.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.js +8 -6
- package/{src → dist/src}/generators/init/schema.json +1 -1
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.d.ts +9 -0
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.js +134 -0
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md +25 -0
- package/{src → dist/src}/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.d.ts +0 -1
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +202 -0
- package/{src → dist/src}/plugins/analyze.d.ts +0 -1
- package/{src → dist/src}/plugins/delete-output.d.ts +0 -1
- package/{src → dist/src}/plugins/nx-copy-assets.plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/package-json/generate-package-json.d.ts +0 -1
- package/{src → dist/src}/plugins/package-json/update-package-json.d.ts +0 -1
- package/{src → dist/src}/plugins/plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/index.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/index.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/less-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/postcss-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/sass-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/stylus-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/types.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/options.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/postcss-plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/index.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/load-module.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/normalize-path.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/safe-identifier.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/style-inject.d.ts +0 -1
- package/{src → dist/src}/plugins/swc.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/get-project-node.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/normalize-options.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/type-definitions.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/with-nx-options.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/with-nx.d.ts +0 -1
- package/{src → dist/src}/utils/deprecation.d.ts +0 -1
- package/{src → dist/src}/utils/ensure-dependencies.d.ts +0 -1
- package/{src → dist/src}/utils/ensure-dependencies.js +3 -3
- package/{src → dist/src}/utils/fs.d.ts +0 -1
- package/{src → dist/src}/utils/has-plugin.d.ts +0 -1
- package/{src → dist/src}/utils/versions.d.ts +3 -1
- package/dist/src/utils/versions.js +18 -0
- package/{with-nx.d.ts → dist/with-nx.d.ts} +0 -1
- package/executors.json +2 -2
- package/generators.json +6 -6
- package/migrations.json +24 -3
- package/package.json +64 -10
- package/index.d.ts.map +0 -1
- package/plugin.d.ts.map +0 -1
- package/src/executors/rollup/lib/normalize.d.ts.map +0 -1
- package/src/executors/rollup/rollup.impl.d.ts.map +0 -1
- package/src/generators/configuration/configuration.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/add-plugin-registrations.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/normalize-path-options.d.ts.map +0 -1
- package/src/generators/init/init.d.ts.map +0 -1
- package/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.d.ts.map +0 -1
- package/src/plugins/analyze.d.ts.map +0 -1
- package/src/plugins/delete-output.d.ts.map +0 -1
- package/src/plugins/nx-copy-assets.plugin.d.ts.map +0 -1
- package/src/plugins/package-json/generate-package-json.d.ts.map +0 -1
- package/src/plugins/package-json/update-package-json.d.ts.map +0 -1
- package/src/plugins/plugin.d.ts.map +0 -1
- package/src/plugins/postcss/index.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/index.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/less-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/postcss-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/sass-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/stylus-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/types.d.ts.map +0 -1
- package/src/plugins/postcss/options.d.ts.map +0 -1
- package/src/plugins/postcss/postcss-plugin.d.ts.map +0 -1
- package/src/plugins/postcss/utils/index.d.ts.map +0 -1
- package/src/plugins/postcss/utils/load-module.d.ts.map +0 -1
- package/src/plugins/postcss/utils/normalize-path.d.ts.map +0 -1
- package/src/plugins/postcss/utils/safe-identifier.d.ts.map +0 -1
- package/src/plugins/postcss/utils/style-inject.d.ts.map +0 -1
- package/src/plugins/swc.d.ts.map +0 -1
- package/src/plugins/with-nx/get-project-node.d.ts.map +0 -1
- package/src/plugins/with-nx/normalize-options.d.ts.map +0 -1
- package/src/plugins/with-nx/type-definitions.d.ts.map +0 -1
- package/src/plugins/with-nx/with-nx-options.d.ts.map +0 -1
- package/src/plugins/with-nx/with-nx.d.ts.map +0 -1
- package/src/utils/deprecation.d.ts.map +0 -1
- package/src/utils/ensure-dependencies.d.ts.map +0 -1
- package/src/utils/fs.d.ts.map +0 -1
- package/src/utils/has-plugin.d.ts.map +0 -1
- package/src/utils/versions.d.ts.map +0 -1
- package/src/utils/versions.js +0 -8
- package/with-nx.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{plugin.js → dist/plugin.js} +0 -0
- /package/{src → dist/src}/executors/rollup/lib/normalize.js +0 -0
- /package/{src → dist/src}/executors/rollup/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/rollup/schema.json +0 -0
- /package/{src → dist/src}/generators/configuration/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/configuration/schema.json +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/add-plugin-registrations.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/normalize-path-options.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
- /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
- /package/{src → dist/src}/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.js +0 -0
- /package/{src → dist/src}/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.md +0 -0
- /package/{src → dist/src}/plugins/analyze.js +0 -0
- /package/{src → dist/src}/plugins/delete-output.js +0 -0
- /package/{src → dist/src}/plugins/nx-copy-assets.plugin.js +0 -0
- /package/{src → dist/src}/plugins/package-json/generate-package-json.js +0 -0
- /package/{src → dist/src}/plugins/package-json/update-package-json.js +0 -0
- /package/{src → dist/src}/plugins/plugin.js +0 -0
- /package/{src → dist/src}/plugins/postcss/index.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/index.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/less-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/postcss-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/sass-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/stylus-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/types.js +0 -0
- /package/{src → dist/src}/plugins/postcss/options.js +0 -0
- /package/{src → dist/src}/plugins/postcss/postcss-plugin.js +0 -0
- /package/{src → dist/src}/plugins/postcss/types/concat-with-sourcemaps.d.ts +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/index.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/load-module.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/normalize-path.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/safe-identifier.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/style-inject.js +0 -0
- /package/{src → dist/src}/plugins/swc.js +0 -0
- /package/{src → dist/src}/plugins/with-nx/get-project-node.js +0 -0
- /package/{src → dist/src}/plugins/with-nx/normalize-options.js +0 -0
- /package/{src → dist/src}/plugins/with-nx/type-definitions.js +0 -0
- /package/{src → dist/src}/plugins/with-nx/with-nx-options.js +0 -0
- /package/{src → dist/src}/plugins/with-nx/with-nx.js +0 -0
- /package/{src → dist/src}/utils/deprecation.js +0 -0
- /package/{src → dist/src}/utils/fs.js +0 -0
- /package/{src → dist/src}/utils/has-plugin.js +0 -0
- /package/{with-nx.js → dist/with-nx.js} +0 -0
|
@@ -5,4 +5,3 @@ export declare const rollupProjectGenerator: typeof configurationGenerator;
|
|
|
5
5
|
export * from './src/generators/init/init';
|
|
6
6
|
export type { AssetGlobPattern, Globals, RollupExecutorOptions, } from './src/executors/rollup/schema';
|
|
7
7
|
export * from './src/executors/rollup/rollup.impl';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { hasPlugin } from './src/utils/has-plugin';
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasPlugin = void 0;
|
|
4
|
+
// Curated internal API surface for other first-party Nx plugins. Prefer this
|
|
5
|
+
// over deep `@nx/rollup/src/*` imports — those are not part of the public API.
|
|
6
|
+
var has_plugin_1 = require("./src/utils/has-plugin");
|
|
7
|
+
Object.defineProperty(exports, "hasPlugin", { enumerable: true, get: function () { return has_plugin_1.hasPlugin; } });
|
|
@@ -6,4 +6,3 @@ export interface NormalizedRollupExecutorOptions extends RollupExecutorOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function normalizeRollupExecutorOptions(options: RollupExecutorOptions, context: ExecutorContext): NormalizedRollupExecutorOptions;
|
|
8
8
|
export declare function normalizePluginPath(pluginPath: void | string, root: string): string;
|
|
9
|
-
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import type * as Rollup from 'rollup';
|
|
2
2
|
import { type ExecutorContext } from '@nx/devkit';
|
|
3
3
|
import { RollupExecutorOptions } from './schema';
|
|
4
4
|
import { NormalizedRollupExecutorOptions } from './lib/normalize';
|
|
5
5
|
export declare function rollupExecutor(rawOptions: RollupExecutorOptions, context: ExecutorContext): AsyncGenerator<unknown, any, any>;
|
|
6
|
-
export declare function createRollupOptions(options: NormalizedRollupExecutorOptions, context: ExecutorContext): Promise<
|
|
6
|
+
export declare function createRollupOptions(options: NormalizedRollupExecutorOptions, context: ExecutorContext): Promise<Rollup.RollupOptions | Rollup.RollupOptions[]>;
|
|
7
7
|
export default rollupExecutor;
|
|
8
|
-
//# sourceMappingURL=rollup.impl.d.ts.map
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rollupExecutor = rollupExecutor;
|
|
4
4
|
exports.createRollupOptions = createRollupOptions;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const rollup = tslib_1.__importStar(require("rollup"));
|
|
7
5
|
const path_1 = require("path");
|
|
8
6
|
const devkit_1 = require("@nx/devkit");
|
|
9
7
|
const internal_1 = require("@nx/devkit/internal");
|
|
@@ -14,6 +12,8 @@ const internal_2 = require("@nx/js/internal");
|
|
|
14
12
|
const deprecation_1 = require("../../utils/deprecation");
|
|
15
13
|
async function* rollupExecutor(rawOptions, context) {
|
|
16
14
|
(0, deprecation_1.warnRollupExecutorDeprecation)();
|
|
15
|
+
// Lazy-loaded: `rollup` is an optional peer, absent at project-graph discovery time.
|
|
16
|
+
const rollup = require('rollup');
|
|
17
17
|
process.env.NODE_ENV ??= 'production';
|
|
18
18
|
const options = (0, normalize_1.normalizeRollupExecutorOptions)(rawOptions, context);
|
|
19
19
|
const rollupOptions = await createRollupOptions(options, context);
|
|
@@ -2,4 +2,3 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
|
2
2
|
import { RollupProjectSchema } from './schema';
|
|
3
3
|
export declare function configurationGenerator(tree: Tree, options: RollupProjectSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export default configurationGenerator;
|
|
5
|
-
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -10,9 +10,11 @@ const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
|
10
10
|
const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
11
11
|
const has_plugin_1 = require("../../utils/has-plugin");
|
|
12
12
|
const deprecation_1 = require("../../utils/deprecation");
|
|
13
|
+
const versions_1 = require("../../utils/versions");
|
|
13
14
|
const init_1 = require("../init/init");
|
|
14
15
|
let ts;
|
|
15
16
|
async function configurationGenerator(tree, options) {
|
|
17
|
+
(0, versions_1.assertSupportedRollupVersion)(tree);
|
|
16
18
|
const tasks = [];
|
|
17
19
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
18
20
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
@@ -5,7 +5,9 @@ const internal_1 = require("@nx/devkit/internal");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const extract_rollup_config_from_executor_options_1 = require("./lib/extract-rollup-config-from-executor-options");
|
|
7
7
|
const add_plugin_registrations_1 = require("./lib/add-plugin-registrations");
|
|
8
|
+
const versions_1 = require("../../utils/versions");
|
|
8
9
|
async function convertToInferred(tree, options) {
|
|
10
|
+
(0, versions_1.assertSupportedRollupVersion)(tree);
|
|
9
11
|
const migratedProjects = new Map();
|
|
10
12
|
let projects = (0, devkit_1.getProjects)(tree);
|
|
11
13
|
(0, internal_1.forEachExecutorOptions)(tree, '@nx/rollup:rollup', (_, projectName, targetName, configurationName) => {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
2
2
|
export declare function addPluginRegistrations<T>(tree: Tree, projectTargets: Map<string, T>, projects: Map<string, ProjectConfiguration>, pluginPath: string): Promise<void>;
|
|
3
|
-
//# sourceMappingURL=add-plugin-registrations.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { RollupExecutorOptions } from '../../../executors/rollup/schema';
|
|
3
3
|
export declare function extractRollupConfigFromExecutorOptions(tree: Tree, options: RollupExecutorOptions, configurations: Record<string, Partial<RollupExecutorOptions>>, projectRoot: string): Record<string, unknown>;
|
|
4
|
-
//# sourceMappingURL=extract-rollup-config-from-executor-options.d.ts.map
|
|
@@ -6,18 +6,20 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const versions_1 = require("../../utils/versions");
|
|
7
7
|
const plugin_1 = require("../../plugins/plugin");
|
|
8
8
|
async function rollupInitGenerator(tree, schema) {
|
|
9
|
+
(0, versions_1.assertSupportedRollupVersion)(tree);
|
|
9
10
|
let task = () => { };
|
|
10
11
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
11
12
|
schema.addPlugin ??=
|
|
12
13
|
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
13
14
|
nxJson.useInferencePlugins !== false;
|
|
14
15
|
if (!schema.skipPackageJson) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
// Rollup is a peer dependency, so ensure it is installed for both the
|
|
17
|
+
// inferred-plugin (CLI) path and the executor (programmatic) path.
|
|
18
|
+
const devDependencies = {
|
|
19
|
+
'@nx/rollup': versions_1.nxVersion,
|
|
20
|
+
rollup: versions_1.rollupVersion,
|
|
21
|
+
};
|
|
22
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions ?? true);
|
|
21
23
|
}
|
|
22
24
|
if (schema.addPlugin) {
|
|
23
25
|
await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rollup/plugin', plugin_1.createNodesV2, {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export default function migrateCreateNodesV2ToCreateNodes(tree: Tree): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
|
|
5
|
+
* when they come from one of the given module specifiers. Only the named
|
|
6
|
+
* bindings are touched — the module specifier, the `import`/`export` keyword,
|
|
7
|
+
* any `type` modifier, and any default import are left untouched.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rewriteCreateNodesV2Imports(source: string, specifiers: ReadonlySet<string>): string;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateCreateNodesV2ToCreateNodes;
|
|
4
|
+
exports.rewriteCreateNodesV2Imports = rewriteCreateNodesV2Imports;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
|
|
7
|
+
const DEPRECATED_NAME = 'createNodesV2';
|
|
8
|
+
const CANONICAL_NAME = 'createNodes';
|
|
9
|
+
// Module specifiers from which `@nx/rollup` publicly exposes `createNodesV2`.
|
|
10
|
+
// A named import or re-export of `createNodesV2` from one of these is rewritten
|
|
11
|
+
// to the canonical `createNodes` export.
|
|
12
|
+
const TARGET_SPECIFIERS = new Set(['@nx/rollup/plugin']);
|
|
13
|
+
let ts;
|
|
14
|
+
async function migrateCreateNodesV2ToCreateNodes(tree) {
|
|
15
|
+
let touchedCount = 0;
|
|
16
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
17
|
+
if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const original = tree.read(filePath, 'utf-8');
|
|
21
|
+
if (!original || !original.includes(DEPRECATED_NAME)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const updated = rewriteCreateNodesV2Imports(original, TARGET_SPECIFIERS);
|
|
25
|
+
if (updated !== original) {
|
|
26
|
+
tree.write(filePath, updated);
|
|
27
|
+
touchedCount += 1;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (touchedCount > 0) {
|
|
31
|
+
devkit_1.logger.info(`Renamed \`${DEPRECATED_NAME}\` imports to \`${CANONICAL_NAME}\` in ${touchedCount} file(s).`);
|
|
32
|
+
}
|
|
33
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
|
|
37
|
+
* when they come from one of the given module specifiers. Only the named
|
|
38
|
+
* bindings are touched — the module specifier, the `import`/`export` keyword,
|
|
39
|
+
* any `type` modifier, and any default import are left untouched.
|
|
40
|
+
*/
|
|
41
|
+
function rewriteCreateNodesV2Imports(source, specifiers) {
|
|
42
|
+
ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
|
|
43
|
+
const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
|
|
44
|
+
/* setParentNodes */ true, ts.ScriptKind.TSX);
|
|
45
|
+
const changes = [];
|
|
46
|
+
for (const stmt of sourceFile.statements) {
|
|
47
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
48
|
+
collectImportRewrite(sourceFile, stmt, specifiers, changes);
|
|
49
|
+
}
|
|
50
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
51
|
+
collectExportRewrite(sourceFile, stmt, specifiers, changes);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
|
|
55
|
+
}
|
|
56
|
+
function isTargetSpecifier(node, specifiers) {
|
|
57
|
+
return ts.isStringLiteral(node) && specifiers.has(node.text);
|
|
58
|
+
}
|
|
59
|
+
function collectImportRewrite(sourceFile, stmt, specifiers, changes) {
|
|
60
|
+
if (!isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const namedBindings = stmt.importClause?.namedBindings;
|
|
64
|
+
// Only `import { ... }` carries renameable named bindings. `import x`,
|
|
65
|
+
// `import * as ns`, and side-effect imports reference the module wholesale
|
|
66
|
+
// and keep working through the `createNodesV2` runtime alias, so we leave
|
|
67
|
+
// them be. A mixed `import def, { createNodesV2 }` still has its named
|
|
68
|
+
// bindings rewritten below — the default binding is untouched.
|
|
69
|
+
if (!namedBindings || !ts.isNamedImports(namedBindings)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
rewriteNamedBindings(sourceFile, namedBindings, changes);
|
|
73
|
+
}
|
|
74
|
+
function collectExportRewrite(sourceFile, stmt, specifiers, changes) {
|
|
75
|
+
if (!stmt.moduleSpecifier ||
|
|
76
|
+
!isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// `export { ... } from '...'` can be rewritten; `export * from '...'` has no
|
|
80
|
+
// named bindings to rename.
|
|
81
|
+
if (!stmt.exportClause || !ts.isNamedExports(stmt.exportClause)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
rewriteNamedBindings(sourceFile, stmt.exportClause, changes);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Re-renders the `{ ... }` of a named import/export, renaming any
|
|
88
|
+
* `createNodesV2` specifier to `createNodes`. If renaming would collide with a
|
|
89
|
+
* `createNodes` that is already present (e.g. `{ createNodes, createNodesV2 }`),
|
|
90
|
+
* the duplicate is dropped. Returns without recording a change when the binding
|
|
91
|
+
* list contains no `createNodesV2`.
|
|
92
|
+
*/
|
|
93
|
+
function rewriteNamedBindings(sourceFile, namedBindings, changes) {
|
|
94
|
+
const elements = namedBindings.elements;
|
|
95
|
+
const hasDeprecated = elements.some((el) => (el.propertyName ?? el.name).text === DEPRECATED_NAME);
|
|
96
|
+
if (!hasDeprecated) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const seen = new Set();
|
|
100
|
+
const rendered = [];
|
|
101
|
+
for (const el of elements) {
|
|
102
|
+
const text = renderSpecifier(el);
|
|
103
|
+
if (!seen.has(text)) {
|
|
104
|
+
seen.add(text);
|
|
105
|
+
rendered.push(text);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const start = namedBindings.getStart(sourceFile);
|
|
109
|
+
changes.push({
|
|
110
|
+
type: devkit_1.ChangeType.Delete,
|
|
111
|
+
start,
|
|
112
|
+
length: namedBindings.getEnd() - start,
|
|
113
|
+
}, {
|
|
114
|
+
type: devkit_1.ChangeType.Insert,
|
|
115
|
+
index: start,
|
|
116
|
+
text: `{ ${rendered.join(', ')} }`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function renderSpecifier(el) {
|
|
120
|
+
const typePrefix = el.isTypeOnly ? 'type ' : '';
|
|
121
|
+
const rename = (name) => name === DEPRECATED_NAME ? CANONICAL_NAME : name;
|
|
122
|
+
// `{ name }` — no alias, so the local binding follows the rename.
|
|
123
|
+
if (!el.propertyName) {
|
|
124
|
+
return `${typePrefix}${rename(el.name.text)}`;
|
|
125
|
+
}
|
|
126
|
+
// `{ propertyName as name }` — only the imported (left) side is renamed; the
|
|
127
|
+
// local alias is preserved. A now-redundant alias such as
|
|
128
|
+
// `createNodesV2 as createNodes` collapses to `createNodes`.
|
|
129
|
+
const canonicalImported = rename(el.propertyName.text);
|
|
130
|
+
const localName = el.name.text;
|
|
131
|
+
return canonicalImported === localName
|
|
132
|
+
? `${typePrefix}${localName}`
|
|
133
|
+
: `${typePrefix}${canonicalImported} as ${localName}`;
|
|
134
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#### Rename `createNodesV2` imports to `createNodes`
|
|
2
|
+
|
|
3
|
+
`@nx/rollup` renamed its primary inferred-plugin export from `createNodesV2` to `createNodes`. The `createNodesV2` name is preserved as a deprecated alias for now, but new code should use `createNodes`.
|
|
4
|
+
|
|
5
|
+
This migration scans every `.ts`, `.tsx`, `.cts`, and `.mts` file in your workspace and rewrites named imports and re-exports of `createNodesV2` from `@nx/rollup/plugin` to `createNodes`.
|
|
6
|
+
|
|
7
|
+
#### Sample Code Changes
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createNodesV2 } from '@nx/rollup/plugin';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
##### After
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createNodes } from '@nx/rollup/plugin';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Aliases are preserved (`createNodesV2 as cn` becomes `createNodes as cn`), and if a file already imports both names (`{ createNodes, createNodesV2 }`) the redundant binding is dropped.
|
|
22
|
+
|
|
23
|
+
#### What is not rewritten
|
|
24
|
+
|
|
25
|
+
Only static `import`/`export` named bindings from `@nx/rollup/plugin` are rewritten. Namespace imports, dynamic `import(...)`, `require(...)` destructuring, and property access such as `plugin.createNodesV2` are left untouched — they keep working through the `createNodesV2` runtime alias. Update those by hand if you want to drop the deprecated name everywhere.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = rewriteInternalSubpathImports;
|
|
4
|
+
exports.rewriteSubpathImports = rewriteSubpathImports;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
|
|
7
|
+
const FROM_PREFIX = '@nx/rollup/src/';
|
|
8
|
+
const TO_PUBLIC = '@nx/rollup';
|
|
9
|
+
const TO_INTERNAL = '@nx/rollup/internal';
|
|
10
|
+
// Symbols exported from `@nx/rollup`'s public entry (packages/rollup/index.ts).
|
|
11
|
+
// A named import/export of one of these from `@nx/rollup/src/*` is routed to
|
|
12
|
+
// the public `@nx/rollup` entry; everything else goes to `@nx/rollup/internal`.
|
|
13
|
+
const PUBLIC_SYMBOLS = new Set([
|
|
14
|
+
'AssetGlobPattern',
|
|
15
|
+
'Globals',
|
|
16
|
+
'RollupExecutorOptions',
|
|
17
|
+
'configurationGenerator',
|
|
18
|
+
'createRollupOptions',
|
|
19
|
+
'rollupExecutor',
|
|
20
|
+
'rollupInitGenerator',
|
|
21
|
+
'rollupProjectGenerator',
|
|
22
|
+
]);
|
|
23
|
+
// Methods on `jest` and `vi` that take a module specifier as their first arg.
|
|
24
|
+
const MOCK_HELPER_METHODS = new Set([
|
|
25
|
+
'mock',
|
|
26
|
+
'unmock',
|
|
27
|
+
'doMock',
|
|
28
|
+
'dontMock',
|
|
29
|
+
'requireActual',
|
|
30
|
+
'requireMock',
|
|
31
|
+
'importActual',
|
|
32
|
+
'importMock',
|
|
33
|
+
]);
|
|
34
|
+
let ts;
|
|
35
|
+
async function rewriteInternalSubpathImports(tree) {
|
|
36
|
+
let touchedCount = 0;
|
|
37
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
38
|
+
if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const original = tree.read(filePath, 'utf-8');
|
|
42
|
+
if (!original || !original.includes(FROM_PREFIX)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const updated = rewriteSubpathImports(original);
|
|
46
|
+
if (updated !== original) {
|
|
47
|
+
tree.write(filePath, updated);
|
|
48
|
+
touchedCount += 1;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (touchedCount > 0) {
|
|
52
|
+
devkit_1.logger.info(`Rewrote @nx/rollup/src/* imports in ${touchedCount} file(s) ` +
|
|
53
|
+
`(public symbols to @nx/rollup, internals to @nx/rollup/internal).`);
|
|
54
|
+
}
|
|
55
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
56
|
+
}
|
|
57
|
+
function rewriteSubpathImports(source) {
|
|
58
|
+
ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
|
|
59
|
+
const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
|
|
60
|
+
/* setParentNodes */ true, ts.ScriptKind.TSX);
|
|
61
|
+
const changes = [];
|
|
62
|
+
for (const stmt of sourceFile.statements) {
|
|
63
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
64
|
+
collectImportRewrite(sourceFile, stmt, changes);
|
|
65
|
+
}
|
|
66
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
67
|
+
collectExportRewrite(sourceFile, stmt, changes);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
collectCallExpressionRewrites(sourceFile, changes);
|
|
71
|
+
return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
|
|
72
|
+
}
|
|
73
|
+
function isSubpathSpecifier(node) {
|
|
74
|
+
return ts.isStringLiteral(node) && node.text.startsWith(FROM_PREFIX);
|
|
75
|
+
}
|
|
76
|
+
function collectImportRewrite(sourceFile, stmt, changes) {
|
|
77
|
+
if (!isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const clause = stmt.importClause;
|
|
81
|
+
// Pure named imports (`import { a, b } from '...'`) can be split by symbol.
|
|
82
|
+
// A default or namespace import grabs the whole module, so it can't be
|
|
83
|
+
// split — route it wholesale to the internal entry.
|
|
84
|
+
if (clause &&
|
|
85
|
+
!clause.name &&
|
|
86
|
+
clause.namedBindings &&
|
|
87
|
+
ts.isNamedImports(clause.namedBindings)) {
|
|
88
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, clause.isTypeOnly, clause.namedBindings.elements, 'import', changes);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
92
|
+
}
|
|
93
|
+
function collectExportRewrite(sourceFile, stmt, changes) {
|
|
94
|
+
if (!stmt.moduleSpecifier || !isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// `export { a, b } from '...'` can be split; `export * from '...'` cannot.
|
|
98
|
+
if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
|
|
99
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, stmt.isTypeOnly, stmt.exportClause.elements, 'export', changes);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Partition the named bindings of an import/export declaration into the ones
|
|
106
|
+
* that resolve to `@nx/rollup`'s public entry and the ones that don't. If both
|
|
107
|
+
* groups are non-empty, the single declaration is split into two.
|
|
108
|
+
*/
|
|
109
|
+
function rewriteNamedDeclaration(sourceFile, decl, specifier, isTypeOnly, elements, keyword, changes) {
|
|
110
|
+
const publicEls = [];
|
|
111
|
+
const internalEls = [];
|
|
112
|
+
for (const el of elements) {
|
|
113
|
+
// `propertyName` is the original name in `orig as alias`; fall back to
|
|
114
|
+
// `name` for the plain `orig` form.
|
|
115
|
+
const importedName = (el.propertyName ?? el.name).text;
|
|
116
|
+
(PUBLIC_SYMBOLS.has(importedName) ? publicEls : internalEls).push(el);
|
|
117
|
+
}
|
|
118
|
+
if (publicEls.length === 0) {
|
|
119
|
+
replaceSpecifier(sourceFile, specifier, TO_INTERNAL, changes);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (internalEls.length === 0) {
|
|
123
|
+
replaceSpecifier(sourceFile, specifier, TO_PUBLIC, changes);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// Mixed — replace the whole declaration with one statement per target.
|
|
127
|
+
const quote = sourceFile.text.charAt(specifier.getStart(sourceFile));
|
|
128
|
+
const start = decl.getStart(sourceFile);
|
|
129
|
+
const end = decl.getEnd();
|
|
130
|
+
const semicolon = sourceFile.text.charAt(end - 1) === ';' ? ';' : '';
|
|
131
|
+
const prefix = isTypeOnly ? `${keyword} type` : keyword;
|
|
132
|
+
const render = (els, target) => `${prefix} { ${els
|
|
133
|
+
.map((el) => el.getText(sourceFile))
|
|
134
|
+
.join(', ')} } from ${quote}${target}${quote}${semicolon}`;
|
|
135
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
136
|
+
type: devkit_1.ChangeType.Insert,
|
|
137
|
+
index: start,
|
|
138
|
+
text: `${render(publicEls, TO_PUBLIC)}\n${render(internalEls, TO_INTERNAL)}`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function collectCallExpressionRewrites(sourceFile, changes) {
|
|
142
|
+
const visit = (node) => {
|
|
143
|
+
if (ts.isCallExpression(node) &&
|
|
144
|
+
shouldRewriteCallExpression(node) &&
|
|
145
|
+
node.arguments.length >= 1 &&
|
|
146
|
+
isSubpathSpecifier(node.arguments[0])) {
|
|
147
|
+
// `require(...)`, dynamic `import(...)` and `jest.mock(...)` reference
|
|
148
|
+
// the module as a whole and can't be symbol-split, so they go to the
|
|
149
|
+
// internal entry.
|
|
150
|
+
replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
|
|
151
|
+
}
|
|
152
|
+
else if (ts.isImportTypeNode(node)) {
|
|
153
|
+
// `typeof import('...')` parses as an `ImportTypeNode`, not a
|
|
154
|
+
// CallExpression — its argument is `LiteralTypeNode<StringLiteral>`.
|
|
155
|
+
// The whole module is referenced, so it can't be symbol-split.
|
|
156
|
+
const literal = getImportTypeStringLiteral(node);
|
|
157
|
+
if (literal && literal.text.startsWith(FROM_PREFIX)) {
|
|
158
|
+
replaceSpecifier(sourceFile, literal, TO_INTERNAL, changes);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
ts.forEachChild(node, visit);
|
|
162
|
+
};
|
|
163
|
+
visit(sourceFile);
|
|
164
|
+
}
|
|
165
|
+
function getImportTypeStringLiteral(node) {
|
|
166
|
+
const arg = node.argument;
|
|
167
|
+
if (arg && ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal)) {
|
|
168
|
+
return arg.literal;
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
function shouldRewriteCallExpression(call) {
|
|
173
|
+
const callee = call.expression;
|
|
174
|
+
// `require('...')`
|
|
175
|
+
if (ts.isIdentifier(callee) && callee.text === 'require')
|
|
176
|
+
return true;
|
|
177
|
+
// dynamic `import('...')` (runtime form parses as a CallExpression whose
|
|
178
|
+
// callee is the `import` keyword). The `typeof import('...')` type-position
|
|
179
|
+
// form is an `ImportTypeNode` (handled in `collectCallExpressionRewrites`).
|
|
180
|
+
if (callee.kind === ts.SyntaxKind.ImportKeyword)
|
|
181
|
+
return true;
|
|
182
|
+
// `jest.mock(...)` / `vi.mock(...)` and friends.
|
|
183
|
+
if (ts.isPropertyAccessExpression(callee)) {
|
|
184
|
+
const obj = callee.expression;
|
|
185
|
+
if (ts.isIdentifier(obj) &&
|
|
186
|
+
(obj.text === 'jest' || obj.text === 'vi') &&
|
|
187
|
+
MOCK_HELPER_METHODS.has(callee.name.text)) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
function replaceSpecifier(sourceFile, literal, target, changes) {
|
|
194
|
+
const start = literal.getStart(sourceFile);
|
|
195
|
+
const end = literal.getEnd();
|
|
196
|
+
const quote = sourceFile.text.charAt(start);
|
|
197
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
198
|
+
type: devkit_1.ChangeType.Insert,
|
|
199
|
+
index: start,
|
|
200
|
+
text: `${quote}${target}${quote}`,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
@@ -11,4 +11,3 @@ export interface GeneratePackageJsonOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const pluginName = "rollup-plugin-nx-generate-package-json";
|
|
13
13
|
export declare function generatePackageJson(options: GeneratePackageJsonOptions, packageJson: PackageJson): Plugin;
|
|
14
|
-
//# sourceMappingURL=generate-package-json.d.ts.map
|
|
@@ -13,4 +13,3 @@
|
|
|
13
13
|
export { postcss } from './postcss-plugin';
|
|
14
14
|
export { postcss as default } from './postcss-plugin';
|
|
15
15
|
export type { PostCSSPluginOptions, PostCSSModulesOptions, FilterPattern, UseOptions, LessOptions, SassOptions, StylusOptions, } from './options';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -108,4 +108,3 @@ export interface NormalizedPostCSSOptions extends PostCSSPluginOptions {
|
|
|
108
108
|
* Normalize plugin options with defaults
|
|
109
109
|
*/
|
|
110
110
|
export declare function normalizeOptions(options?: PostCSSPluginOptions): NormalizedPostCSSOptions;
|
|
111
|
-
//# sourceMappingURL=options.d.ts.map
|
|
@@ -2,4 +2,3 @@ export { normalizePath, humanizePath } from './normalize-path';
|
|
|
2
2
|
export { loadModule, requireModule } from './load-module';
|
|
3
3
|
export { safeIdentifier, escapeClassNameDashes } from './safe-identifier';
|
|
4
4
|
export { styleInjectCode, STYLE_INJECT_ID, STYLE_INJECT_PATH, } from './style-inject';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|