@nx/rollup 0.0.0-pr-22870-9ecd080 → 0.0.0-pr-26623-78cbba7
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": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-26623-78cbba7",
|
|
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,9 +43,9 @@
|
|
|
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-
|
|
48
|
-
"@nrwl/rollup": "0.0.0-pr-
|
|
46
|
+
"@nx/devkit": "0.0.0-pr-26623-78cbba7",
|
|
47
|
+
"@nx/js": "0.0.0-pr-26623-78cbba7",
|
|
48
|
+
"@nrwl/rollup": "0.0.0-pr-26623-78cbba7"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
package/src/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.js
CHANGED
|
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const normalize_path_options_1 = require("./normalize-path-options");
|
|
6
6
|
function extractRollupConfigFromExecutorOptions(tree, options, configurations, projectRoot) {
|
|
7
7
|
(0, normalize_path_options_1.normalizePathOptions)(projectRoot, options);
|
|
8
|
+
let newRollupConfigContent;
|
|
8
9
|
const hasConfigurations = !!configurations && Object.keys(configurations).length > 0;
|
|
9
10
|
const oldRollupConfig = Array.isArray(options.rollupConfig)
|
|
10
11
|
? options.rollupConfig
|
|
@@ -27,70 +28,25 @@ function extractRollupConfigFromExecutorOptions(tree, options, configurations, p
|
|
|
27
28
|
delete options[key];
|
|
28
29
|
defaultOptions[key] = value;
|
|
29
30
|
}
|
|
30
|
-
let configurationOptions;
|
|
31
31
|
if (hasConfigurations) {
|
|
32
|
-
configurationOptions = {};
|
|
32
|
+
const configurationOptions = {};
|
|
33
33
|
for (const [key, value] of Object.entries(configurations)) {
|
|
34
|
-
let newConfigFileName;
|
|
35
|
-
let oldRollupConfigForConfiguration;
|
|
36
34
|
for (const [optionKey, optionValue] of Object.entries(value)) {
|
|
37
35
|
if (optionKey === 'watch')
|
|
38
36
|
continue;
|
|
39
|
-
/**
|
|
40
|
-
* If a configuration lists rollupConfig as an option
|
|
41
|
-
* Collect the options and set up a new file to point to
|
|
42
|
-
* Set the `--config` option to the new file
|
|
43
|
-
*/
|
|
44
|
-
if (optionKey === 'rollupConfig') {
|
|
45
|
-
oldRollupConfigForConfiguration = Array.isArray(optionValue)
|
|
46
|
-
? optionValue
|
|
47
|
-
: optionValue
|
|
48
|
-
? [optionValue]
|
|
49
|
-
: [];
|
|
50
|
-
newConfigFileName = `rollup.${key}.config.js`;
|
|
51
|
-
for (let i = 0; i < oldRollupConfigForConfiguration.length; i++) {
|
|
52
|
-
const file = oldRollupConfigForConfiguration[i];
|
|
53
|
-
if (file === newConfigFileName) {
|
|
54
|
-
tree.rename((0, devkit_1.joinPathFragments)(projectRoot, newConfigFileName), (0, devkit_1.joinPathFragments)(projectRoot, `rollup.${key}.migrated.config.js`));
|
|
55
|
-
oldRollupConfigForConfiguration.splice(i, 1, `./rollup.${key}.migrated.config.js`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
delete value[optionKey];
|
|
59
|
-
value['config'] = newConfigFileName;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
37
|
delete value[optionKey];
|
|
63
38
|
configurationOptions[key] ??= {};
|
|
64
39
|
configurationOptions[key][optionKey] = optionValue;
|
|
65
40
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Only if we encountered a rollupConfig in the current configuration
|
|
68
|
-
* should we write a new config file, containing all the config values
|
|
69
|
-
*/
|
|
70
|
-
if (newConfigFileName) {
|
|
71
|
-
tree.write((0, devkit_1.joinPathFragments)(projectRoot, newConfigFileName), createNewRollupConfig(oldRollupConfigForConfiguration, defaultOptions, configurationOptions[key], true));
|
|
72
|
-
}
|
|
73
41
|
}
|
|
74
|
-
|
|
75
|
-
tree.write((0, devkit_1.joinPathFragments)(projectRoot, `rollup.config.js`), createNewRollupConfig(oldRollupConfig, defaultOptions, configurationOptions));
|
|
76
|
-
return defaultOptions;
|
|
77
|
-
}
|
|
78
|
-
exports.extractRollupConfigFromExecutorOptions = extractRollupConfigFromExecutorOptions;
|
|
79
|
-
function createNewRollupConfig(oldRollupConfig, defaultOptions, configurationOptions, singleConfiguration = false) {
|
|
80
|
-
if (configurationOptions) {
|
|
81
|
-
return (0, devkit_1.stripIndents) `
|
|
42
|
+
newRollupConfigContent = (0, devkit_1.stripIndents) `
|
|
82
43
|
const { withNx } = require('@nx/rollup/with-nx');
|
|
83
44
|
|
|
84
45
|
// These options were migrated by @nx/rollup:convert-to-inferred from project.json
|
|
85
|
-
const configValues = ${JSON.stringify(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
: {
|
|
91
|
-
default: defaultOptions,
|
|
92
|
-
...configurationOptions,
|
|
93
|
-
}, null, 2)};
|
|
46
|
+
const configValues = ${JSON.stringify({
|
|
47
|
+
default: defaultOptions,
|
|
48
|
+
...configurationOptions,
|
|
49
|
+
}, null, 2)};
|
|
94
50
|
|
|
95
51
|
// Determine the correct configValue to use based on the configuration
|
|
96
52
|
const nxConfiguration = process.env.NX_TASK_TARGET_CONFIGURATION ?? 'default';
|
|
@@ -115,7 +71,7 @@ function createNewRollupConfig(oldRollupConfig, defaultOptions, configurationOpt
|
|
|
115
71
|
`;
|
|
116
72
|
}
|
|
117
73
|
else {
|
|
118
|
-
|
|
74
|
+
newRollupConfigContent = (0, devkit_1.stripIndents) `
|
|
119
75
|
const { withNx } = require('@nx/rollup/with-nx');
|
|
120
76
|
|
|
121
77
|
// These options were migrated by @nx/rollup:convert-to-inferred from project.json
|
|
@@ -135,4 +91,7 @@ function createNewRollupConfig(oldRollupConfig, defaultOptions, configurationOpt
|
|
|
135
91
|
module.exports = config;
|
|
136
92
|
`;
|
|
137
93
|
}
|
|
94
|
+
tree.write((0, devkit_1.joinPathFragments)(projectRoot, `rollup.config.js`), newRollupConfigContent);
|
|
95
|
+
return defaultOptions;
|
|
138
96
|
}
|
|
97
|
+
exports.extractRollupConfigFromExecutorOptions = extractRollupConfigFromExecutorOptions;
|