@nx/rollup 21.3.0-canary.20250626-8b6ad42 → 21.3.0-canary.20250628-7430238
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": "21.3.0-canary.
|
3
|
+
"version": "21.3.0-canary.20250628-7430238",
|
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": {
|
@@ -29,8 +29,8 @@
|
|
29
29
|
"migrations": "./migrations.json"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@nx/devkit": "21.3.0-canary.
|
33
|
-
"@nx/js": "21.3.0-canary.
|
32
|
+
"@nx/devkit": "21.3.0-canary.20250628-7430238",
|
33
|
+
"@nx/js": "21.3.0-canary.20250628-7430238",
|
34
34
|
"@rollup/plugin-babel": "^6.0.4",
|
35
35
|
"@rollup/plugin-commonjs": "^25.0.7",
|
36
36
|
"@rollup/plugin-image": "^3.0.3",
|
@@ -155,6 +155,11 @@
|
|
155
155
|
"sourceMap": {
|
156
156
|
"description": "Output sourcemaps.",
|
157
157
|
"type": "boolean"
|
158
|
+
},
|
159
|
+
"useLegacyTypescriptPlugin": {
|
160
|
+
"type": "boolean",
|
161
|
+
"description": "Use rollup-plugin-typescript2 instead of @rollup/plugin-typescript.",
|
162
|
+
"default": true
|
158
163
|
}
|
159
164
|
},
|
160
165
|
"required": ["tsConfig", "main", "outputPath"],
|
@@ -80,6 +80,10 @@ export interface RollupWithNxPluginOptions {
|
|
80
80
|
* The path to tsconfig file.
|
81
81
|
*/
|
82
82
|
tsConfig: string;
|
83
|
+
/**
|
84
|
+
* Use rollup-plugin-typescript2 instead of @rollup/plugin-typescript.
|
85
|
+
*/
|
86
|
+
useLegacyTypescriptPlugin?: boolean;
|
83
87
|
/**
|
84
88
|
* Whether to generate a package.json file in the output path. It's not supported when the workspace is
|
85
89
|
* set up with TypeScript Project References along with the package managers' Workspaces feature. Otherwise,
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withNx = withNx;
|
4
4
|
const node_fs_1 = require("node:fs");
|
5
5
|
const node_path_1 = require("node:path");
|
6
|
-
const ts = require("typescript");
|
7
6
|
const plugin_babel_1 = require("@rollup/plugin-babel");
|
8
7
|
const autoprefixer = require("autoprefixer");
|
9
8
|
const devkit_1 = require("@nx/devkit");
|
@@ -24,6 +23,18 @@ const json = require('@rollup/plugin-json');
|
|
24
23
|
const copy = require('rollup-plugin-copy');
|
25
24
|
const postcss = require('rollup-plugin-postcss');
|
26
25
|
const fileExtensions = ['.js', '.jsx', '.ts', '.tsx'];
|
26
|
+
let ts;
|
27
|
+
function ensureTypeScript() {
|
28
|
+
if (!ts) {
|
29
|
+
try {
|
30
|
+
ts = require('typescript');
|
31
|
+
}
|
32
|
+
catch (e) {
|
33
|
+
throw new Error('TypeScript is required for the @nx/rollup plugin. Please install it in your workspace.');
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return ts;
|
37
|
+
}
|
27
38
|
function withNx(rawOptions, rollupConfig = {},
|
28
39
|
// Passed by @nx/rollup:rollup executor to previous behavior of remapping tsconfig paths based on buildable dependencies remains intact.
|
29
40
|
dependencies) {
|
@@ -46,6 +57,7 @@ dependencies) {
|
|
46
57
|
const tsConfigPath = options.buildLibsFromSource || global.NX_GRAPH_CREATION
|
47
58
|
? (0, node_path_1.join)(devkit_1.workspaceRoot, options.tsConfig)
|
48
59
|
: (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, devkit_1.workspaceRoot, projectRoot, dependencies);
|
60
|
+
ensureTypeScript();
|
49
61
|
const tsConfigFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
50
62
|
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, (0, node_path_1.dirname)(tsConfigPath));
|
51
63
|
if (!options.format || !options.format.length) {
|
@@ -122,6 +134,8 @@ dependencies) {
|
|
122
134
|
};
|
123
135
|
}
|
124
136
|
if (!global.NX_GRAPH_CREATION) {
|
137
|
+
// Ensure TypeScript is available before any plugin initialization
|
138
|
+
ensureTypeScript();
|
125
139
|
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
126
140
|
if (isTsSolutionSetup) {
|
127
141
|
if (options.generatePackageJson) {
|
@@ -134,20 +148,50 @@ dependencies) {
|
|
134
148
|
else {
|
135
149
|
options.generatePackageJson ??= true;
|
136
150
|
}
|
151
|
+
const compilerOptions = createTsCompilerOptions(projectRoot, tsConfig, options, dependencies);
|
152
|
+
compilerOptions.outDir = Array.isArray(finalConfig.output)
|
153
|
+
? finalConfig.output[0].dir
|
154
|
+
: finalConfig.output.dir;
|
137
155
|
finalConfig.plugins = [
|
138
156
|
copy({
|
139
157
|
targets: convertCopyAssetsToRollupOptions(options.outputPath, options.assets),
|
140
158
|
}),
|
141
159
|
image(),
|
142
160
|
json(),
|
143
|
-
//
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
161
|
+
// TypeScript compilation and declaration generation
|
162
|
+
// TODO(v22): Change default value of useLegacyTypescriptPlugin to false for Nx 22
|
163
|
+
options.useLegacyTypescriptPlugin !== false
|
164
|
+
? (() => {
|
165
|
+
// TODO(v23): Remove in Nx 23
|
166
|
+
// Show deprecation warning
|
167
|
+
devkit_1.logger.warn(`rollup-plugin-typescript2 usage is deprecated and will be removed in Nx 23. ` +
|
168
|
+
`Set 'useLegacyTypescriptPlugin: false' to use the official @rollup/plugin-typescript.`);
|
169
|
+
return require('rollup-plugin-typescript2')({
|
170
|
+
check: !options.skipTypeCheck,
|
171
|
+
tsconfig: tsConfigPath,
|
172
|
+
tsconfigOverride: {
|
173
|
+
compilerOptions,
|
174
|
+
},
|
175
|
+
});
|
176
|
+
})()
|
177
|
+
: (() => {
|
178
|
+
// @rollup/plugin-typescript needs outDir and declarationDir to match Rollup's output directory
|
179
|
+
const { outDir, declarationDir, ...tsCompilerOptions } = compilerOptions;
|
180
|
+
const rollupOutputDir = Array.isArray(finalConfig.output)
|
181
|
+
? finalConfig.output[0].dir
|
182
|
+
: finalConfig.output.dir;
|
183
|
+
return require('@rollup/plugin-typescript')({
|
184
|
+
tsconfig: tsConfigPath,
|
185
|
+
compilerOptions: {
|
186
|
+
...tsCompilerOptions,
|
187
|
+
outDir: rollupOutputDir,
|
188
|
+
declarationDir: rollupOutputDir,
|
189
|
+
},
|
190
|
+
declaration: true,
|
191
|
+
declarationMap: !!options.sourceMap,
|
192
|
+
noEmitOnError: !options.skipTypeCheck,
|
193
|
+
});
|
194
|
+
})(),
|
151
195
|
(0, type_definitions_1.typeDefinitions)({
|
152
196
|
projectRoot,
|
153
197
|
}),
|
@@ -224,6 +268,7 @@ function createTsCompilerOptions(projectRoot, config, options, dependencies) {
|
|
224
268
|
declaration: true,
|
225
269
|
paths: compilerOptionPaths,
|
226
270
|
};
|
271
|
+
ensureTypeScript();
|
227
272
|
if (config.options.module === ts.ModuleKind.CommonJS) {
|
228
273
|
compilerOptions['module'] = 'ESNext';
|
229
274
|
}
|
@@ -241,6 +286,7 @@ function convertCopyAssetsToRollupOptions(outputPath, assets) {
|
|
241
286
|
: undefined;
|
242
287
|
}
|
243
288
|
function readCompatibleFormats(config) {
|
289
|
+
ensureTypeScript();
|
244
290
|
switch (config.options.module) {
|
245
291
|
case ts.ModuleKind.CommonJS:
|
246
292
|
case ts.ModuleKind.UMD:
|