@nx/rollup 22.1.2 → 22.1.3
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": "22.1.
|
|
3
|
+
"version": "22.1.3",
|
|
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": "22.1.
|
|
33
|
-
"@nx/js": "22.1.
|
|
32
|
+
"@nx/devkit": "22.1.3",
|
|
33
|
+
"@nx/js": "22.1.3",
|
|
34
34
|
"@rollup/plugin-babel": "^6.0.4",
|
|
35
35
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
36
36
|
"@rollup/plugin-image": "^3.0.3",
|
|
@@ -42,13 +42,12 @@
|
|
|
42
42
|
"picomatch": "4.0.2",
|
|
43
43
|
"postcss": "^8.4.38",
|
|
44
44
|
"rollup": "^4.14.0",
|
|
45
|
-
"rollup-plugin-copy": "^3.5.0",
|
|
46
45
|
"rollup-plugin-postcss": "^4.0.2",
|
|
47
46
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
48
47
|
"tslib": "^2.3.0"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"nx": "22.1.
|
|
50
|
+
"nx": "22.1.3"
|
|
52
51
|
},
|
|
53
52
|
"publishConfig": {
|
|
54
53
|
"access": "public"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Plugin } from 'rollup';
|
|
2
|
+
import { AssetGlob } from '@nx/js/src/utils/assets/assets';
|
|
3
|
+
export interface NxCopyAssetsPluginOptions {
|
|
4
|
+
assets: (string | AssetGlob)[];
|
|
5
|
+
outputPath: string;
|
|
6
|
+
projectRoot: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Splits a glob into its literal directory prefix and the remaining pattern.
|
|
10
|
+
* CopyAssetsHandler expects input to be a directory and glob to be a pattern
|
|
11
|
+
* within it (e.g., input: 'docs', glob: '**\/*.md'), not combined paths.
|
|
12
|
+
*
|
|
13
|
+
* 'libs/mylib/README.md' => { prefix: 'libs/mylib', glob: 'README.md' }
|
|
14
|
+
* 'docs/*.md' => { prefix: 'docs', glob: '*.md' }
|
|
15
|
+
* '**\/*.md' => { prefix: '.', glob: '**\/*.md' }
|
|
16
|
+
*
|
|
17
|
+
* @visibleForTesting
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractGlobLiteralPrefix(glob: string): {
|
|
20
|
+
prefix: string;
|
|
21
|
+
glob: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function nxCopyAssetsPlugin(options: NxCopyAssetsPluginOptions): Plugin;
|
|
24
|
+
//# sourceMappingURL=nx-copy-assets.plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-copy-assets.plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/rollup/src/plugins/nx-copy-assets.plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAG3D,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAiBA;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAqD7E"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractGlobLiteralPrefix = extractGlobLiteralPrefix;
|
|
4
|
+
exports.nxCopyAssetsPlugin = nxCopyAssetsPlugin;
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const copy_assets_handler_1 = require("@nx/js/src/utils/assets/copy-assets-handler");
|
|
8
|
+
/**
|
|
9
|
+
* Splits a glob into its literal directory prefix and the remaining pattern.
|
|
10
|
+
* CopyAssetsHandler expects input to be a directory and glob to be a pattern
|
|
11
|
+
* within it (e.g., input: 'docs', glob: '**\/*.md'), not combined paths.
|
|
12
|
+
*
|
|
13
|
+
* 'libs/mylib/README.md' => { prefix: 'libs/mylib', glob: 'README.md' }
|
|
14
|
+
* 'docs/*.md' => { prefix: 'docs', glob: '*.md' }
|
|
15
|
+
* '**\/*.md' => { prefix: '.', glob: '**\/*.md' }
|
|
16
|
+
*
|
|
17
|
+
* @visibleForTesting
|
|
18
|
+
*/
|
|
19
|
+
function extractGlobLiteralPrefix(glob) {
|
|
20
|
+
const parts = glob.split('/');
|
|
21
|
+
const isGlobPart = (p) => p.includes('*') || p.includes('?') || p.includes('[') || p.includes('{');
|
|
22
|
+
const firstGlobIndex = parts.findIndex(isGlobPart);
|
|
23
|
+
const hasGlob = firstGlobIndex !== -1;
|
|
24
|
+
const prefixParts = hasGlob
|
|
25
|
+
? parts.slice(0, firstGlobIndex)
|
|
26
|
+
: parts.slice(0, -1);
|
|
27
|
+
const globParts = hasGlob ? parts.slice(firstGlobIndex) : parts.slice(-1);
|
|
28
|
+
return {
|
|
29
|
+
prefix: prefixParts.join('/') || '.',
|
|
30
|
+
glob: globParts.join('/'),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function nxCopyAssetsPlugin(options) {
|
|
34
|
+
let handler;
|
|
35
|
+
let dispose;
|
|
36
|
+
if (global.NX_GRAPH_CREATION)
|
|
37
|
+
return { name: 'nx-copy-assets-plugin' };
|
|
38
|
+
const relativeProjectRoot = (0, node_path_1.relative)(devkit_1.workspaceRoot, options.projectRoot);
|
|
39
|
+
return {
|
|
40
|
+
name: 'nx-copy-assets-plugin',
|
|
41
|
+
async buildStart() {
|
|
42
|
+
// Input must be relative to rootDir because CopyAssetsHandler computes
|
|
43
|
+
// destination paths using path.relative(input, globResult), and glob
|
|
44
|
+
// returns paths relative to rootDir.
|
|
45
|
+
const assets = options.assets.map((a) => {
|
|
46
|
+
if (typeof a === 'string') {
|
|
47
|
+
return (0, node_path_1.join)(relativeProjectRoot, a);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// relative() returns '' when paths are equal, normalize to '.'
|
|
51
|
+
const relativeInput = (0, node_path_1.relative)(devkit_1.workspaceRoot, a.input) || '.';
|
|
52
|
+
const { prefix: globPrefix, glob: normalizedGlob } = extractGlobLiteralPrefix(a.glob);
|
|
53
|
+
return {
|
|
54
|
+
...a,
|
|
55
|
+
input: (0, node_path_1.join)(relativeInput, globPrefix),
|
|
56
|
+
glob: normalizedGlob,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const outputDir = (0, node_path_1.isAbsolute)(options.outputPath)
|
|
61
|
+
? options.outputPath
|
|
62
|
+
: (0, node_path_1.join)(devkit_1.workspaceRoot, options.outputPath);
|
|
63
|
+
handler = new copy_assets_handler_1.CopyAssetsHandler({
|
|
64
|
+
rootDir: devkit_1.workspaceRoot,
|
|
65
|
+
projectDir: options.projectRoot,
|
|
66
|
+
outputDir,
|
|
67
|
+
assets,
|
|
68
|
+
});
|
|
69
|
+
if (this.meta.watchMode && (0, devkit_1.isDaemonEnabled)()) {
|
|
70
|
+
dispose = await handler.watchAndProcessOnAssetChange();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
async writeBundle() {
|
|
74
|
+
await handler.processAllAssetsOnce();
|
|
75
|
+
},
|
|
76
|
+
closeWatcher() {
|
|
77
|
+
dispose?.();
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-nx.d.ts","sourceRoot":"","sources":["../../../../../../packages/rollup/src/plugins/with-nx/with-nx.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,6BAA6B,EAC9B,MAAM,uCAAuC,CAAC;AAW/C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"with-nx.d.ts","sourceRoot":"","sources":["../../../../../../packages/rollup/src/plugins/with-nx/with-nx.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,6BAA6B,EAC9B,MAAM,uCAAuC,CAAC;AAW/C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAQjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AA0B9D,wBAAgB,MAAM,CACpB,UAAU,EAAE,yBAAyB,EACrC,YAAY,GAAE,MAAM,CAAC,aAAkB,EAEvC,YAAY,CAAC,EAAE,6BAA6B,EAAE,GAC7C,MAAM,CAAC,aAAa,CAwRtB"}
|
|
@@ -12,6 +12,7 @@ const node_fs_1 = require("node:fs");
|
|
|
12
12
|
const node_path_1 = require("node:path");
|
|
13
13
|
const analyze_1 = require("../analyze");
|
|
14
14
|
const delete_output_1 = require("../delete-output");
|
|
15
|
+
const nx_copy_assets_plugin_1 = require("../nx-copy-assets.plugin");
|
|
15
16
|
const generate_package_json_1 = require("../package-json/generate-package-json");
|
|
16
17
|
const swc_1 = require("../swc");
|
|
17
18
|
const get_project_node_1 = require("./get-project-node");
|
|
@@ -20,7 +21,6 @@ const normalize_options_1 = require("./normalize-options");
|
|
|
20
21
|
const commonjs = require('@rollup/plugin-commonjs');
|
|
21
22
|
const image = require('@rollup/plugin-image');
|
|
22
23
|
const json = require('@rollup/plugin-json');
|
|
23
|
-
const copy = require('rollup-plugin-copy');
|
|
24
24
|
const postcss = require('rollup-plugin-postcss');
|
|
25
25
|
const fileExtensions = ['.js', '.jsx', '.ts', '.tsx'];
|
|
26
26
|
let ts;
|
|
@@ -154,8 +154,10 @@ dependencies) {
|
|
|
154
154
|
? finalConfig.output[0].dir
|
|
155
155
|
: finalConfig.output.dir;
|
|
156
156
|
finalConfig.plugins = [
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
(0, nx_copy_assets_plugin_1.nxCopyAssetsPlugin)({
|
|
158
|
+
assets: options.assets,
|
|
159
|
+
outputPath: options.outputPath,
|
|
160
|
+
projectRoot,
|
|
159
161
|
}),
|
|
160
162
|
image(),
|
|
161
163
|
json(),
|
|
@@ -277,14 +279,6 @@ function createTsCompilerOptions(projectRoot, config, options, dependencies) {
|
|
|
277
279
|
}
|
|
278
280
|
return compilerOptions;
|
|
279
281
|
}
|
|
280
|
-
function convertCopyAssetsToRollupOptions(outputPath, assets) {
|
|
281
|
-
return assets
|
|
282
|
-
? assets.map((a) => ({
|
|
283
|
-
src: (0, node_path_1.join)(a.input, a.glob).replace(/\\/g, '/'),
|
|
284
|
-
dest: (0, node_path_1.join)(devkit_1.workspaceRoot, outputPath, a.output).replace(/\\/g, '/'),
|
|
285
|
-
}))
|
|
286
|
-
: undefined;
|
|
287
|
-
}
|
|
288
282
|
function readCompatibleFormats(config) {
|
|
289
283
|
ensureTypeScript();
|
|
290
284
|
switch (config.options.module) {
|