@nx/rollup 16.8.0-beta.4 → 16.8.0-beta.6
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 +5 -5
- package/src/executors/rollup/lib/normalize.js +19 -10
- package/src/executors/rollup/lib/update-package-json.js +34 -8
- package/src/executors/rollup/rollup.impl.js +64 -70
- package/src/generators/configuration/configuration.js +30 -22
- package/src/generators/init/init.js +20 -23
- package/src/migrations/update-15-0-0/add-babel-inputs.js +3 -6
- 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-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag.js +10 -13
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +19 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rollup",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.6",
|
|
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,9 +29,9 @@
|
|
|
29
29
|
"migrations": "./migrations.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@nrwl/rollup": "16.8.0-beta.
|
|
33
|
-
"@nx/devkit": "16.8.0-beta.
|
|
34
|
-
"@nx/js": "16.8.0-beta.
|
|
32
|
+
"@nrwl/rollup": "16.8.0-beta.6",
|
|
33
|
+
"@nx/devkit": "16.8.0-beta.6",
|
|
34
|
+
"@nx/js": "16.8.0-beta.6",
|
|
35
35
|
"@rollup/plugin-babel": "^5.3.0",
|
|
36
36
|
"@rollup/plugin-commonjs": "^20.0.0",
|
|
37
37
|
"@rollup/plugin-image": "^2.1.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"type": "commonjs",
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "0cc6ba996f2ef09f00b932c8eacf42de642457f3"
|
|
58
58
|
}
|
|
@@ -17,18 +17,25 @@ function normalizeRollupExecutorOptions(options, context, sourceRoot) {
|
|
|
17
17
|
if (options.buildableProjectDepsInPackageJsonType == undefined) {
|
|
18
18
|
options.buildableProjectDepsInPackageJsonType = 'peerDependencies';
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
...options,
|
|
21
22
|
// de-dupe formats
|
|
22
|
-
format: Array.from(new Set(options.format)),
|
|
23
|
+
format: Array.from(new Set(options.format)),
|
|
24
|
+
rollupConfig: []
|
|
23
25
|
.concat(options.rollupConfig)
|
|
24
26
|
.filter(Boolean)
|
|
25
|
-
.map((p) => normalizePluginPath(p, root)),
|
|
27
|
+
.map((p) => normalizePluginPath(p, root)),
|
|
28
|
+
assets: options.assets
|
|
26
29
|
? normalizeAssets(options.assets, root, sourceRoot)
|
|
27
|
-
: undefined,
|
|
30
|
+
: undefined,
|
|
31
|
+
main,
|
|
28
32
|
entryRoot,
|
|
29
33
|
project,
|
|
30
34
|
projectRoot,
|
|
31
|
-
outputPath,
|
|
35
|
+
outputPath,
|
|
36
|
+
skipTypeCheck: options.skipTypeCheck || false,
|
|
37
|
+
additionalEntryPoints: createEntryPoints(options, context),
|
|
38
|
+
};
|
|
32
39
|
}
|
|
33
40
|
exports.normalizeRollupExecutorOptions = normalizeRollupExecutorOptions;
|
|
34
41
|
function normalizePluginPath(pluginPath, root) {
|
|
@@ -38,7 +45,7 @@ function normalizePluginPath(pluginPath, root) {
|
|
|
38
45
|
try {
|
|
39
46
|
return require.resolve(pluginPath);
|
|
40
47
|
}
|
|
41
|
-
catch
|
|
48
|
+
catch {
|
|
42
49
|
return (0, path_1.resolve)(root, pluginPath);
|
|
43
50
|
}
|
|
44
51
|
}
|
|
@@ -70,16 +77,18 @@ function normalizeAssets(assets, root, sourceRoot) {
|
|
|
70
77
|
}
|
|
71
78
|
const assetPath = (0, devkit_1.normalizePath)(asset.input);
|
|
72
79
|
const resolvedAssetPath = (0, path_1.resolve)(root, assetPath);
|
|
73
|
-
return
|
|
80
|
+
return {
|
|
81
|
+
...asset,
|
|
82
|
+
input: resolvedAssetPath,
|
|
74
83
|
// Now we remove starting slash to make Webpack place it from the output root.
|
|
75
|
-
output: asset.output.replace(/^\//, '')
|
|
84
|
+
output: asset.output.replace(/^\//, ''),
|
|
85
|
+
};
|
|
76
86
|
}
|
|
77
87
|
});
|
|
78
88
|
}
|
|
79
89
|
exports.normalizeAssets = normalizeAssets;
|
|
80
90
|
function createEntryPoints(options, context) {
|
|
81
|
-
|
|
82
|
-
if (!((_a = options.additionalEntryPoints) === null || _a === void 0 ? void 0 : _a.length))
|
|
91
|
+
if (!options.additionalEntryPoints?.length)
|
|
83
92
|
return [];
|
|
84
93
|
return (0, fast_glob_1.sync)(options.additionalEntryPoints, {
|
|
85
94
|
cwd: context.root,
|
|
@@ -4,34 +4,43 @@ exports.updatePackageJson = void 0;
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
6
6
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
9
|
// TODO(jack): Use updatePackageJson from @nx/js instead.
|
|
8
10
|
function updatePackageJson(options, context, target, dependencies, packageJson) {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
var _c;
|
|
11
11
|
const hasEsmFormat = options.format.includes('esm');
|
|
12
12
|
const hasCjsFormat = options.format.includes('cjs');
|
|
13
13
|
if (options.generateExportsField) {
|
|
14
14
|
packageJson.exports =
|
|
15
|
-
typeof packageJson.exports === 'string' ? {} :
|
|
15
|
+
typeof packageJson.exports === 'string' ? {} : { ...packageJson.exports };
|
|
16
16
|
packageJson.exports['./package.json'] = './package.json';
|
|
17
17
|
}
|
|
18
18
|
if (hasEsmFormat) {
|
|
19
|
-
const esmExports = getExports(
|
|
19
|
+
const esmExports = getExports({
|
|
20
|
+
...options,
|
|
21
|
+
fileExt: '.esm.js',
|
|
22
|
+
});
|
|
20
23
|
packageJson.module = esmExports['.'];
|
|
21
24
|
if (!hasCjsFormat) {
|
|
22
25
|
packageJson.type = 'module';
|
|
23
|
-
|
|
26
|
+
packageJson.main ??= esmExports['.'];
|
|
24
27
|
}
|
|
25
28
|
if (options.generateExportsField) {
|
|
26
29
|
for (const [exportEntry, filePath] of Object.entries(esmExports)) {
|
|
27
30
|
packageJson.exports[exportEntry] = hasCjsFormat
|
|
28
|
-
?
|
|
31
|
+
? // If CJS format is used, make sure `import` (from Node) points to same instance of the package.
|
|
32
|
+
// Otherwise, packages that are required to be singletons (like React, RxJS, etc.) will break.
|
|
33
|
+
// Reserve `module` entry for bundlers to accommodate tree-shaking.
|
|
34
|
+
{ [hasCjsFormat ? 'module' : 'import']: filePath }
|
|
29
35
|
: filePath;
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
if (hasCjsFormat) {
|
|
34
|
-
const cjsExports = getExports(
|
|
40
|
+
const cjsExports = getExports({
|
|
41
|
+
...options,
|
|
42
|
+
fileExt: '.cjs.js',
|
|
43
|
+
});
|
|
35
44
|
packageJson.main = cjsExports['.'];
|
|
36
45
|
if (!hasEsmFormat) {
|
|
37
46
|
packageJson.type = 'commonjs';
|
|
@@ -39,7 +48,24 @@ function updatePackageJson(options, context, target, dependencies, packageJson)
|
|
|
39
48
|
if (options.generateExportsField) {
|
|
40
49
|
for (const [exportEntry, filePath] of Object.entries(cjsExports)) {
|
|
41
50
|
if (hasEsmFormat) {
|
|
42
|
-
|
|
51
|
+
// If ESM format used, make sure `import` (from Node) points to a wrapped
|
|
52
|
+
// version of CJS file to ensure the package remains a singleton.
|
|
53
|
+
// TODO(jack): This can be made into a rollup plugin to re-use in Vite.
|
|
54
|
+
const relativeFile = (0, path_1.parse)(filePath).base;
|
|
55
|
+
const fauxEsmFilePath = filePath.replace(/\.cjs\.js$/, '.cjs.mjs');
|
|
56
|
+
packageJson.exports[exportEntry]['import'] ??= fauxEsmFilePath;
|
|
57
|
+
packageJson.exports[exportEntry]['default'] ??= filePath;
|
|
58
|
+
// Re-export from relative CJS file, and Node will synthetically export it as ESM.
|
|
59
|
+
// Make sure both ESM and CJS point to same instance of the package because libs like React, RxJS, etc. requires it.
|
|
60
|
+
// Also need a special .cjs.default.js file that re-exports the `default` from CJS, or else
|
|
61
|
+
// default import in Node will not work.
|
|
62
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.outputPath, filePath.replace(/\.cjs\.js$/, '.cjs.default.js')), `exports._default = require('./${(0, path_1.parse)(filePath).base}').default;`);
|
|
63
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.outputPath, fauxEsmFilePath),
|
|
64
|
+
// Re-export from relative CJS file, and Node will synthetically export it as ESM.
|
|
65
|
+
(0, devkit_1.stripIndents) `
|
|
66
|
+
export * from './${relativeFile}';
|
|
67
|
+
export { _default as default } from './${relativeFile.replace(/\.cjs\.js$/, '.cjs.default.js')}';
|
|
68
|
+
`);
|
|
43
69
|
}
|
|
44
70
|
else {
|
|
45
71
|
packageJson.exports[exportEntry] = filePath;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRollupOptions = exports.rollupExecutor = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const ts = require("typescript");
|
|
6
5
|
const rollup = require("rollup");
|
|
7
6
|
const peerDepsExternal = require("rollup-plugin-peer-deps-external");
|
|
@@ -28,73 +27,69 @@ const json = require('@rollup/plugin-json');
|
|
|
28
27
|
const copy = require('rollup-plugin-copy');
|
|
29
28
|
const postcss = require('rollup-plugin-postcss');
|
|
30
29
|
const fileExtensions = ['.js', '.jsx', '.ts', '.tsx'];
|
|
31
|
-
function rollupExecutor(rawOptions, context) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Delete output path before bundling
|
|
70
|
-
if (options.deleteOutputPath) {
|
|
71
|
-
(0, fs_1.deleteOutputDir)(context.root, options.outputPath);
|
|
72
|
-
}
|
|
73
|
-
const start = process.hrtime.bigint();
|
|
74
|
-
return yield tslib_1.__await((0, rxjs_1.from)(rollupOptions)
|
|
75
|
-
.pipe((0, operators_1.concatMap)((opts) => (0, run_rollup_1.runRollup)(opts).pipe((0, operators_1.catchError)((e) => {
|
|
76
|
-
devkit_1.logger.error(`Error during bundle: ${e}`);
|
|
77
|
-
return (0, rxjs_1.of)({ success: false });
|
|
78
|
-
}))), (0, operators_1.scan)((acc, result) => {
|
|
79
|
-
if (!acc.success)
|
|
80
|
-
return acc;
|
|
81
|
-
return result;
|
|
82
|
-
}, { success: true, outfile }), (0, operators_1.last)(), (0, operators_1.tap)({
|
|
83
|
-
next: (result) => {
|
|
84
|
-
if (result.success) {
|
|
85
|
-
const end = process.hrtime.bigint();
|
|
86
|
-
const duration = `${(Number(end - start) / 1000000000).toFixed(2)}s`;
|
|
87
|
-
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies, packageJson);
|
|
88
|
-
devkit_1.logger.info(`⚡ Done in ${duration}`);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
devkit_1.logger.error(`Bundle failed: ${context.projectName}`);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
}))
|
|
95
|
-
.toPromise());
|
|
30
|
+
async function* rollupExecutor(rawOptions, context) {
|
|
31
|
+
process.env.NODE_ENV ??= 'production';
|
|
32
|
+
const project = context.projectsConfigurations.projects[context.projectName];
|
|
33
|
+
const sourceRoot = project.sourceRoot;
|
|
34
|
+
const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName, true);
|
|
35
|
+
const options = (0, normalize_1.normalizeRollupExecutorOptions)(rawOptions, context, sourceRoot);
|
|
36
|
+
const packageJson = (0, devkit_1.readJsonFile)(options.project);
|
|
37
|
+
const npmDeps = (context.projectGraph.dependencies[context.projectName] ?? [])
|
|
38
|
+
.filter((d) => d.target.startsWith('npm:'))
|
|
39
|
+
.map((d) => d.target.slice(4));
|
|
40
|
+
const rollupOptions = createRollupOptions(options, dependencies, context, packageJson, sourceRoot, npmDeps);
|
|
41
|
+
const outfile = resolveOutfile(context, options);
|
|
42
|
+
if (options.watch) {
|
|
43
|
+
const watcher = rollup.watch(rollupOptions);
|
|
44
|
+
return yield* (0, rxjs_for_await_1.eachValueFrom)(new rxjs_1.Observable((obs) => {
|
|
45
|
+
watcher.on('event', (data) => {
|
|
46
|
+
if (data.code === 'START') {
|
|
47
|
+
devkit_1.logger.info(`Bundling ${context.projectName}...`);
|
|
48
|
+
}
|
|
49
|
+
else if (data.code === 'END') {
|
|
50
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies, packageJson);
|
|
51
|
+
devkit_1.logger.info('Bundle complete. Watching for file changes...');
|
|
52
|
+
obs.next({ success: true, outfile });
|
|
53
|
+
}
|
|
54
|
+
else if (data.code === 'ERROR') {
|
|
55
|
+
devkit_1.logger.error(`Error during bundle: ${data.error.message}`);
|
|
56
|
+
obs.next({ success: false });
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
// Teardown logic. Close watcher when unsubscribed.
|
|
60
|
+
return () => watcher.close();
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
devkit_1.logger.info(`Bundling ${context.projectName}...`);
|
|
65
|
+
// Delete output path before bundling
|
|
66
|
+
if (options.deleteOutputPath) {
|
|
67
|
+
(0, fs_1.deleteOutputDir)(context.root, options.outputPath);
|
|
96
68
|
}
|
|
97
|
-
|
|
69
|
+
const start = process.hrtime.bigint();
|
|
70
|
+
return (0, rxjs_1.from)(rollupOptions)
|
|
71
|
+
.pipe((0, operators_1.concatMap)((opts) => (0, run_rollup_1.runRollup)(opts).pipe((0, operators_1.catchError)((e) => {
|
|
72
|
+
devkit_1.logger.error(`Error during bundle: ${e}`);
|
|
73
|
+
return (0, rxjs_1.of)({ success: false });
|
|
74
|
+
}))), (0, operators_1.scan)((acc, result) => {
|
|
75
|
+
if (!acc.success)
|
|
76
|
+
return acc;
|
|
77
|
+
return result;
|
|
78
|
+
}, { success: true, outfile }), (0, operators_1.last)(), (0, operators_1.tap)({
|
|
79
|
+
next: (result) => {
|
|
80
|
+
if (result.success) {
|
|
81
|
+
const end = process.hrtime.bigint();
|
|
82
|
+
const duration = `${(Number(end - start) / 1000000000).toFixed(2)}s`;
|
|
83
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies, packageJson);
|
|
84
|
+
devkit_1.logger.info(`⚡ Done in ${duration}`);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
devkit_1.logger.error(`Bundle failed: ${context.projectName}`);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
}))
|
|
91
|
+
.toPromise();
|
|
92
|
+
}
|
|
98
93
|
}
|
|
99
94
|
exports.rollupExecutor = rollupExecutor;
|
|
100
95
|
// -----------------------------------------------------------------------------
|
|
@@ -251,10 +246,9 @@ function readCompatibleFormats(config) {
|
|
|
251
246
|
}
|
|
252
247
|
}
|
|
253
248
|
function resolveOutfile(context, options) {
|
|
254
|
-
|
|
255
|
-
if (!((_a = options.format) === null || _a === void 0 ? void 0 : _a.includes('cjs')))
|
|
249
|
+
if (!options.format?.includes('cjs'))
|
|
256
250
|
return undefined;
|
|
257
|
-
const { name } = (0, path_1.parse)(
|
|
251
|
+
const { name } = (0, path_1.parse)(options.outputFileName ?? options.main);
|
|
258
252
|
return (0, path_1.resolve)(context.root, options.outputPath, `${name}.cjs.js`);
|
|
259
253
|
}
|
|
260
254
|
exports.default = rollupExecutor;
|
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compat = exports.configurationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
7
6
|
const init_1 = require("../init/init");
|
|
8
|
-
function configurationGenerator(tree, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(_a = options.buildTarget) !== null && _a !== void 0 ? _a : (options.buildTarget = 'build');
|
|
13
|
-
checkForTargetConflicts(tree, options);
|
|
14
|
-
addBuildTarget(tree, options);
|
|
15
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
16
|
-
return task;
|
|
7
|
+
async function configurationGenerator(tree, options) {
|
|
8
|
+
const task = await (0, init_1.rollupInitGenerator)(tree, {
|
|
9
|
+
...options,
|
|
10
|
+
skipFormat: true,
|
|
17
11
|
});
|
|
12
|
+
options.buildTarget ??= 'build';
|
|
13
|
+
checkForTargetConflicts(tree, options);
|
|
14
|
+
addBuildTarget(tree, options);
|
|
15
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
16
|
+
return task;
|
|
18
17
|
}
|
|
19
18
|
exports.configurationGenerator = configurationGenerator;
|
|
20
19
|
function checkForTargetConflicts(tree, options) {
|
|
21
|
-
var _a;
|
|
22
20
|
if (options.skipValidation)
|
|
23
21
|
return;
|
|
24
22
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
25
|
-
if (
|
|
23
|
+
if (project.targets?.[options.buildTarget]) {
|
|
26
24
|
throw new Error(`Project "${options.project}" already has a ${options.buildTarget} target. Pass --skipValidation to ignore this error.`);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
function addBuildTarget(tree, options) {
|
|
30
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
31
28
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
32
29
|
const packageJsonPath = (0, devkit_1.joinPathFragments)(project.root, 'package.json');
|
|
33
30
|
if (!tree.exists(packageJsonPath)) {
|
|
@@ -37,14 +34,19 @@ function addBuildTarget(tree, options) {
|
|
|
37
34
|
version: '0.0.1',
|
|
38
35
|
});
|
|
39
36
|
}
|
|
40
|
-
const prevBuildOptions =
|
|
37
|
+
const prevBuildOptions = project.targets?.[options.buildTarget]?.options;
|
|
41
38
|
const buildOptions = {
|
|
42
|
-
main:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
main: options.main ??
|
|
40
|
+
prevBuildOptions?.main ??
|
|
41
|
+
(0, devkit_1.joinPathFragments)(project.root, 'src/main.ts'),
|
|
42
|
+
outputPath: prevBuildOptions?.outputPath ??
|
|
43
|
+
(0, devkit_1.joinPathFragments)('dist', project.root === '.' ? project.name : project.root),
|
|
44
|
+
tsConfig: options.tsConfig ??
|
|
45
|
+
prevBuildOptions?.tsConfig ??
|
|
46
|
+
(0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json'),
|
|
47
|
+
additionalEntryPoints: prevBuildOptions?.additionalEntryPoints,
|
|
48
|
+
generateExportsField: prevBuildOptions?.generateExportsField,
|
|
49
|
+
compiler: options.compiler ?? 'babel',
|
|
48
50
|
project: `${project.root}/package.json`,
|
|
49
51
|
external: options.external,
|
|
50
52
|
format: options.format,
|
|
@@ -61,7 +63,11 @@ function addBuildTarget(tree, options) {
|
|
|
61
63
|
},
|
|
62
64
|
];
|
|
63
65
|
}
|
|
64
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project,
|
|
66
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, {
|
|
67
|
+
...project,
|
|
68
|
+
targets: {
|
|
69
|
+
...project.targets,
|
|
70
|
+
[options.buildTarget]: {
|
|
65
71
|
executor: '@nx/rollup:rollup',
|
|
66
72
|
outputs: ['{options.outputPath}'],
|
|
67
73
|
defaultConfiguration: 'production',
|
|
@@ -75,7 +81,9 @@ function addBuildTarget(tree, options) {
|
|
|
75
81
|
vendorChunk: false,
|
|
76
82
|
},
|
|
77
83
|
},
|
|
78
|
-
}
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
79
87
|
}
|
|
80
88
|
exports.default = configurationGenerator;
|
|
81
89
|
exports.compat = (0, devkit_1.convertNxGenerator)(configurationGenerator);
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rollupInitSchematic = exports.rollupInitGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const versions_1 = require("@nx/js/src/utils/versions");
|
|
7
6
|
const versions_2 = require("../../utils/versions");
|
|
8
|
-
function rollupInitGenerator(tree, schema) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return task;
|
|
29
|
-
});
|
|
7
|
+
async function rollupInitGenerator(tree, schema) {
|
|
8
|
+
let task;
|
|
9
|
+
if (schema.compiler === 'swc') {
|
|
10
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
11
|
+
'@nx/rollup': versions_2.nxVersion,
|
|
12
|
+
'@swc/helpers': versions_1.swcHelpersVersion,
|
|
13
|
+
'@swc/core': versions_1.swcCoreVersion,
|
|
14
|
+
'swc-loader': versions_2.swcLoaderVersion,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
19
|
+
'@nx/rollup': versions_2.nxVersion,
|
|
20
|
+
tslib: versions_2.tsLibVersion,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (!schema.skipFormat) {
|
|
24
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
25
|
+
}
|
|
26
|
+
return task;
|
|
30
27
|
}
|
|
31
28
|
exports.rollupInitGenerator = rollupInitGenerator;
|
|
32
29
|
exports.default = rollupInitGenerator;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
|
|
6
|
-
function default_1(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function default_1(tree) {
|
|
6
|
+
(0, add_babel_inputs_1.addBabelInputs)(tree);
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = default_1;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
function replacePackage(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/rollup', '@nx/rollup');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = replacePackage;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function default_1(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
16
|
-
});
|
|
17
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
5
|
+
async function default_1(tree) {
|
|
6
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rollup:rollup', (options, projectName, targetName, _configurationName) => {
|
|
7
|
+
if (options.babelUpwardRootMode !== undefined) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
11
|
+
projectConfiguration.targets[targetName].options.babelUpwardRootMode =
|
|
12
|
+
true;
|
|
13
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
18
14
|
});
|
|
15
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
16
|
}
|
|
20
17
|
exports.default = default_1;
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executors = new Set(['@nx/rollup:rollup', '@nrwl/rollup:rollup']);
|
|
6
|
-
function default_1(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
async function default_1(tree) {
|
|
6
|
+
// use project graph to get the expanded target configurations
|
|
7
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
8
|
+
for (const [projectName, { data: projectData }] of Object.entries(projectGraph.nodes)) {
|
|
9
|
+
if (projectData.projectType !== 'library') {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
for (const [targetName, target] of Object.entries(projectData.targets || {})) {
|
|
13
|
+
if (!executors.has(target.executor)) {
|
|
14
14
|
continue;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
25
|
-
(_a = (_b = project.targets[targetName]).options) !== null && _a !== void 0 ? _a : (_b.options = {});
|
|
26
|
-
project.targets[targetName].options.updateBuildableProjectDepsInPackageJson = true;
|
|
27
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
28
|
-
}
|
|
16
|
+
if (!target.options ||
|
|
17
|
+
target.options.updateBuildableProjectDepsInPackageJson === undefined) {
|
|
18
|
+
// read the project configuration to write the explicit project configuration
|
|
19
|
+
// and avoid writing the expanded target configuration
|
|
20
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
21
|
+
project.targets[targetName].options ??= {};
|
|
22
|
+
project.targets[targetName].options.updateBuildableProjectDepsInPackageJson = true;
|
|
23
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
}
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
33
28
|
}
|
|
34
29
|
exports.default = default_1;
|