@nx/rollup 16.0.0-beta.1
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/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/executors.json +16 -0
- package/generators.json +33 -0
- package/index.d.ts +4 -0
- package/index.js +8 -0
- package/index.js.map +1 -0
- package/migrations.json +17 -0
- package/package.json +58 -0
- package/src/executors/rollup/compat.d.ts +2 -0
- package/src/executors/rollup/compat.js +6 -0
- package/src/executors/rollup/compat.js.map +1 -0
- package/src/executors/rollup/lib/analyze-plugin.d.ts +4 -0
- package/src/executors/rollup/lib/analyze-plugin.js +26 -0
- package/src/executors/rollup/lib/analyze-plugin.js.map +1 -0
- package/src/executors/rollup/lib/normalize.d.ts +10 -0
- package/src/executors/rollup/lib/normalize.js +78 -0
- package/src/executors/rollup/lib/normalize.js.map +1 -0
- package/src/executors/rollup/lib/run-rollup.d.ts +4 -0
- package/src/executors/rollup/lib/run-rollup.js +16 -0
- package/src/executors/rollup/lib/run-rollup.js.map +1 -0
- package/src/executors/rollup/lib/swc-plugin.d.ts +2 -0
- package/src/executors/rollup/lib/swc-plugin.js +21 -0
- package/src/executors/rollup/lib/swc-plugin.js.map +1 -0
- package/src/executors/rollup/lib/update-package-json.d.ts +6 -0
- package/src/executors/rollup/lib/update-package-json.js +46 -0
- package/src/executors/rollup/lib/update-package-json.js.map +1 -0
- package/src/executors/rollup/lib/validate-types.d.ts +5 -0
- package/src/executors/rollup/lib/validate-types.js +21 -0
- package/src/executors/rollup/lib/validate-types.js.map +1 -0
- package/src/executors/rollup/rollup.impl.d.ts +13 -0
- package/src/executors/rollup/rollup.impl.js +250 -0
- package/src/executors/rollup/rollup.impl.js.map +1 -0
- package/src/executors/rollup/schema.d.ts +35 -0
- package/src/executors/rollup/schema.json +172 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +35 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +4 -0
- package/src/generators/init/schema.json +22 -0
- package/src/generators/rollup-project/rollup-project.d.ts +5 -0
- package/src/generators/rollup-project/rollup-project.js +77 -0
- package/src/generators/rollup-project/rollup-project.js.map +1 -0
- package/src/generators/rollup-project/schema.d.ts +12 -0
- package/src/generators/rollup-project/schema.json +72 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.js +13 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.js.map +1 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/utils/fs.d.ts +4 -0
- package/src/utils/fs.js +17 -0
- package/src/utils/fs.js.map +1 -0
- package/src/utils/versions.d.ts +3 -0
- package/src/utils/versions.js +7 -0
- package/src/utils/versions.js.map +1 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRollupOptions = exports.rollupExecutor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
require("dotenv/config");
|
|
6
|
+
const ts = require("typescript");
|
|
7
|
+
const rollup = require("rollup");
|
|
8
|
+
const peerDepsExternal = require("rollup-plugin-peer-deps-external");
|
|
9
|
+
const plugin_babel_1 = require("@rollup/plugin-babel");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const rxjs_1 = require("rxjs");
|
|
12
|
+
const operators_1 = require("rxjs/operators");
|
|
13
|
+
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
14
|
+
const autoprefixer = require("autoprefixer");
|
|
15
|
+
const devkit_1 = require("@nx/devkit");
|
|
16
|
+
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
17
|
+
const plugin_node_resolve_1 = require("@rollup/plugin-node-resolve");
|
|
18
|
+
const run_rollup_1 = require("./lib/run-rollup");
|
|
19
|
+
const normalize_1 = require("./lib/normalize");
|
|
20
|
+
const analyze_plugin_1 = require("./lib/analyze-plugin");
|
|
21
|
+
const fs_1 = require("../../utils/fs");
|
|
22
|
+
const swc_plugin_1 = require("./lib/swc-plugin");
|
|
23
|
+
const validate_types_1 = require("./lib/validate-types");
|
|
24
|
+
const update_package_json_1 = require("./lib/update-package-json");
|
|
25
|
+
// These use require because the ES import isn't correct.
|
|
26
|
+
const commonjs = require('@rollup/plugin-commonjs');
|
|
27
|
+
const image = require('@rollup/plugin-image');
|
|
28
|
+
const json = require('@rollup/plugin-json');
|
|
29
|
+
const copy = require('rollup-plugin-copy');
|
|
30
|
+
const postcss = require('rollup-plugin-postcss');
|
|
31
|
+
const fileExtensions = ['.js', '.jsx', '.ts', '.tsx'];
|
|
32
|
+
function rollupExecutor(rawOptions, context) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
var _c;
|
|
35
|
+
return tslib_1.__asyncGenerator(this, arguments, function* rollupExecutor_1() {
|
|
36
|
+
(_a = (_c = process.env).NODE_ENV) !== null && _a !== void 0 ? _a : (_c.NODE_ENV = 'production');
|
|
37
|
+
const project = context.projectsConfigurations.projects[context.projectName];
|
|
38
|
+
const sourceRoot = project.sourceRoot;
|
|
39
|
+
const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectDependencies)(context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName, true);
|
|
40
|
+
const options = (0, normalize_1.normalizeRollupExecutorOptions)(rawOptions, context.root, sourceRoot);
|
|
41
|
+
const packageJson = (0, devkit_1.readJsonFile)(options.project);
|
|
42
|
+
const npmDeps = ((_b = context.projectGraph.dependencies[context.projectName]) !== null && _b !== void 0 ? _b : [])
|
|
43
|
+
.filter((d) => d.target.startsWith('npm:'))
|
|
44
|
+
.map((d) => d.target.slice(4));
|
|
45
|
+
const rollupOptions = createRollupOptions(options, dependencies, context, packageJson, sourceRoot, npmDeps);
|
|
46
|
+
const outfile = resolveOutfile(context, options);
|
|
47
|
+
if (options.compiler === 'swc') {
|
|
48
|
+
try {
|
|
49
|
+
yield tslib_1.__await((0, validate_types_1.validateTypes)({
|
|
50
|
+
workspaceRoot: context.root,
|
|
51
|
+
projectRoot: options.projectRoot,
|
|
52
|
+
tsconfig: options.tsConfig,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
catch (_d) {
|
|
56
|
+
return yield tslib_1.__await({ success: false });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (options.watch) {
|
|
60
|
+
const watcher = rollup.watch(rollupOptions);
|
|
61
|
+
return yield tslib_1.__await(yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues((0, rxjs_for_await_1.eachValueFrom)(new rxjs_1.Observable((obs) => {
|
|
62
|
+
watcher.on('event', (data) => {
|
|
63
|
+
if (data.code === 'START') {
|
|
64
|
+
devkit_1.logger.info(`Bundling ${context.projectName}...`);
|
|
65
|
+
}
|
|
66
|
+
else if (data.code === 'END') {
|
|
67
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies, packageJson);
|
|
68
|
+
devkit_1.logger.info('Bundle complete. Watching for file changes...');
|
|
69
|
+
obs.next({ success: true, outfile });
|
|
70
|
+
}
|
|
71
|
+
else if (data.code === 'ERROR') {
|
|
72
|
+
devkit_1.logger.error(`Error during bundle: ${data.error.message}`);
|
|
73
|
+
obs.next({ success: false });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// Teardown logic. Close watcher when unsubscribed.
|
|
77
|
+
return () => watcher.close();
|
|
78
|
+
}))))));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
devkit_1.logger.info(`Bundling ${context.projectName}...`);
|
|
82
|
+
// Delete output path before bundling
|
|
83
|
+
if (options.deleteOutputPath) {
|
|
84
|
+
(0, fs_1.deleteOutputDir)(context.root, options.outputPath);
|
|
85
|
+
}
|
|
86
|
+
const start = process.hrtime.bigint();
|
|
87
|
+
return yield tslib_1.__await((0, rxjs_1.from)(rollupOptions)
|
|
88
|
+
.pipe((0, operators_1.concatMap)((opts) => (0, run_rollup_1.runRollup)(opts).pipe((0, operators_1.catchError)((e) => {
|
|
89
|
+
devkit_1.logger.error(`Error during bundle: ${e}`);
|
|
90
|
+
return (0, rxjs_1.of)({ success: false });
|
|
91
|
+
}))), (0, operators_1.scan)((acc, result) => {
|
|
92
|
+
if (!acc.success)
|
|
93
|
+
return acc;
|
|
94
|
+
return result;
|
|
95
|
+
}, { success: true, outfile }), (0, operators_1.last)(), (0, operators_1.tap)({
|
|
96
|
+
next: (result) => {
|
|
97
|
+
if (result.success) {
|
|
98
|
+
const end = process.hrtime.bigint();
|
|
99
|
+
const duration = `${(Number(end - start) / 1000000000).toFixed(2)}s`;
|
|
100
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies, packageJson);
|
|
101
|
+
devkit_1.logger.info(`⚡ Done in ${duration}`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
devkit_1.logger.error(`Bundle failed: ${context.projectName}`);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
}))
|
|
108
|
+
.toPromise());
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
exports.rollupExecutor = rollupExecutor;
|
|
113
|
+
// -----------------------------------------------------------------------------
|
|
114
|
+
function createRollupOptions(options, dependencies, context, packageJson, sourceRoot, npmDeps) {
|
|
115
|
+
const useBabel = options.compiler === 'babel';
|
|
116
|
+
const useTsc = options.compiler === 'tsc';
|
|
117
|
+
const useSwc = options.compiler === 'swc';
|
|
118
|
+
const tsConfigPath = (0, devkit_1.joinPathFragments)(context.root, options.tsConfig);
|
|
119
|
+
const configFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
120
|
+
const config = ts.parseJsonConfigFileContent(configFile.config, ts.sys, (0, path_1.dirname)(tsConfigPath));
|
|
121
|
+
if (!options.format || !options.format.length) {
|
|
122
|
+
options.format = readCompatibleFormats(config);
|
|
123
|
+
}
|
|
124
|
+
return options.format.map((format, idx) => {
|
|
125
|
+
const plugins = [
|
|
126
|
+
copy({
|
|
127
|
+
targets: convertCopyAssetsToRollupOptions(options.outputPath, options.assets),
|
|
128
|
+
}),
|
|
129
|
+
image(),
|
|
130
|
+
json(),
|
|
131
|
+
(useTsc || useBabel) &&
|
|
132
|
+
require('rollup-plugin-typescript2')({
|
|
133
|
+
check: true,
|
|
134
|
+
tsconfig: options.tsConfig,
|
|
135
|
+
tsconfigOverride: {
|
|
136
|
+
compilerOptions: createTsCompilerOptions(config, dependencies, options),
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
peerDepsExternal({
|
|
140
|
+
packageJsonPath: options.project,
|
|
141
|
+
}),
|
|
142
|
+
postcss({
|
|
143
|
+
inject: true,
|
|
144
|
+
extract: options.extractCss,
|
|
145
|
+
autoModules: true,
|
|
146
|
+
plugins: [autoprefixer],
|
|
147
|
+
use: {
|
|
148
|
+
less: {
|
|
149
|
+
javascriptEnabled: options.javascriptEnabled,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
153
|
+
(0, plugin_node_resolve_1.default)({
|
|
154
|
+
preferBuiltins: true,
|
|
155
|
+
extensions: fileExtensions,
|
|
156
|
+
}),
|
|
157
|
+
useSwc && (0, swc_plugin_1.swc)(),
|
|
158
|
+
useBabel &&
|
|
159
|
+
(0, plugin_babel_1.getBabelInputPlugin)({
|
|
160
|
+
// Lets `@nrwl/js/babel` preset know that we are packaging.
|
|
161
|
+
caller: {
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
// Ignoring type checks for caller since we have custom attributes
|
|
164
|
+
isNxPackage: true,
|
|
165
|
+
// Always target esnext and let rollup handle cjs
|
|
166
|
+
supportsStaticESM: true,
|
|
167
|
+
isModern: true,
|
|
168
|
+
},
|
|
169
|
+
cwd: (0, path_1.join)(context.root, sourceRoot),
|
|
170
|
+
rootMode: 'upward',
|
|
171
|
+
babelrc: true,
|
|
172
|
+
extensions: fileExtensions,
|
|
173
|
+
babelHelpers: 'bundled',
|
|
174
|
+
skipPreflightCheck: true,
|
|
175
|
+
exclude: /node_modules/,
|
|
176
|
+
plugins: [
|
|
177
|
+
format === 'esm'
|
|
178
|
+
? undefined
|
|
179
|
+
: require.resolve('babel-plugin-transform-async-to-promises'),
|
|
180
|
+
].filter(Boolean),
|
|
181
|
+
}),
|
|
182
|
+
commonjs(),
|
|
183
|
+
(0, analyze_plugin_1.analyze)(),
|
|
184
|
+
];
|
|
185
|
+
const externalPackages = dependencies
|
|
186
|
+
.map((d) => d.name)
|
|
187
|
+
.concat(options.external || [])
|
|
188
|
+
.concat(Object.keys(packageJson.dependencies || {}));
|
|
189
|
+
const rollupConfig = {
|
|
190
|
+
input: options.outputFileName
|
|
191
|
+
? {
|
|
192
|
+
[(0, path_1.parse)(options.outputFileName).name]: options.main,
|
|
193
|
+
}
|
|
194
|
+
: options.main,
|
|
195
|
+
output: {
|
|
196
|
+
format,
|
|
197
|
+
dir: `${options.outputPath}`,
|
|
198
|
+
name: (0, devkit_1.names)(context.projectName).className,
|
|
199
|
+
entryFileNames: `[name].${format === 'esm' ? 'js' : 'cjs'}`,
|
|
200
|
+
chunkFileNames: `[name].${format === 'esm' ? 'js' : 'cjs'}`,
|
|
201
|
+
},
|
|
202
|
+
external: (id) => externalPackages.some((name) => id === name || id.startsWith(`${name}/`)) || npmDeps.some((name) => id === name || id.startsWith(`${name}/`)),
|
|
203
|
+
plugins,
|
|
204
|
+
};
|
|
205
|
+
return options.rollupConfig.reduce((currentConfig, plugin) => {
|
|
206
|
+
return require(plugin)(currentConfig, options);
|
|
207
|
+
}, rollupConfig);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
exports.createRollupOptions = createRollupOptions;
|
|
211
|
+
function createTsCompilerOptions(config, dependencies, options) {
|
|
212
|
+
const compilerOptionPaths = (0, buildable_libs_utils_1.computeCompilerOptionsPaths)(config, dependencies);
|
|
213
|
+
const compilerOptions = {
|
|
214
|
+
rootDir: options.projectRoot,
|
|
215
|
+
allowJs: false,
|
|
216
|
+
declaration: true,
|
|
217
|
+
paths: compilerOptionPaths,
|
|
218
|
+
};
|
|
219
|
+
if (config.options.module === ts.ModuleKind.CommonJS) {
|
|
220
|
+
compilerOptions['module'] = 'ESNext';
|
|
221
|
+
}
|
|
222
|
+
return compilerOptions;
|
|
223
|
+
}
|
|
224
|
+
function convertCopyAssetsToRollupOptions(outputPath, assets) {
|
|
225
|
+
return assets
|
|
226
|
+
? assets.map((a) => ({
|
|
227
|
+
src: (0, path_1.join)(a.input, a.glob).replace(/\\/g, '/'),
|
|
228
|
+
dest: (0, path_1.join)(outputPath, a.output).replace(/\\/g, '/'),
|
|
229
|
+
}))
|
|
230
|
+
: undefined;
|
|
231
|
+
}
|
|
232
|
+
function readCompatibleFormats(config) {
|
|
233
|
+
switch (config.options.module) {
|
|
234
|
+
case ts.ModuleKind.CommonJS:
|
|
235
|
+
case ts.ModuleKind.UMD:
|
|
236
|
+
case ts.ModuleKind.AMD:
|
|
237
|
+
return ['cjs'];
|
|
238
|
+
default:
|
|
239
|
+
return ['esm'];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function resolveOutfile(context, options) {
|
|
243
|
+
var _a, _b;
|
|
244
|
+
if (!((_a = options.format) === null || _a === void 0 ? void 0 : _a.includes('cjs')))
|
|
245
|
+
return undefined;
|
|
246
|
+
const { name } = (0, path_1.parse)((_b = options.outputFileName) !== null && _b !== void 0 ? _b : options.main);
|
|
247
|
+
return (0, path_1.resolve)(context.root, options.outputPath, `${name}.cjs`);
|
|
248
|
+
}
|
|
249
|
+
exports.default = rollupExecutor;
|
|
250
|
+
//# sourceMappingURL=rollup.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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AAC;KAClB;AACH,CAAC;AAED,SAAS,cAAc,CACrB,OAAwB,EACxB,OAAwC;;IAExC,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;QAAE,OAAO,SAAS,CAAC;IACvD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,YAAK,EAAC,MAAA,OAAO,CAAC,cAAc,mCAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO,IAAA,cAAO,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;AAClE,CAAC;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type Compiler = 'babel' | 'swc';
|
|
2
|
+
|
|
3
|
+
export interface AssetGlobPattern {
|
|
4
|
+
glob: string;
|
|
5
|
+
input: string;
|
|
6
|
+
output: string;
|
|
7
|
+
ignore?: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Globals {
|
|
11
|
+
moduleId: string;
|
|
12
|
+
global: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RollupExecutorOptions {
|
|
16
|
+
outputPath: string;
|
|
17
|
+
tsConfig: string;
|
|
18
|
+
project: string;
|
|
19
|
+
main: string;
|
|
20
|
+
outputFileName?: string;
|
|
21
|
+
extractCss?: boolean | string;
|
|
22
|
+
external?: string[];
|
|
23
|
+
rollupConfig?: string | string[];
|
|
24
|
+
watch?: boolean;
|
|
25
|
+
assets?: any[];
|
|
26
|
+
updateBuildableProjectDepsInPackageJson?: boolean;
|
|
27
|
+
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
|
|
28
|
+
deleteOutputPath?: boolean;
|
|
29
|
+
format?: string[];
|
|
30
|
+
compiler?: 'babel' | 'tsc' | 'swc';
|
|
31
|
+
javascriptEnabled?: boolean;
|
|
32
|
+
// TODO(jack): remove this for Nx 16
|
|
33
|
+
skipTypeField?: boolean;
|
|
34
|
+
generateExportsField?: boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"outputCapture": "direct-nodejs",
|
|
4
|
+
"title": "Web Library Rollup Target (Experimental)",
|
|
5
|
+
"description": "Packages a library for different web usages (ESM, CommonJS).",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"presets": [
|
|
9
|
+
{
|
|
10
|
+
"name": "Including Dependencies in package.json",
|
|
11
|
+
"keys": [
|
|
12
|
+
"main",
|
|
13
|
+
"outputPath",
|
|
14
|
+
"project",
|
|
15
|
+
"tsConfig",
|
|
16
|
+
"buildableProjectDepsInPackageJsonType",
|
|
17
|
+
"updateBuildableProjectDepsInPackageJson"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"properties": {
|
|
22
|
+
"project": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "The path to package.json file.",
|
|
25
|
+
"x-priority": "important"
|
|
26
|
+
},
|
|
27
|
+
"main": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The path to the entry file, relative to project.",
|
|
30
|
+
"alias": "entryFile",
|
|
31
|
+
"x-completion-type": "file",
|
|
32
|
+
"x-completion-glob": "**/*@(.js|.ts)",
|
|
33
|
+
"x-priority": "important"
|
|
34
|
+
},
|
|
35
|
+
"outputPath": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "The output path of the generated files.",
|
|
38
|
+
"x-completion-type": "directory",
|
|
39
|
+
"x-priority": "important"
|
|
40
|
+
},
|
|
41
|
+
"outputFileName": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Name of the main output file. Defaults same basename as 'main' file."
|
|
44
|
+
},
|
|
45
|
+
"deleteOutputPath": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "Delete the output path before building.",
|
|
48
|
+
"default": true
|
|
49
|
+
},
|
|
50
|
+
"tsConfig": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "The path to tsconfig file.",
|
|
53
|
+
"x-completion-type": "file",
|
|
54
|
+
"x-completion-glob": "tsconfig.*.json",
|
|
55
|
+
"x-priority": "important"
|
|
56
|
+
},
|
|
57
|
+
"format": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"description": "List of module formats to output. Defaults to matching format from tsconfig (e.g. CJS for CommonJS, and ESM otherwise).",
|
|
60
|
+
"alias": "f",
|
|
61
|
+
"items": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"enum": ["esm", "cjs"]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"external": {
|
|
67
|
+
"type": "array",
|
|
68
|
+
"description": "A list of external modules that will not be bundled (`react`, `react-dom`, etc.).",
|
|
69
|
+
"items": {
|
|
70
|
+
"type": "string"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"watch": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"description": "Enable re-building when files change.",
|
|
76
|
+
"default": false
|
|
77
|
+
},
|
|
78
|
+
"updateBuildableProjectDepsInPackageJson": {
|
|
79
|
+
"type": "boolean",
|
|
80
|
+
"description": "Update buildable project dependencies in `package.json`.",
|
|
81
|
+
"default": true
|
|
82
|
+
},
|
|
83
|
+
"buildableProjectDepsInPackageJsonType": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
|
|
86
|
+
"enum": ["dependencies", "peerDependencies"],
|
|
87
|
+
"default": "peerDependencies"
|
|
88
|
+
},
|
|
89
|
+
"rollupConfig": {
|
|
90
|
+
"oneOf": [
|
|
91
|
+
{
|
|
92
|
+
"type": "array",
|
|
93
|
+
"items": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"x-completion-type": "file",
|
|
96
|
+
"x-completion-glob": "rollup?(*)@(.js|.ts)"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"type": "string",
|
|
101
|
+
"x-completion-type": "file",
|
|
102
|
+
"x-completion-glob": "rollup?(*)@(.js|.ts)"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"description": "Path to a function which takes a rollup config and returns an updated rollup config."
|
|
106
|
+
},
|
|
107
|
+
"extractCss": {
|
|
108
|
+
"type": ["boolean", "string"],
|
|
109
|
+
"description": "CSS files will be extracted to the output folder. Alternatively custom filename can be provided (e.g. styles.css)",
|
|
110
|
+
"default": true
|
|
111
|
+
},
|
|
112
|
+
"assets": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"description": "List of static assets.",
|
|
115
|
+
"default": [],
|
|
116
|
+
"items": {
|
|
117
|
+
"$ref": "#/definitions/assetPattern"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"compiler": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"enum": ["babel", "swc", "tsc"],
|
|
123
|
+
"default": "babel",
|
|
124
|
+
"description": "Which compiler to use."
|
|
125
|
+
},
|
|
126
|
+
"javascriptEnabled": {
|
|
127
|
+
"type": "boolean",
|
|
128
|
+
"description": "Sets `javascriptEnabled` option for less loader",
|
|
129
|
+
"default": false
|
|
130
|
+
},
|
|
131
|
+
"generateExportsField": {
|
|
132
|
+
"type": "boolean",
|
|
133
|
+
"description": "Generate package.json with 'exports' field. This field defines entry points in the package and is used by Node and the TypeScript compiler.",
|
|
134
|
+
"default": false
|
|
135
|
+
},
|
|
136
|
+
"skipTypeField": {
|
|
137
|
+
"type": "boolean",
|
|
138
|
+
"description": "Prevents 'type' field from being added to compiled package.json file. Only use this if you are having an issue with this field.",
|
|
139
|
+
"default": false
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"required": ["tsConfig", "main", "outputPath"],
|
|
143
|
+
"definitions": {
|
|
144
|
+
"assetPattern": {
|
|
145
|
+
"oneOf": [
|
|
146
|
+
{
|
|
147
|
+
"type": "object",
|
|
148
|
+
"properties": {
|
|
149
|
+
"glob": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"description": "The pattern to match."
|
|
152
|
+
},
|
|
153
|
+
"input": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"description": "The input directory path in which to apply `glob`. Defaults to the project root."
|
|
156
|
+
},
|
|
157
|
+
"output": {
|
|
158
|
+
"type": "string",
|
|
159
|
+
"description": "Relative path within the output folder."
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"additionalProperties": false,
|
|
163
|
+
"required": ["glob", "input", "output"]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"type": "string"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"examplesFile": "../../docs/rollup-examples.md"
|
|
172
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function rollupInitGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export default rollupInitGenerator;
|
|
5
|
+
export declare const rollupInitSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rollupInitSchematic = exports.rollupInitGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const versions_1 = require("@nx/js/src/utils/versions");
|
|
7
|
+
const versions_2 = require("../../utils/versions");
|
|
8
|
+
const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
|
|
9
|
+
function rollupInitGenerator(tree, schema) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
let task;
|
|
12
|
+
if (schema.compiler === 'babel') {
|
|
13
|
+
(0, add_babel_inputs_1.addBabelInputs)(tree);
|
|
14
|
+
}
|
|
15
|
+
if (schema.compiler === 'swc') {
|
|
16
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
17
|
+
'@nrwl/rollup': versions_2.nxVersion,
|
|
18
|
+
'@swc/helpers': versions_1.swcHelpersVersion,
|
|
19
|
+
'@swc/core': versions_1.swcCoreVersion,
|
|
20
|
+
'swc-loader': versions_2.swcLoaderVersion,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
task = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { tslib: versions_2.tsLibVersion });
|
|
25
|
+
}
|
|
26
|
+
if (!schema.skipFormat) {
|
|
27
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
29
|
+
return task;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.rollupInitGenerator = rollupInitGenerator;
|
|
33
|
+
exports.default = rollupInitGenerator;
|
|
34
|
+
exports.rollupInitSchematic = (0, devkit_1.convertNxGenerator)(rollupInitGenerator);
|
|
35
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/rollup/src/generators/init/init.ts"],"names":[],"mappings":";;;;AAAA,uCAMoB;AAEpB,wDAA8E;AAC9E,mDAI8B;AAC9B,wEAAmE;AAEnE,SAAsB,mBAAmB,CAAC,IAAU,EAAE,MAAc;;QAClE,IAAI,IAAuB,CAAC;QAE5B,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC/B,IAAA,iCAAc,EAAC,IAAI,CAAC,CAAC;SACtB;QAED,IAAI,MAAM,CAAC,QAAQ,KAAK,KAAK,EAAE;YAC7B,IAAI,GAAG,IAAA,qCAA4B,EACjC,IAAI,EACJ,EAAE,EACF;gBACE,cAAc,EAAE,oBAAS;gBACzB,cAAc,EAAE,4BAAiB;gBACjC,WAAW,EAAE,yBAAc;gBAC3B,YAAY,EAAE,2BAAgB;aAC/B,CACF,CAAC;SACH;aAAM;YACL,IAAI,GAAG,IAAA,qCAA4B,EAAC,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,uBAAY,EAAE,CAAC,CAAC;SACxE;QAED,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACtB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AA3BD,kDA2BC;AAED,kBAAe,mBAAmB,CAAC;AAEtB,QAAA,mBAAmB,GAAG,IAAA,2BAAkB,EAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxWebpackInit",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"title": "Init Webpack Plugin",
|
|
6
|
+
"description": "Init Webpack Plugin.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"compiler": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"enum": ["babel", "swc", "tsc"],
|
|
12
|
+
"description": "The compiler to initialize for.",
|
|
13
|
+
"default": "babel"
|
|
14
|
+
},
|
|
15
|
+
"skipFormat": {
|
|
16
|
+
"description": "Skip formatting files.",
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"default": false
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": []
|
|
22
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import { RollupProjectSchema } from './schema';
|
|
3
|
+
export declare function rollupProjectGenerator(tree: Tree, options: RollupProjectSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
+
export default rollupProjectGenerator;
|
|
5
|
+
export declare const rollupProjectSchematic: (generatorOptions: RollupProjectSchema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rollupProjectSchematic = exports.rollupProjectGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const init_1 = require("../init/init");
|
|
7
|
+
function rollupProjectGenerator(tree, options) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const task = yield (0, init_1.rollupInitGenerator)(tree, Object.assign(Object.assign({}, options), { skipFormat: true }));
|
|
10
|
+
checkForTargetConflicts(tree, options);
|
|
11
|
+
addBuildTarget(tree, options);
|
|
12
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
13
|
+
return task;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.rollupProjectGenerator = rollupProjectGenerator;
|
|
17
|
+
function checkForTargetConflicts(tree, options) {
|
|
18
|
+
var _a;
|
|
19
|
+
if (options.skipValidation)
|
|
20
|
+
return;
|
|
21
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
22
|
+
if ((_a = project.targets) === null || _a === void 0 ? void 0 : _a.build) {
|
|
23
|
+
throw new Error(`Project "${options.project}" already has a build target. Pass --skipValidation to ignore this error.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function addBuildTarget(tree, options) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
29
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(project.root, 'package.json');
|
|
30
|
+
if (!tree.exists(packageJsonPath)) {
|
|
31
|
+
const { npmScope } = (0, devkit_1.getWorkspaceLayout)(tree);
|
|
32
|
+
const importPath = options.importPath || (0, devkit_1.getImportPath)(npmScope, options.project);
|
|
33
|
+
(0, devkit_1.writeJson)(tree, packageJsonPath, {
|
|
34
|
+
name: importPath,
|
|
35
|
+
version: '0.0.1',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const tsConfig = (_a = options.tsConfig) !== null && _a !== void 0 ? _a : (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json');
|
|
39
|
+
const buildOptions = {
|
|
40
|
+
main: (_b = options.main) !== null && _b !== void 0 ? _b : (0, devkit_1.joinPathFragments)(project.root, 'src/main.ts'),
|
|
41
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', project.root),
|
|
42
|
+
compiler: (_c = options.compiler) !== null && _c !== void 0 ? _c : 'babel',
|
|
43
|
+
tsConfig,
|
|
44
|
+
project: `${project.root}/package.json`,
|
|
45
|
+
external: options.external,
|
|
46
|
+
};
|
|
47
|
+
if (options.rollupConfig) {
|
|
48
|
+
buildOptions.rollupConfig = options.rollupConfig;
|
|
49
|
+
}
|
|
50
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'README.md'))) {
|
|
51
|
+
buildOptions.assets = [
|
|
52
|
+
{
|
|
53
|
+
glob: `${project.root}/README.md`,
|
|
54
|
+
input: '.',
|
|
55
|
+
output: '.',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, Object.assign(Object.assign({}, project), { targets: Object.assign(Object.assign({}, project.targets), { build: {
|
|
60
|
+
executor: '@nrwl/rollup:rollup',
|
|
61
|
+
outputs: ['{options.outputPath}'],
|
|
62
|
+
defaultConfiguration: 'production',
|
|
63
|
+
options: buildOptions,
|
|
64
|
+
configurations: {
|
|
65
|
+
production: {
|
|
66
|
+
optimization: true,
|
|
67
|
+
sourceMap: false,
|
|
68
|
+
namedChunks: false,
|
|
69
|
+
extractLicenses: true,
|
|
70
|
+
vendorChunk: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
} }) }));
|
|
74
|
+
}
|
|
75
|
+
exports.default = rollupProjectGenerator;
|
|
76
|
+
exports.rollupProjectSchematic = (0, devkit_1.convertNxGenerator)(rollupProjectGenerator);
|
|
77
|
+
//# sourceMappingURL=rollup-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup-project.js","sourceRoot":"","sources":["../../../../../../packages/rollup/src/generators/rollup-project/rollup-project.ts"],"names":[],"mappings":";;;;AACA,uCASoB;AAEpB,uCAAmD;AAInD,SAAsB,sBAAsB,CAC1C,IAAU,EACV,OAA4B;;QAE5B,MAAM,IAAI,GAAG,MAAM,IAAA,0BAAmB,EAAC,IAAI,kCACtC,OAAO,KACV,UAAU,EAAE,IAAI,IAChB,CAAC;QACH,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9B,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAZD,wDAYC;AAED,SAAS,uBAAuB,CAAC,IAAU,EAAE,OAA4B;;IACvE,IAAI,OAAO,CAAC,cAAc;QAAE,OAAO;IACnC,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAChE,IAAI,MAAA,OAAO,CAAC,OAAO,0CAAE,KAAK,EAAE;QAC1B,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,CAAC,OAAO,2EAA2E,CACvG,CAAC;KACH;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAAU,EAAE,OAA4B;;IAC9D,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAChE,MAAM,eAAe,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAExE,IAAI,CAAC,IAAI,CAA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E,OAAO,CAAC,OAAO,kCAC3C,OAAO,KACV,OAAO,kCACF,OAAO,CAAC,OAAO,KAClB,KAAK,EAAE;gBACL,QAAQ,EAAE,qBAAqB;gBAC/B,OAAO,EAAE,CAAC,sBAAsB,CAAC;gBACjC,oBAAoB,EAAE,YAAY;gBAClC,OAAO,EAAE,YAAY;gBACrB,cAAc,EAAE;oBACd,UAAU,EAAE;wBACV,YAAY,EAAE,IAAI;wBAClB,SAAS,EAAE,KAAK;wBAChB,WAAW,EAAE,KAAK;wBAClB,eAAe,EAAE,IAAI;wBACrB,WAAW,EAAE,KAAK;qBACnB;iBACF;aACF,OAEH,CAAC;AACL,CAAC;AAED,kBAAe,sBAAsB,CAAC;AAEzB,QAAA,sBAAsB,GAAG,IAAA,2BAAkB,EACtD,sBAAsB,CACvB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface RollupProjectSchema {
|
|
2
|
+
project: string;
|
|
3
|
+
main?: string;
|
|
4
|
+
tsConfig?: string;
|
|
5
|
+
compiler?: 'babel' | 'swc' | 'tsc';
|
|
6
|
+
skipFormat?: boolean;
|
|
7
|
+
skipPackageJson?: boolean;
|
|
8
|
+
skipValidation?: boolean;
|
|
9
|
+
importPath?: string;
|
|
10
|
+
external?: string[];
|
|
11
|
+
rollupConfig?: string;
|
|
12
|
+
}
|