@nx/rollup 23.0.0-pr.35413.460eeef → 23.0.0-rc.0
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/{index.d.ts → dist/index.d.ts} +0 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +7 -0
- package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
- package/{src → dist/src}/executors/rollup/lib/normalize.d.ts +0 -1
- package/{src → dist/src}/executors/rollup/lib/normalize.js +2 -2
- package/{src → dist/src}/executors/rollup/rollup.impl.d.ts +2 -3
- package/{src → dist/src}/executors/rollup/rollup.impl.js +9 -8
- package/{src → dist/src}/executors/rollup/schema.d.ts +0 -1
- package/{src → dist/src}/executors/rollup/schema.json +2 -6
- package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/configuration.js +14 -12
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +11 -6
- package/{src → dist/src}/generators/convert-to-inferred/lib/add-plugin-registrations.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/normalize-path-options.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.js +10 -8
- package/{src → dist/src}/generators/init/schema.json +1 -1
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.d.ts +9 -0
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.js +223 -0
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md +25 -0
- package/dist/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.d.ts +2 -0
- package/dist/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.js +125 -0
- package/dist/src/migrations/update-23-0-0/remove-use-legacy-typescript-plugin.md +100 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +202 -0
- package/{src → dist/src}/plugins/analyze.d.ts +0 -1
- package/{src → dist/src}/plugins/delete-output.d.ts +0 -1
- package/{src → dist/src}/plugins/nx-copy-assets.plugin.d.ts +1 -2
- package/{src → dist/src}/plugins/nx-copy-assets.plugin.js +2 -2
- package/{src → dist/src}/plugins/package-json/generate-package-json.d.ts +0 -1
- package/{src → dist/src}/plugins/package-json/update-package-json.d.ts +0 -1
- package/{src → dist/src}/plugins/plugin.d.ts +3 -4
- package/{src → dist/src}/plugins/plugin.js +58 -27
- package/{src → dist/src}/plugins/postcss/index.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/index.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/less-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/postcss-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/sass-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/stylus-loader.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/loaders/types.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/options.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/postcss-plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/index.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/load-module.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/normalize-path.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/safe-identifier.d.ts +0 -1
- package/{src → dist/src}/plugins/postcss/utils/style-inject.d.ts +0 -1
- package/{src → dist/src}/plugins/swc.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/get-project-node.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/normalize-options.d.ts +0 -1
- package/{src → dist/src}/plugins/with-nx/normalize-options.js +3 -8
- package/dist/src/plugins/with-nx/type-definitions.d.ts +7 -0
- package/dist/src/plugins/with-nx/type-definitions.js +48 -0
- package/{src → dist/src}/plugins/with-nx/with-nx-options.d.ts +0 -5
- package/{src → dist/src}/plugins/with-nx/with-nx.d.ts +1 -2
- package/{src → dist/src}/plugins/with-nx/with-nx.js +26 -43
- package/dist/src/utils/deprecation.d.ts +3 -0
- package/dist/src/utils/deprecation.js +19 -0
- package/{src → dist/src}/utils/ensure-dependencies.d.ts +0 -1
- package/{src → dist/src}/utils/ensure-dependencies.js +10 -10
- package/{src → dist/src}/utils/fs.d.ts +0 -1
- package/{src → dist/src}/utils/has-plugin.d.ts +0 -1
- package/{src → dist/src}/utils/versions.d.ts +3 -1
- package/dist/src/utils/versions.js +18 -0
- package/{with-nx.d.ts → dist/with-nx.d.ts} +0 -1
- package/executors.json +2 -2
- package/generators.json +6 -6
- package/migrations.json +31 -2
- package/package.json +66 -12
- package/index.d.ts.map +0 -1
- package/plugin.d.ts.map +0 -1
- package/src/executors/rollup/lib/normalize.d.ts.map +0 -1
- package/src/executors/rollup/rollup.impl.d.ts.map +0 -1
- package/src/generators/configuration/configuration.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/add-plugin-registrations.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/normalize-path-options.d.ts.map +0 -1
- package/src/generators/init/init.d.ts.map +0 -1
- package/src/plugins/analyze.d.ts.map +0 -1
- package/src/plugins/delete-output.d.ts.map +0 -1
- package/src/plugins/nx-copy-assets.plugin.d.ts.map +0 -1
- package/src/plugins/package-json/generate-package-json.d.ts.map +0 -1
- package/src/plugins/package-json/update-package-json.d.ts.map +0 -1
- package/src/plugins/plugin.d.ts.map +0 -1
- package/src/plugins/postcss/index.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/index.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/less-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/postcss-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/sass-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/stylus-loader.d.ts.map +0 -1
- package/src/plugins/postcss/loaders/types.d.ts.map +0 -1
- package/src/plugins/postcss/options.d.ts.map +0 -1
- package/src/plugins/postcss/postcss-plugin.d.ts.map +0 -1
- package/src/plugins/postcss/utils/index.d.ts.map +0 -1
- package/src/plugins/postcss/utils/load-module.d.ts.map +0 -1
- package/src/plugins/postcss/utils/normalize-path.d.ts.map +0 -1
- package/src/plugins/postcss/utils/safe-identifier.d.ts.map +0 -1
- package/src/plugins/postcss/utils/style-inject.d.ts.map +0 -1
- package/src/plugins/swc.d.ts.map +0 -1
- package/src/plugins/with-nx/get-project-node.d.ts.map +0 -1
- package/src/plugins/with-nx/normalize-options.d.ts.map +0 -1
- package/src/plugins/with-nx/with-nx-options.d.ts.map +0 -1
- package/src/plugins/with-nx/with-nx.d.ts.map +0 -1
- package/src/utils/ensure-dependencies.d.ts.map +0 -1
- package/src/utils/fs.d.ts.map +0 -1
- package/src/utils/has-plugin.d.ts.map +0 -1
- package/src/utils/versions.d.ts.map +0 -1
- package/src/utils/versions.js +0 -8
- package/with-nx.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{plugin.js → dist/plugin.js} +0 -0
- /package/{src → dist/src}/generators/configuration/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/configuration/schema.json +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/add-plugin-registrations.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/extract-rollup-config-from-executor-options.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/normalize-path-options.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
- /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
- /package/{src → dist/src}/plugins/analyze.js +0 -0
- /package/{src → dist/src}/plugins/delete-output.js +0 -0
- /package/{src → dist/src}/plugins/package-json/generate-package-json.js +0 -0
- /package/{src → dist/src}/plugins/package-json/update-package-json.js +0 -0
- /package/{src → dist/src}/plugins/postcss/index.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/index.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/less-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/postcss-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/sass-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/stylus-loader.js +0 -0
- /package/{src → dist/src}/plugins/postcss/loaders/types.js +0 -0
- /package/{src → dist/src}/plugins/postcss/options.js +0 -0
- /package/{src → dist/src}/plugins/postcss/postcss-plugin.js +0 -0
- /package/{src → dist/src}/plugins/postcss/types/concat-with-sourcemaps.d.ts +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/index.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/load-module.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/normalize-path.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/safe-identifier.js +0 -0
- /package/{src → dist/src}/plugins/postcss/utils/style-inject.js +0 -0
- /package/{src → dist/src}/plugins/swc.js +0 -0
- /package/{src → dist/src}/plugins/with-nx/get-project-node.js +0 -0
- /package/{src → dist/src}/plugins/with-nx/with-nx-options.js +0 -0
- /package/{src → dist/src}/utils/fs.js +0 -0
- /package/{src → dist/src}/utils/has-plugin.js +0 -0
- /package/{with-nx.js → dist/with-nx.js} +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const ROLLUP_CONFIG_NAMES = [
|
|
7
|
+
'rollup.config.cjs',
|
|
8
|
+
'rollup.config.mjs',
|
|
9
|
+
'rollup.config.js',
|
|
10
|
+
'rollup.config.ts',
|
|
11
|
+
];
|
|
12
|
+
const PROPERTY_NAME = 'useLegacyTypescriptPlugin';
|
|
13
|
+
async function default_1(tree) {
|
|
14
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
15
|
+
// Track whether the migration actually stripped any legacy config so we
|
|
16
|
+
// only strip the orphan devDep when it was needed (a user could have
|
|
17
|
+
// installed `rollup-plugin-typescript2` for their own custom rollup setup).
|
|
18
|
+
let anyChange = false;
|
|
19
|
+
for (const [projectName] of projects) {
|
|
20
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
21
|
+
let projectJsonChanged = false;
|
|
22
|
+
if (projectConfig.targets) {
|
|
23
|
+
for (const [, targetConfig] of Object.entries(projectConfig.targets)) {
|
|
24
|
+
if (targetConfig.executor !== '@nx/rollup:rollup' &&
|
|
25
|
+
targetConfig.executor !== '@nrwl/rollup:rollup') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (targetConfig.options &&
|
|
29
|
+
'useLegacyTypescriptPlugin' in targetConfig.options) {
|
|
30
|
+
delete targetConfig.options.useLegacyTypescriptPlugin;
|
|
31
|
+
projectJsonChanged = true;
|
|
32
|
+
}
|
|
33
|
+
if (targetConfig.configurations) {
|
|
34
|
+
for (const [, config] of Object.entries(targetConfig.configurations)) {
|
|
35
|
+
if ('useLegacyTypescriptPlugin' in config) {
|
|
36
|
+
delete config.useLegacyTypescriptPlugin;
|
|
37
|
+
projectJsonChanged = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (projectJsonChanged) {
|
|
44
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
45
|
+
anyChange = true;
|
|
46
|
+
}
|
|
47
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
48
|
+
const basename = filePath.split('/').pop();
|
|
49
|
+
if (!ROLLUP_CONFIG_NAMES.includes(basename))
|
|
50
|
+
return;
|
|
51
|
+
if (stripFromRollupConfig(tree, filePath)) {
|
|
52
|
+
anyChange = true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Strip from nx.json targetDefaults (keyed by target name or executor name).
|
|
57
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
58
|
+
if (nxJson?.targetDefaults) {
|
|
59
|
+
const ROLLUP_EXECUTORS = ['@nx/rollup:rollup', '@nrwl/rollup:rollup'];
|
|
60
|
+
let nxJsonChanged = false;
|
|
61
|
+
for (const [targetOrExecutor, targetDefault] of Object.entries(nxJson.targetDefaults)) {
|
|
62
|
+
if (!ROLLUP_EXECUTORS.includes(targetOrExecutor) &&
|
|
63
|
+
!ROLLUP_EXECUTORS.includes(targetDefault.executor)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (targetDefault.options &&
|
|
67
|
+
'useLegacyTypescriptPlugin' in targetDefault.options) {
|
|
68
|
+
delete targetDefault.options.useLegacyTypescriptPlugin;
|
|
69
|
+
nxJsonChanged = true;
|
|
70
|
+
}
|
|
71
|
+
if (targetDefault.configurations) {
|
|
72
|
+
for (const [, config] of Object.entries(targetDefault.configurations)) {
|
|
73
|
+
if ('useLegacyTypescriptPlugin' in config) {
|
|
74
|
+
delete config.useLegacyTypescriptPlugin;
|
|
75
|
+
nxJsonChanged = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (nxJsonChanged) {
|
|
81
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
82
|
+
anyChange = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Only strip the orphan devDep when we actually stripped a legacy config.
|
|
86
|
+
// Skipping otherwise preserves a user's own dep on rollup-plugin-typescript2.
|
|
87
|
+
if (anyChange) {
|
|
88
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['rollup-plugin-typescript2']);
|
|
89
|
+
}
|
|
90
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
91
|
+
}
|
|
92
|
+
function stripFromRollupConfig(tree, filePath) {
|
|
93
|
+
const original = tree.read(filePath, 'utf-8');
|
|
94
|
+
if (!original?.includes(PROPERTY_NAME))
|
|
95
|
+
return false;
|
|
96
|
+
// Filter by the property NAME (not any descendant Identifier) so we don't
|
|
97
|
+
// strip `{ alias: useLegacyTypescriptPlugin }` where the identifier appears as a value.
|
|
98
|
+
// Also handle shorthand `{ useLegacyTypescriptPlugin }` — strip the entry, leave
|
|
99
|
+
// the variable declaration behind (not our problem).
|
|
100
|
+
const matches = (0, tsquery_1.query)((0, tsquery_1.ast)(original), 'PropertyAssignment, ShorthandPropertyAssignment').filter((p) => p.name && p.name.text === PROPERTY_NAME);
|
|
101
|
+
if (matches.length === 0)
|
|
102
|
+
return false;
|
|
103
|
+
// Walk in reverse so each splice doesn't shift the offsets of remaining matches
|
|
104
|
+
// (a file may legitimately contain multiple withNx({...}) calls, e.g. multi-format
|
|
105
|
+
// configs returning more than one rollup options object).
|
|
106
|
+
let updated = original;
|
|
107
|
+
for (const propNode of matches.slice().reverse()) {
|
|
108
|
+
let start = propNode.getStart();
|
|
109
|
+
let end = propNode.getEnd();
|
|
110
|
+
if (updated[end] === ',')
|
|
111
|
+
end += 1;
|
|
112
|
+
// If the property occupies its own line, drop the whole line including indentation.
|
|
113
|
+
const lineStart = updated.lastIndexOf('\n', start - 1) + 1;
|
|
114
|
+
const nextNewline = updated.indexOf('\n', end);
|
|
115
|
+
const lineEnd = nextNewline === -1 ? updated.length : nextNewline + 1;
|
|
116
|
+
if (/^\s*$/.test(updated.slice(lineStart, start)) &&
|
|
117
|
+
/^\s*$/.test(updated.slice(end, lineEnd))) {
|
|
118
|
+
start = lineStart;
|
|
119
|
+
end = lineEnd;
|
|
120
|
+
}
|
|
121
|
+
updated = updated.slice(0, start) + updated.slice(end);
|
|
122
|
+
}
|
|
123
|
+
tree.write(filePath, updated);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#### Remove the `useLegacyTypescriptPlugin` Option from the `@nx/rollup:rollup` Executor
|
|
2
|
+
|
|
3
|
+
Removes the deprecated `useLegacyTypescriptPlugin` option from the `@nx/rollup:rollup` executor. The legacy TypeScript plugin support has been dropped; the option no longer has any effect. The migration removes it from project configuration, target defaults in `nx.json`, and `rollup.config.*` files that pass it to `withNx`.
|
|
4
|
+
|
|
5
|
+
#### Sample Code Changes
|
|
6
|
+
|
|
7
|
+
Remove `useLegacyTypescriptPlugin` from the `@nx/rollup:rollup` executor options in project configuration.
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```json title="libs/my-lib/project.json" {8}
|
|
12
|
+
{
|
|
13
|
+
"targets": {
|
|
14
|
+
"build": {
|
|
15
|
+
"executor": "@nx/rollup:rollup",
|
|
16
|
+
"options": {
|
|
17
|
+
"main": "libs/my-lib/src/index.ts",
|
|
18
|
+
"outputPath": "dist/libs/my-lib",
|
|
19
|
+
"useLegacyTypescriptPlugin": true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
##### After
|
|
27
|
+
|
|
28
|
+
```json title="libs/my-lib/project.json"
|
|
29
|
+
{
|
|
30
|
+
"targets": {
|
|
31
|
+
"build": {
|
|
32
|
+
"executor": "@nx/rollup:rollup",
|
|
33
|
+
"options": {
|
|
34
|
+
"main": "libs/my-lib/src/index.ts",
|
|
35
|
+
"outputPath": "dist/libs/my-lib"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Remove `useLegacyTypescriptPlugin` from the `@nx/rollup:rollup` executor target defaults in `nx.json`.
|
|
43
|
+
|
|
44
|
+
##### Before
|
|
45
|
+
|
|
46
|
+
```json title="nx.json" {7}
|
|
47
|
+
{
|
|
48
|
+
"targetDefaults": {
|
|
49
|
+
"@nx/rollup:rollup": {
|
|
50
|
+
"options": {
|
|
51
|
+
"outputPath": "dist/{projectRoot}",
|
|
52
|
+
"tsConfig": "{projectRoot}/tsconfig.lib.json",
|
|
53
|
+
"useLegacyTypescriptPlugin": true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
##### After
|
|
61
|
+
|
|
62
|
+
```json title="nx.json"
|
|
63
|
+
{
|
|
64
|
+
"targetDefaults": {
|
|
65
|
+
"@nx/rollup:rollup": {
|
|
66
|
+
"options": {
|
|
67
|
+
"outputPath": "dist/{projectRoot}",
|
|
68
|
+
"tsConfig": "{projectRoot}/tsconfig.lib.json"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Remove `useLegacyTypescriptPlugin` from `withNx` calls in `rollup.config.*` files.
|
|
76
|
+
|
|
77
|
+
##### Before
|
|
78
|
+
|
|
79
|
+
```js title="libs/my-lib/rollup.config.cjs" {7}
|
|
80
|
+
const { withNx } = require('@nx/rollup/with-nx');
|
|
81
|
+
module.exports = withNx({
|
|
82
|
+
outputPath: '../../dist/libs/my-lib',
|
|
83
|
+
main: './src/index.ts',
|
|
84
|
+
tsConfig: './tsconfig.lib.json',
|
|
85
|
+
format: ['cjs', 'esm'],
|
|
86
|
+
useLegacyTypescriptPlugin: true,
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
##### After
|
|
91
|
+
|
|
92
|
+
```js title="libs/my-lib/rollup.config.cjs"
|
|
93
|
+
const { withNx } = require('@nx/rollup/with-nx');
|
|
94
|
+
module.exports = withNx({
|
|
95
|
+
outputPath: '../../dist/libs/my-lib',
|
|
96
|
+
main: './src/index.ts',
|
|
97
|
+
tsConfig: './tsconfig.lib.json',
|
|
98
|
+
format: ['cjs', 'esm'],
|
|
99
|
+
});
|
|
100
|
+
```
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = rewriteInternalSubpathImports;
|
|
4
|
+
exports.rewriteSubpathImports = rewriteSubpathImports;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
|
|
7
|
+
const FROM_PREFIX = '@nx/rollup/src/';
|
|
8
|
+
const TO_PUBLIC = '@nx/rollup';
|
|
9
|
+
const TO_INTERNAL = '@nx/rollup/internal';
|
|
10
|
+
// Symbols exported from `@nx/rollup`'s public entry (packages/rollup/index.ts).
|
|
11
|
+
// A named import/export of one of these from `@nx/rollup/src/*` is routed to
|
|
12
|
+
// the public `@nx/rollup` entry; everything else goes to `@nx/rollup/internal`.
|
|
13
|
+
const PUBLIC_SYMBOLS = new Set([
|
|
14
|
+
'AssetGlobPattern',
|
|
15
|
+
'Globals',
|
|
16
|
+
'RollupExecutorOptions',
|
|
17
|
+
'configurationGenerator',
|
|
18
|
+
'createRollupOptions',
|
|
19
|
+
'rollupExecutor',
|
|
20
|
+
'rollupInitGenerator',
|
|
21
|
+
'rollupProjectGenerator',
|
|
22
|
+
]);
|
|
23
|
+
// Methods on `jest` and `vi` that take a module specifier as their first arg.
|
|
24
|
+
const MOCK_HELPER_METHODS = new Set([
|
|
25
|
+
'mock',
|
|
26
|
+
'unmock',
|
|
27
|
+
'doMock',
|
|
28
|
+
'dontMock',
|
|
29
|
+
'requireActual',
|
|
30
|
+
'requireMock',
|
|
31
|
+
'importActual',
|
|
32
|
+
'importMock',
|
|
33
|
+
]);
|
|
34
|
+
let ts;
|
|
35
|
+
async function rewriteInternalSubpathImports(tree) {
|
|
36
|
+
let touchedCount = 0;
|
|
37
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
38
|
+
if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const original = tree.read(filePath, 'utf-8');
|
|
42
|
+
if (!original || !original.includes(FROM_PREFIX)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const updated = rewriteSubpathImports(original);
|
|
46
|
+
if (updated !== original) {
|
|
47
|
+
tree.write(filePath, updated);
|
|
48
|
+
touchedCount += 1;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (touchedCount > 0) {
|
|
52
|
+
devkit_1.logger.info(`Rewrote @nx/rollup/src/* imports in ${touchedCount} file(s) ` +
|
|
53
|
+
`(public symbols to @nx/rollup, internals to @nx/rollup/internal).`);
|
|
54
|
+
}
|
|
55
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
56
|
+
}
|
|
57
|
+
function rewriteSubpathImports(source) {
|
|
58
|
+
ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
|
|
59
|
+
const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
|
|
60
|
+
/* setParentNodes */ true, ts.ScriptKind.TSX);
|
|
61
|
+
const changes = [];
|
|
62
|
+
for (const stmt of sourceFile.statements) {
|
|
63
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
64
|
+
collectImportRewrite(sourceFile, stmt, changes);
|
|
65
|
+
}
|
|
66
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
67
|
+
collectExportRewrite(sourceFile, stmt, changes);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
collectCallExpressionRewrites(sourceFile, changes);
|
|
71
|
+
return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
|
|
72
|
+
}
|
|
73
|
+
function isSubpathSpecifier(node) {
|
|
74
|
+
return ts.isStringLiteral(node) && node.text.startsWith(FROM_PREFIX);
|
|
75
|
+
}
|
|
76
|
+
function collectImportRewrite(sourceFile, stmt, changes) {
|
|
77
|
+
if (!isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const clause = stmt.importClause;
|
|
81
|
+
// Pure named imports (`import { a, b } from '...'`) can be split by symbol.
|
|
82
|
+
// A default or namespace import grabs the whole module, so it can't be
|
|
83
|
+
// split — route it wholesale to the internal entry.
|
|
84
|
+
if (clause &&
|
|
85
|
+
!clause.name &&
|
|
86
|
+
clause.namedBindings &&
|
|
87
|
+
ts.isNamedImports(clause.namedBindings)) {
|
|
88
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, clause.isTypeOnly, clause.namedBindings.elements, 'import', changes);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
92
|
+
}
|
|
93
|
+
function collectExportRewrite(sourceFile, stmt, changes) {
|
|
94
|
+
if (!stmt.moduleSpecifier || !isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// `export { a, b } from '...'` can be split; `export * from '...'` cannot.
|
|
98
|
+
if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
|
|
99
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, stmt.isTypeOnly, stmt.exportClause.elements, 'export', changes);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Partition the named bindings of an import/export declaration into the ones
|
|
106
|
+
* that resolve to `@nx/rollup`'s public entry and the ones that don't. If both
|
|
107
|
+
* groups are non-empty, the single declaration is split into two.
|
|
108
|
+
*/
|
|
109
|
+
function rewriteNamedDeclaration(sourceFile, decl, specifier, isTypeOnly, elements, keyword, changes) {
|
|
110
|
+
const publicEls = [];
|
|
111
|
+
const internalEls = [];
|
|
112
|
+
for (const el of elements) {
|
|
113
|
+
// `propertyName` is the original name in `orig as alias`; fall back to
|
|
114
|
+
// `name` for the plain `orig` form.
|
|
115
|
+
const importedName = (el.propertyName ?? el.name).text;
|
|
116
|
+
(PUBLIC_SYMBOLS.has(importedName) ? publicEls : internalEls).push(el);
|
|
117
|
+
}
|
|
118
|
+
if (publicEls.length === 0) {
|
|
119
|
+
replaceSpecifier(sourceFile, specifier, TO_INTERNAL, changes);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (internalEls.length === 0) {
|
|
123
|
+
replaceSpecifier(sourceFile, specifier, TO_PUBLIC, changes);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// Mixed — replace the whole declaration with one statement per target.
|
|
127
|
+
const quote = sourceFile.text.charAt(specifier.getStart(sourceFile));
|
|
128
|
+
const start = decl.getStart(sourceFile);
|
|
129
|
+
const end = decl.getEnd();
|
|
130
|
+
const semicolon = sourceFile.text.charAt(end - 1) === ';' ? ';' : '';
|
|
131
|
+
const prefix = isTypeOnly ? `${keyword} type` : keyword;
|
|
132
|
+
const render = (els, target) => `${prefix} { ${els
|
|
133
|
+
.map((el) => el.getText(sourceFile))
|
|
134
|
+
.join(', ')} } from ${quote}${target}${quote}${semicolon}`;
|
|
135
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
136
|
+
type: devkit_1.ChangeType.Insert,
|
|
137
|
+
index: start,
|
|
138
|
+
text: `${render(publicEls, TO_PUBLIC)}\n${render(internalEls, TO_INTERNAL)}`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function collectCallExpressionRewrites(sourceFile, changes) {
|
|
142
|
+
const visit = (node) => {
|
|
143
|
+
if (ts.isCallExpression(node) &&
|
|
144
|
+
shouldRewriteCallExpression(node) &&
|
|
145
|
+
node.arguments.length >= 1 &&
|
|
146
|
+
isSubpathSpecifier(node.arguments[0])) {
|
|
147
|
+
// `require(...)`, dynamic `import(...)` and `jest.mock(...)` reference
|
|
148
|
+
// the module as a whole and can't be symbol-split, so they go to the
|
|
149
|
+
// internal entry.
|
|
150
|
+
replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
|
|
151
|
+
}
|
|
152
|
+
else if (ts.isImportTypeNode(node)) {
|
|
153
|
+
// `typeof import('...')` parses as an `ImportTypeNode`, not a
|
|
154
|
+
// CallExpression — its argument is `LiteralTypeNode<StringLiteral>`.
|
|
155
|
+
// The whole module is referenced, so it can't be symbol-split.
|
|
156
|
+
const literal = getImportTypeStringLiteral(node);
|
|
157
|
+
if (literal && literal.text.startsWith(FROM_PREFIX)) {
|
|
158
|
+
replaceSpecifier(sourceFile, literal, TO_INTERNAL, changes);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
ts.forEachChild(node, visit);
|
|
162
|
+
};
|
|
163
|
+
visit(sourceFile);
|
|
164
|
+
}
|
|
165
|
+
function getImportTypeStringLiteral(node) {
|
|
166
|
+
const arg = node.argument;
|
|
167
|
+
if (arg && ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal)) {
|
|
168
|
+
return arg.literal;
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
function shouldRewriteCallExpression(call) {
|
|
173
|
+
const callee = call.expression;
|
|
174
|
+
// `require('...')`
|
|
175
|
+
if (ts.isIdentifier(callee) && callee.text === 'require')
|
|
176
|
+
return true;
|
|
177
|
+
// dynamic `import('...')` (runtime form parses as a CallExpression whose
|
|
178
|
+
// callee is the `import` keyword). The `typeof import('...')` type-position
|
|
179
|
+
// form is an `ImportTypeNode` (handled in `collectCallExpressionRewrites`).
|
|
180
|
+
if (callee.kind === ts.SyntaxKind.ImportKeyword)
|
|
181
|
+
return true;
|
|
182
|
+
// `jest.mock(...)` / `vi.mock(...)` and friends.
|
|
183
|
+
if (ts.isPropertyAccessExpression(callee)) {
|
|
184
|
+
const obj = callee.expression;
|
|
185
|
+
if (ts.isIdentifier(obj) &&
|
|
186
|
+
(obj.text === 'jest' || obj.text === 'vi') &&
|
|
187
|
+
MOCK_HELPER_METHODS.has(callee.name.text)) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
function replaceSpecifier(sourceFile, literal, target, changes) {
|
|
194
|
+
const start = literal.getStart(sourceFile);
|
|
195
|
+
const end = literal.getEnd();
|
|
196
|
+
const quote = sourceFile.text.charAt(start);
|
|
197
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
198
|
+
type: devkit_1.ChangeType.Insert,
|
|
199
|
+
index: start,
|
|
200
|
+
text: `${quote}${target}${quote}`,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from 'rollup';
|
|
2
|
-
import { AssetGlob } from '@nx/js/
|
|
2
|
+
import { AssetGlob } from '@nx/js/internal';
|
|
3
3
|
export interface NxCopyAssetsPluginOptions {
|
|
4
4
|
assets: (string | AssetGlob)[];
|
|
5
5
|
outputPath: string;
|
|
@@ -21,4 +21,3 @@ export declare function extractGlobLiteralPrefix(glob: string): {
|
|
|
21
21
|
glob: string;
|
|
22
22
|
};
|
|
23
23
|
export declare function nxCopyAssetsPlugin(options: NxCopyAssetsPluginOptions): Plugin;
|
|
24
|
-
//# sourceMappingURL=nx-copy-assets.plugin.d.ts.map
|
|
@@ -4,7 +4,7 @@ exports.extractGlobLiteralPrefix = extractGlobLiteralPrefix;
|
|
|
4
4
|
exports.nxCopyAssetsPlugin = nxCopyAssetsPlugin;
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const
|
|
7
|
+
const internal_1 = require("@nx/js/internal");
|
|
8
8
|
/**
|
|
9
9
|
* Splits a glob into its literal directory prefix and the remaining pattern.
|
|
10
10
|
* CopyAssetsHandler expects input to be a directory and glob to be a pattern
|
|
@@ -60,7 +60,7 @@ function nxCopyAssetsPlugin(options) {
|
|
|
60
60
|
const outputDir = (0, node_path_1.isAbsolute)(options.outputPath)
|
|
61
61
|
? options.outputPath
|
|
62
62
|
: (0, node_path_1.join)(devkit_1.workspaceRoot, options.outputPath);
|
|
63
|
-
handler = new
|
|
63
|
+
handler = new internal_1.CopyAssetsHandler({
|
|
64
64
|
rootDir: devkit_1.workspaceRoot,
|
|
65
65
|
projectDir: options.projectRoot,
|
|
66
66
|
outputDir,
|
|
@@ -11,4 +11,3 @@ export interface GeneratePackageJsonOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const pluginName = "rollup-plugin-nx-generate-package-json";
|
|
13
13
|
export declare function generatePackageJson(options: GeneratePackageJsonOptions, packageJson: PackageJson): Plugin;
|
|
14
|
-
//# sourceMappingURL=generate-package-json.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreateDependencies,
|
|
1
|
+
import { type CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
2
2
|
/**
|
|
3
3
|
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
4
4
|
*/
|
|
@@ -8,6 +8,5 @@ export interface RollupPluginOptions {
|
|
|
8
8
|
buildDepsTargetName?: string;
|
|
9
9
|
watchDepsTargetName?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const createNodes:
|
|
12
|
-
export declare const createNodesV2:
|
|
13
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
11
|
+
export declare const createNodes: CreateNodes<RollupPluginOptions>;
|
|
12
|
+
export declare const createNodesV2: CreateNodes<RollupPluginOptions>;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const fs_1 = require("fs");
|
|
7
8
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
9
9
|
const js_1 = require("@nx/js");
|
|
10
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
11
10
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
12
|
-
const
|
|
13
|
-
const util_1 = require("@nx/js/src/plugins/typescript/util");
|
|
14
|
-
function readTargetsCache(cachePath) {
|
|
15
|
-
return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
|
|
16
|
-
}
|
|
17
|
-
function writeTargetsToCache(cachePath, results) {
|
|
18
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
19
|
-
}
|
|
11
|
+
const internal_2 = require("@nx/js/internal");
|
|
20
12
|
/**
|
|
21
13
|
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
22
14
|
*/
|
|
@@ -31,34 +23,50 @@ exports.createNodes = [
|
|
|
31
23
|
const normalizedOptions = normalizeOptions(options);
|
|
32
24
|
const optionsHash = (0, file_hasher_1.hashObject)(normalizedOptions);
|
|
33
25
|
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `rollup-${optionsHash}.hash`);
|
|
34
|
-
const targetsCache =
|
|
35
|
-
const isTsSolutionSetup = (0,
|
|
36
|
-
const
|
|
26
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
27
|
+
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)();
|
|
28
|
+
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
29
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
30
|
+
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
37
31
|
try {
|
|
38
|
-
|
|
32
|
+
const { entries, preErrors } = await filterRollupConfigs(configFilePaths, context);
|
|
33
|
+
const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), normalizedOptions, context, entries.map(() => [lockFileName]));
|
|
34
|
+
let results = [];
|
|
35
|
+
let nodeErrors = [];
|
|
36
|
+
try {
|
|
37
|
+
results = await (0, devkit_1.createNodesFromFiles)((configFile, _, ctx, idx) => createNodesInternal(configFile, normalizedOptions, ctx, targetsCache, isTsSolutionSetup, pmc, projectHashes[idx]), entries.map((e) => e.configFile), normalizedOptions, context);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (e instanceof devkit_1.AggregateCreateNodesError) {
|
|
41
|
+
results = e.partialResults ?? [];
|
|
42
|
+
nodeErrors = e.errors;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const allErrors = [...preErrors, ...nodeErrors];
|
|
49
|
+
if (allErrors.length > 0) {
|
|
50
|
+
throw new devkit_1.AggregateCreateNodesError(allErrors, results);
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
39
53
|
}
|
|
40
54
|
finally {
|
|
41
|
-
|
|
55
|
+
targetsCache.writeToDisk();
|
|
42
56
|
}
|
|
43
57
|
},
|
|
44
58
|
];
|
|
45
59
|
exports.createNodesV2 = exports.createNodes;
|
|
46
|
-
async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc) {
|
|
60
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc, hash) {
|
|
47
61
|
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const siblingFiles = (0, fs_1.readdirSync)(fullyQualifiedProjectRoot);
|
|
51
|
-
if (!siblingFiles.includes('package.json') &&
|
|
52
|
-
!siblingFiles.includes('project.json')) {
|
|
53
|
-
return {};
|
|
62
|
+
if (!targetsCache.has(hash)) {
|
|
63
|
+
targetsCache.set(hash, await buildRollupTarget(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc));
|
|
54
64
|
}
|
|
55
|
-
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
56
|
-
targetsCache[hash] ??= await buildRollupTarget(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc);
|
|
57
65
|
return {
|
|
58
66
|
projects: {
|
|
59
67
|
[projectRoot]: {
|
|
60
68
|
root: projectRoot,
|
|
61
|
-
targets: targetsCache
|
|
69
|
+
targets: targetsCache.get(hash),
|
|
62
70
|
},
|
|
63
71
|
},
|
|
64
72
|
};
|
|
@@ -82,7 +90,7 @@ async function buildRollupTarget(configFilePath, projectRoot, options, context,
|
|
|
82
90
|
}
|
|
83
91
|
const isTsConfig = configFilePath.endsWith('ts');
|
|
84
92
|
const tsConfigPlugin = '@rollup/plugin-typescript';
|
|
85
|
-
const namedInputs = (0,
|
|
93
|
+
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
86
94
|
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
|
|
87
95
|
)).options;
|
|
88
96
|
const outputs = getOutputs(rollupConfig, projectRoot);
|
|
@@ -99,6 +107,7 @@ async function buildRollupTarget(configFilePath, projectRoot, options, context,
|
|
|
99
107
|
? ['production', '^production']
|
|
100
108
|
: ['default', '^default']),
|
|
101
109
|
{ externalDependencies: ['rollup'] },
|
|
110
|
+
internal_2.TS_SOLUTION_SETUP_TSCONFIG_INPUT,
|
|
102
111
|
],
|
|
103
112
|
outputs,
|
|
104
113
|
metadata: {
|
|
@@ -120,7 +129,7 @@ async function buildRollupTarget(configFilePath, projectRoot, options, context,
|
|
|
120
129
|
'@nx/js:typescript-sync',
|
|
121
130
|
];
|
|
122
131
|
}
|
|
123
|
-
(0,
|
|
132
|
+
(0, internal_2.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
|
|
124
133
|
return targets;
|
|
125
134
|
}
|
|
126
135
|
function getOutputs(rollupConfigs, projectRoot) {
|
|
@@ -149,6 +158,28 @@ function getOutputs(rollupConfigs, projectRoot) {
|
|
|
149
158
|
}
|
|
150
159
|
return Array.from(outputs);
|
|
151
160
|
}
|
|
161
|
+
async function filterRollupConfigs(configFiles, context) {
|
|
162
|
+
const preErrors = [];
|
|
163
|
+
const candidates = await Promise.all(configFiles.map(async (configFile) => {
|
|
164
|
+
try {
|
|
165
|
+
const projectRoot = (0, path_1.dirname)(configFile);
|
|
166
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
167
|
+
if (!siblingFiles.includes('package.json') &&
|
|
168
|
+
!siblingFiles.includes('project.json')) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return { configFile, projectRoot };
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
preErrors.push([configFile, e]);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
return {
|
|
179
|
+
entries: candidates.filter((c) => c !== null),
|
|
180
|
+
preErrors,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
152
183
|
function normalizeOptions(options) {
|
|
153
184
|
return {
|
|
154
185
|
buildTargetName: options.buildTargetName ?? 'build',
|
|
@@ -13,4 +13,3 @@
|
|
|
13
13
|
export { postcss } from './postcss-plugin';
|
|
14
14
|
export { postcss as default } from './postcss-plugin';
|
|
15
15
|
export type { PostCSSPluginOptions, PostCSSModulesOptions, FilterPattern, UseOptions, LessOptions, SassOptions, StylusOptions, } from './options';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|