@nx/rollup 0.0.0-pr-29176-d3c6c29 → 0.0.0-pr-29314-e664f92
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 +3 -3
- package/src/executors/rollup/lib/normalize.js +3 -1
- package/src/generators/configuration/configuration.js +1 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js +2 -2
- package/src/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.js +6 -2
- package/src/plugins/plugin.js +12 -5
- package/src/plugins/with-nx/normalize-options.js +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rollup",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29314-e664f92",
|
|
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": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"rollup-plugin-postcss": "^4.0.2",
|
|
44
44
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
45
45
|
"tslib": "^2.3.0",
|
|
46
|
-
"@nx/devkit": "0.0.0-pr-
|
|
47
|
-
"@nx/js": "0.0.0-pr-
|
|
46
|
+
"@nx/devkit": "0.0.0-pr-29314-e664f92",
|
|
47
|
+
"@nx/js": "0.0.0-pr-29314-e664f92"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeRollupExecutorOptions = normalizeRollupExecutorOptions;
|
|
4
4
|
exports.normalizePluginPath = normalizePluginPath;
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
7
|
function normalizeRollupExecutorOptions(options, context) {
|
|
7
8
|
const { root } = context;
|
|
9
|
+
const skipTypeCheck = (0, ts_solution_setup_1.isUsingTsSolutionSetup)() ? true : options.skipTypeCheck;
|
|
8
10
|
return {
|
|
9
11
|
...options,
|
|
10
12
|
rollupConfig: []
|
|
@@ -12,7 +14,7 @@ function normalizeRollupExecutorOptions(options, context) {
|
|
|
12
14
|
.filter(Boolean)
|
|
13
15
|
.map((p) => normalizePluginPath(p, root)),
|
|
14
16
|
projectRoot: context.projectGraph.nodes[context.projectName].data.root,
|
|
15
|
-
skipTypeCheck:
|
|
17
|
+
skipTypeCheck: skipTypeCheck || false,
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
function normalizePluginPath(pluginPath, root) {
|
|
@@ -58,7 +58,7 @@ function createRollupConfig(tree, options, isTsSolutionSetup) {
|
|
|
58
58
|
? `./${(0, posix_1.relative)(project.root, options.tsConfig)}`
|
|
59
59
|
: './tsconfig.lib.json',
|
|
60
60
|
};
|
|
61
|
-
tree.write((0, devkit_1.joinPathFragments)(project.root, 'rollup.config.
|
|
61
|
+
tree.write((0, devkit_1.joinPathFragments)(project.root, 'rollup.config.cjs'), `const { withNx } = require('@nx/rollup/with-nx');
|
|
62
62
|
|
|
63
63
|
module.exports = withNx(
|
|
64
64
|
{
|
|
@@ -47,11 +47,11 @@ async function convertToInferred(tree, options) {
|
|
|
47
47
|
// If users have this set erroneously, then it will continue to not work.
|
|
48
48
|
(target.outputs[0] === '{options.outputPath}' ||
|
|
49
49
|
target.outputs[0] === '{workspaceRoot}/{options.outputPath}')) {
|
|
50
|
-
// If only the default `options.outputPath` is set as output, remove it and use path inferred from `rollup.config.
|
|
50
|
+
// If only the default `options.outputPath` is set as output, remove it and use path inferred from `rollup.config.cjs`.
|
|
51
51
|
delete target.outputs;
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
// Otherwise, replace `options.outputPath` with what is inferred from `rollup.config.
|
|
54
|
+
// Otherwise, replace `options.outputPath` with what is inferred from `rollup.config.cjs`.
|
|
55
55
|
target.outputs = target.outputs.map((output) =>
|
|
56
56
|
// Again, "{projectRoot}/{options.outputPath}" is an invalid output for Rollup.
|
|
57
57
|
output === '{options.outputPath}' ||
|
package/src/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.js
CHANGED
|
@@ -17,9 +17,13 @@ function extractRollupConfigFromExecutorOptions(tree, options, configurations, p
|
|
|
17
17
|
? [options.rollupConfig]
|
|
18
18
|
: [];
|
|
19
19
|
delete options.rollupConfig;
|
|
20
|
-
// Resolve conflict with rollup.config.js if
|
|
20
|
+
// Resolve conflict with rollup.config.cjs or rollup.config.js if they exist.
|
|
21
21
|
for (let i = 0; i < oldRollupConfig.length; i++) {
|
|
22
22
|
const file = oldRollupConfig[i];
|
|
23
|
+
if (file === './rollup.config.cjs') {
|
|
24
|
+
tree.rename((0, devkit_1.joinPathFragments)(projectRoot, 'rollup.config.cjs'), (0, devkit_1.joinPathFragments)(projectRoot, `rollup.migrated.config.cjs`));
|
|
25
|
+
oldRollupConfig.splice(i, 1, './rollup.migrated.config.cjs');
|
|
26
|
+
}
|
|
23
27
|
if (file === './rollup.config.js') {
|
|
24
28
|
tree.rename((0, devkit_1.joinPathFragments)(projectRoot, 'rollup.config.js'), (0, devkit_1.joinPathFragments)(projectRoot, `rollup.migrated.config.js`));
|
|
25
29
|
oldRollupConfig.splice(i, 1, './rollup.migrated.config.js');
|
|
@@ -82,7 +86,7 @@ function extractRollupConfigFromExecutorOptions(tree, options, configurations, p
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
|
-
tree.write((0, devkit_1.joinPathFragments)(projectRoot, `rollup.config.
|
|
89
|
+
tree.write((0, devkit_1.joinPathFragments)(projectRoot, `rollup.config.cjs`), createNewRollupConfig(oldRollupConfig, defaultOptions, configurationOptions));
|
|
86
90
|
return defaultOptions;
|
|
87
91
|
}
|
|
88
92
|
function createNewRollupConfig(oldRollupConfig, defaultOptions, configurationOptions, singleConfiguration = false) {
|
package/src/plugins/plugin.js
CHANGED
|
@@ -9,6 +9,7 @@ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculat
|
|
|
9
9
|
const js_1 = require("@nx/js");
|
|
10
10
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
11
11
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
12
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
12
13
|
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
13
14
|
function readTargetsCache(cachePath) {
|
|
14
15
|
return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
|
|
@@ -28,7 +29,7 @@ exports.createNodes = [
|
|
|
28
29
|
rollupConfigGlob,
|
|
29
30
|
async (configFilePath, options, context) => {
|
|
30
31
|
devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
|
|
31
|
-
return createNodesInternal(configFilePath, normalizeOptions(options), context, {});
|
|
32
|
+
return createNodesInternal(configFilePath, normalizeOptions(options), context, {}, (0, ts_solution_setup_1.isUsingTsSolutionSetup)());
|
|
32
33
|
},
|
|
33
34
|
];
|
|
34
35
|
exports.createNodesV2 = [
|
|
@@ -38,15 +39,16 @@ exports.createNodesV2 = [
|
|
|
38
39
|
const optionsHash = (0, file_hasher_1.hashObject)(normalizedOptions);
|
|
39
40
|
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `rollup-${optionsHash}.hash`);
|
|
40
41
|
const targetsCache = readTargetsCache(cachePath);
|
|
42
|
+
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
41
43
|
try {
|
|
42
|
-
return await (0, devkit_1.createNodesFromFiles)((configFile, _, context) => createNodesInternal(configFile, normalizedOptions, context, targetsCache), configFilePaths, normalizedOptions, context);
|
|
44
|
+
return await (0, devkit_1.createNodesFromFiles)((configFile, _, context) => createNodesInternal(configFile, normalizedOptions, context, targetsCache, isTsSolutionSetup), configFilePaths, normalizedOptions, context);
|
|
43
45
|
}
|
|
44
46
|
finally {
|
|
45
47
|
writeTargetsToCache(cachePath, targetsCache);
|
|
46
48
|
}
|
|
47
49
|
},
|
|
48
50
|
];
|
|
49
|
-
async function createNodesInternal(configFilePath, options, context, targetsCache) {
|
|
51
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup) {
|
|
50
52
|
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
51
53
|
const fullyQualifiedProjectRoot = (0, path_1.join)(context.workspaceRoot, projectRoot);
|
|
52
54
|
// Do not create a project if package.json and project.json do not exist
|
|
@@ -56,7 +58,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
56
58
|
return {};
|
|
57
59
|
}
|
|
58
60
|
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
59
|
-
targetsCache[hash] ??= await buildRollupTarget(configFilePath, projectRoot, options, context);
|
|
61
|
+
targetsCache[hash] ??= await buildRollupTarget(configFilePath, projectRoot, options, context, isTsSolutionSetup);
|
|
60
62
|
return {
|
|
61
63
|
projects: {
|
|
62
64
|
[projectRoot]: {
|
|
@@ -66,7 +68,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
66
68
|
},
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
|
-
async function buildRollupTarget(configFilePath, projectRoot, options, context) {
|
|
71
|
+
async function buildRollupTarget(configFilePath, projectRoot, options, context, isTsSolutionSetup) {
|
|
70
72
|
let loadConfigFile;
|
|
71
73
|
try {
|
|
72
74
|
// Try to load the workspace version of rollup first (it should already exist).
|
|
@@ -114,6 +116,11 @@ async function buildRollupTarget(configFilePath, projectRoot, options, context)
|
|
|
114
116
|
},
|
|
115
117
|
},
|
|
116
118
|
};
|
|
119
|
+
if (isTsSolutionSetup) {
|
|
120
|
+
targets[options.buildTargetName].syncGenerators = [
|
|
121
|
+
'@nx/js:typescript-sync',
|
|
122
|
+
];
|
|
123
|
+
}
|
|
117
124
|
return targets;
|
|
118
125
|
}
|
|
119
126
|
function getOutputs(rollupConfigs, projectRoot) {
|
|
@@ -5,10 +5,15 @@ const node_path_1 = require("node:path");
|
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
9
|
function normalizeOptions(projectRoot, sourceRoot, options) {
|
|
9
10
|
if (global.NX_GRAPH_CREATION)
|
|
10
11
|
return options;
|
|
11
12
|
normalizeRelativePaths(projectRoot, options);
|
|
13
|
+
// New TS Solution already has a typecheck target
|
|
14
|
+
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)()) {
|
|
15
|
+
options.skipTypeCheck = true;
|
|
16
|
+
}
|
|
12
17
|
return {
|
|
13
18
|
...options,
|
|
14
19
|
additionalEntryPoints: (0, js_1.createEntryPoints)(options.additionalEntryPoints, devkit_1.workspaceRoot),
|