@nx/rollup 21.0.0-beta.1 → 21.0.0-beta.11
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/migrations.json +0 -9
- package/package.json +3 -3
- package/src/executors/rollup/schema.d.ts +12 -11
- package/src/executors/rollup/schema.json +7 -3
- package/src/generators/configuration/configuration.js +4 -1
- package/src/generators/init/init.js +1 -1
- package/src/plugins/plugin.js +4 -4
- package/src/plugins/with-nx/with-nx-options.d.ts +4 -0
- package/src/plugins/with-nx/with-nx.js +4 -2
package/migrations.json
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {},
|
|
3
3
|
"packageJsonUpdates": {
|
|
4
|
-
"18.2.0": {
|
|
5
|
-
"version": "18.2.0-beta.1",
|
|
6
|
-
"packages": {
|
|
7
|
-
"core-js": {
|
|
8
|
-
"version": "3.36.1",
|
|
9
|
-
"alwaysAddToPackageJson": false
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
4
|
"19.0.0": {
|
|
14
5
|
"version": "19.0.0-beta.0",
|
|
15
6
|
"packages": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rollup",
|
|
3
|
-
"version": "21.0.0-beta.
|
|
3
|
+
"version": "21.0.0-beta.11",
|
|
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.0.0-beta.
|
|
33
|
-
"@nx/js": "21.0.0-beta.
|
|
32
|
+
"@nx/devkit": "21.0.0-beta.11",
|
|
33
|
+
"@nx/js": "21.0.0-beta.11",
|
|
34
34
|
"@rollup/plugin-babel": "^6.0.4",
|
|
35
35
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
36
36
|
"@rollup/plugin-image": "^3.0.3",
|
|
@@ -15,22 +15,23 @@ export interface Globals {
|
|
|
15
15
|
export interface RollupExecutorOptions {
|
|
16
16
|
outputPath: string;
|
|
17
17
|
tsConfig: string;
|
|
18
|
-
allowJs?: boolean;
|
|
19
|
-
project: string;
|
|
20
18
|
main: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
external?: string[] | 'all' | 'none';
|
|
24
|
-
rollupConfig?: string | string[];
|
|
25
|
-
watch?: boolean;
|
|
19
|
+
additionalEntryPoints?: string[];
|
|
20
|
+
allowJs?: boolean;
|
|
26
21
|
assets?: any[];
|
|
22
|
+
babelUpwardRootMode?: boolean;
|
|
23
|
+
buildLibsFromSource?: boolean;
|
|
24
|
+
compiler?: 'babel' | 'tsc' | 'swc';
|
|
27
25
|
deleteOutputPath?: boolean;
|
|
26
|
+
external?: string[] | 'all' | 'none';
|
|
27
|
+
extractCss?: boolean | string;
|
|
28
28
|
format?: ('cjs' | 'esm')[];
|
|
29
|
-
compiler?: 'babel' | 'tsc' | 'swc';
|
|
30
|
-
javascriptEnabled?: boolean;
|
|
31
29
|
generateExportsField?: boolean;
|
|
32
|
-
|
|
30
|
+
javascriptEnabled?: boolean;
|
|
31
|
+
project?: string;
|
|
32
|
+
outputFileName?: string;
|
|
33
|
+
rollupConfig?: string | string[];
|
|
33
34
|
skipTypeCheck?: boolean;
|
|
34
|
-
babelUpwardRootMode?: boolean;
|
|
35
35
|
skipTypeField?: boolean;
|
|
36
|
+
watch?: boolean;
|
|
36
37
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 2,
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
|
-
"title": "Web Library Rollup Target
|
|
4
|
+
"title": "Web Library Rollup Target",
|
|
5
5
|
"description": "Packages a library for different web usages (ESM, CommonJS).",
|
|
6
6
|
"cli": "nx",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
9
|
"project": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "The path to package.json file."
|
|
12
|
-
"x-priority": "important"
|
|
11
|
+
"description": "The path to package.json file."
|
|
13
12
|
},
|
|
14
13
|
"main": {
|
|
15
14
|
"type": "string",
|
|
@@ -138,6 +137,11 @@
|
|
|
138
137
|
},
|
|
139
138
|
"x-priority": "important"
|
|
140
139
|
},
|
|
140
|
+
"buildLibsFromSource": {
|
|
141
|
+
"type": "boolean",
|
|
142
|
+
"description": "Read buildable libraries from source instead of building them separately.",
|
|
143
|
+
"default": true
|
|
144
|
+
},
|
|
141
145
|
"skipTypeCheck": {
|
|
142
146
|
"type": "boolean",
|
|
143
147
|
"description": "Whether to skip TypeScript type checking.",
|
|
@@ -68,7 +68,7 @@ module.exports = withNx(
|
|
|
68
68
|
compiler: '${buildOptions.compiler}',
|
|
69
69
|
format: ${JSON.stringify(options.format ?? ['esm'])},${!isTsSolutionSetup
|
|
70
70
|
? `
|
|
71
|
-
assets: [{ input: '
|
|
71
|
+
assets: [{ input: '{projectRoot}', output: '.', glob:'*.md' }],`
|
|
72
72
|
: ''}
|
|
73
73
|
},
|
|
74
74
|
{
|
|
@@ -122,6 +122,8 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
|
|
|
122
122
|
: undefined) ?? nxJson.targetDefaults?.[options.buildTarget]);
|
|
123
123
|
({ main, outputPath } = mergedTarget.options);
|
|
124
124
|
}
|
|
125
|
+
// the file must exist in the TS solution setup
|
|
126
|
+
const tsconfigBase = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
|
|
125
127
|
packageJson = (0, js_1.getUpdatedPackageJsonContent)(packageJson, {
|
|
126
128
|
main,
|
|
127
129
|
outputPath,
|
|
@@ -132,6 +134,7 @@ function updatePackageJson(tree, options, outputConfig, isTsSolutionSetup) {
|
|
|
132
134
|
format: options.format ?? ['esm'],
|
|
133
135
|
outputFileExtensionForCjs: '.cjs.js',
|
|
134
136
|
outputFileExtensionForEsm: '.esm.js',
|
|
137
|
+
skipDevelopmentExports: !tsconfigBase.compilerOptions?.customConditions?.includes('development'),
|
|
135
138
|
});
|
|
136
139
|
// rollup has a specific declaration file generation not handled by the util above,
|
|
137
140
|
// adjust accordingly
|
|
@@ -20,7 +20,7 @@ async function rollupInitGenerator(tree, schema) {
|
|
|
20
20
|
task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
21
21
|
}
|
|
22
22
|
if (schema.addPlugin) {
|
|
23
|
-
await (0, add_plugin_1.
|
|
23
|
+
await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rollup/plugin', plugin_1.createNodesV2, {
|
|
24
24
|
buildTargetName: ['build', 'rollup:build', 'rollup-build'],
|
|
25
25
|
buildDepsTargetName: [
|
|
26
26
|
'build-deps',
|
package/src/plugins/plugin.js
CHANGED
|
@@ -86,15 +86,15 @@ async function buildRollupTarget(configFilePath, projectRoot, options, context,
|
|
|
86
86
|
// Fallback to our own if needed.
|
|
87
87
|
loadConfigFile = require('rollup/loadConfigFile').loadConfigFile;
|
|
88
88
|
}
|
|
89
|
+
const isTsConfig = configFilePath.endsWith('ts');
|
|
90
|
+
const tsConfigPlugin = '@rollup/plugin-typescript';
|
|
89
91
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
90
|
-
const rollupConfig = (await loadConfigFile((0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath), {}, true // Enable watch mode so that rollup properly reloads config files without reusing a cached version
|
|
92
|
+
const rollupConfig = (await loadConfigFile((0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath), isTsConfig ? { configPlugin: tsConfigPlugin } : {}, true // Enable watch mode so that rollup properly reloads config files without reusing a cached version
|
|
91
93
|
)).options;
|
|
92
94
|
const outputs = getOutputs(rollupConfig, projectRoot);
|
|
93
95
|
const targets = {};
|
|
94
96
|
targets[options.buildTargetName] = {
|
|
95
|
-
command: `rollup -c ${(0, path_1.basename)(configFilePath)}${
|
|
96
|
-
? ' --configPlugin @rollup/plugin-typescript'
|
|
97
|
-
: ''}`,
|
|
97
|
+
command: `rollup -c ${(0, path_1.basename)(configFilePath)}${isTsConfig ? ` --configPlugin ${tsConfigPlugin}` : ''}`,
|
|
98
98
|
options: { cwd: projectRoot },
|
|
99
99
|
cache: true,
|
|
100
100
|
dependsOn: [`^${options.buildTargetName}`],
|
|
@@ -15,6 +15,10 @@ export interface RollupWithNxPluginOptions {
|
|
|
15
15
|
* Whether to set rootmode to upward. See https://babeljs.io/docs/en/options#rootmode
|
|
16
16
|
*/
|
|
17
17
|
babelUpwardRootMode?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Build the libraries from source. Default is `true`.
|
|
20
|
+
*/
|
|
21
|
+
buildLibsFromSource?: boolean;
|
|
18
22
|
/**
|
|
19
23
|
* Which compiler to use.
|
|
20
24
|
*/
|
|
@@ -43,7 +43,9 @@ dependencies) {
|
|
|
43
43
|
const options = (0, normalize_options_1.normalizeOptions)(projectNode.data.root, projectNode.data.sourceRoot, rawOptions);
|
|
44
44
|
const useBabel = options.compiler === 'babel';
|
|
45
45
|
const useSwc = options.compiler === 'swc';
|
|
46
|
-
const tsConfigPath =
|
|
46
|
+
const tsConfigPath = options.buildLibsFromSource || global.NX_GRAPH_CREATION
|
|
47
|
+
? (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, options.tsConfig)
|
|
48
|
+
: (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, devkit_1.workspaceRoot, projectRoot, dependencies);
|
|
47
49
|
const tsConfigFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
48
50
|
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, (0, node_path_1.dirname)(tsConfigPath));
|
|
49
51
|
if (!options.format || !options.format.length) {
|
|
@@ -141,7 +143,7 @@ dependencies) {
|
|
|
141
143
|
// Needed to generate type definitions, even if we're using babel or swc.
|
|
142
144
|
require('rollup-plugin-typescript2')({
|
|
143
145
|
check: !options.skipTypeCheck,
|
|
144
|
-
tsconfig:
|
|
146
|
+
tsconfig: tsConfigPath,
|
|
145
147
|
tsconfigOverride: {
|
|
146
148
|
compilerOptions: createTsCompilerOptions(projectRoot, tsConfig, options, dependencies),
|
|
147
149
|
},
|