@nx/js 19.7.2 → 19.8.0-beta.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/package.json +4 -5
- package/src/executors/swc/swc.impl.js +2 -2
- package/src/executors/verdaccio/verdaccio.impl.js +3 -3
- package/src/generators/library/library.js +13 -10
- package/src/generators/release-version/release-version.js +2 -2
- package/src/generators/typescript-sync/typescript-sync.js +33 -11
- package/src/plugins/typescript/plugin.js +4 -0
- package/src/utils/assets/copy-assets-handler.js +9 -9
- package/src/utils/inline.js +8 -9
- package/src/utils/package-json/update-package-json.js +3 -4
- package/src/utils/swc/compile-swc.js +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.8.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.2",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@babel/runtime": "^7.22.6",
|
|
42
|
-
"@nx/devkit": "19.
|
|
43
|
-
"@nx/workspace": "19.
|
|
42
|
+
"@nx/devkit": "19.8.0-beta.0",
|
|
43
|
+
"@nx/workspace": "19.8.0-beta.0",
|
|
44
44
|
"babel-plugin-const-enum": "^1.0.1",
|
|
45
45
|
"babel-plugin-macros": "^2.8.0",
|
|
46
46
|
"babel-plugin-transform-typescript-metadata": "^0.3.1",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"columnify": "^1.6.0",
|
|
49
49
|
"detect-port": "^1.5.1",
|
|
50
50
|
"fast-glob": "3.2.7",
|
|
51
|
-
"fs-extra": "^11.1.0",
|
|
52
51
|
"ignore": "^5.0.4",
|
|
53
52
|
"js-tokens": "^4.0.0",
|
|
54
53
|
"jsonc-parser": "3.2.0",
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
"ts-node": "10.9.1",
|
|
62
61
|
"tsconfig-paths": "^4.1.2",
|
|
63
62
|
"tslib": "^2.3.0",
|
|
64
|
-
"@nrwl/js": "19.
|
|
63
|
+
"@nrwl/js": "19.8.0-beta.0"
|
|
65
64
|
},
|
|
66
65
|
"peerDependencies": {
|
|
67
66
|
"verdaccio": "^5.0.4"
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.swcExecutor = swcExecutor;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const assets_1 = require("../../utils/assets/assets");
|
|
6
|
-
const fs_extra_1 = require("fs-extra");
|
|
7
6
|
const fast_glob_1 = require("fast-glob");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const assets_2 = require("../../utils/assets");
|
|
10
10
|
const check_dependencies_1 = require("../../utils/check-dependencies");
|
|
@@ -129,7 +129,7 @@ async function* swcExecutor(_options, context) {
|
|
|
129
129
|
function removeTmpSwcrc(swcrcPath) {
|
|
130
130
|
if (swcrcPath.includes((0, path_1.normalize)('tmp/')) &&
|
|
131
131
|
swcrcPath.includes('.generated.swcrc')) {
|
|
132
|
-
(0,
|
|
132
|
+
(0, node_fs_1.rmSync)((0, path_1.dirname)(swcrcPath), { recursive: true, force: true });
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
function createEntryPoints(options, context) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verdaccioExecutor = verdaccioExecutor;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const fs_extra_1 = require("fs-extra");
|
|
6
5
|
const child_process_1 = require("child_process");
|
|
7
6
|
const detectPort = require("detect-port");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const semver_1 = require("semver");
|
|
10
10
|
let childProcess;
|
|
@@ -26,8 +26,8 @@ async function verdaccioExecutor(options, context) {
|
|
|
26
26
|
}
|
|
27
27
|
if (options.storage) {
|
|
28
28
|
options.storage = (0, path_1.resolve)(context.root, options.storage);
|
|
29
|
-
if (options.clear && (0,
|
|
30
|
-
(0,
|
|
29
|
+
if (options.clear && (0, node_fs_1.existsSync)(options.storage)) {
|
|
30
|
+
(0, node_fs_1.rmSync)(options.storage, { recursive: true, force: true });
|
|
31
31
|
console.log(`Cleared local registry storage folder ${options.storage}`);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -221,7 +221,13 @@ async function addLint(tree, options) {
|
|
|
221
221
|
files: ['*.json'],
|
|
222
222
|
parser: 'jsonc-eslint-parser',
|
|
223
223
|
rules: {
|
|
224
|
-
'@nx/dependency-checks':
|
|
224
|
+
'@nx/dependency-checks': [
|
|
225
|
+
'error',
|
|
226
|
+
{
|
|
227
|
+
// With flat configs, we don't want to include imports in the eslint js/cjs/mjs files to be checked
|
|
228
|
+
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
|
|
229
|
+
},
|
|
230
|
+
],
|
|
225
231
|
},
|
|
226
232
|
});
|
|
227
233
|
}
|
|
@@ -244,21 +250,18 @@ async function addLint(tree, options) {
|
|
|
244
250
|
ruleOptions = {};
|
|
245
251
|
}
|
|
246
252
|
if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') {
|
|
247
|
-
ruleOptions.ignoredFiles
|
|
248
|
-
|
|
249
|
-
];
|
|
253
|
+
ruleOptions.ignoredFiles ??= [];
|
|
254
|
+
ruleOptions.ignoredFiles.push('{projectRoot}/vite.config.{js,ts,mjs,mts}');
|
|
250
255
|
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
|
|
251
256
|
}
|
|
252
257
|
else if (options.bundler === 'rollup') {
|
|
253
|
-
ruleOptions.ignoredFiles
|
|
254
|
-
|
|
255
|
-
];
|
|
258
|
+
ruleOptions.ignoredFiles ??= [];
|
|
259
|
+
ruleOptions.ignoredFiles.push('{projectRoot}/rollup.config.{js,ts,mjs,mts}');
|
|
256
260
|
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
|
|
257
261
|
}
|
|
258
262
|
else if (options.bundler === 'esbuild') {
|
|
259
|
-
ruleOptions.ignoredFiles
|
|
260
|
-
|
|
261
|
-
];
|
|
263
|
+
ruleOptions.ignoredFiles ??= [];
|
|
264
|
+
ruleOptions.ignoredFiles.push('{projectRoot}/esbuild.config.{js,ts,mjs,mts}');
|
|
262
265
|
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
|
|
263
266
|
}
|
|
264
267
|
return o;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.releaseVersionGenerator = releaseVersionGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const chalk = require("chalk");
|
|
6
|
-
const fs_extra_1 = require("fs-extra");
|
|
7
6
|
const node_child_process_1 = require("node:child_process");
|
|
7
|
+
const promises_1 = require("node:fs/promises");
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const config_1 = require("nx/src/command-line/release/config/config");
|
|
10
10
|
const git_1 = require("nx/src/command-line/release/utils/git");
|
|
@@ -338,7 +338,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
338
338
|
(options.releaseGroup.resolvedVersionPlans || []).forEach((p) => {
|
|
339
339
|
deleteVersionPlanCallbacks.push(async (dryRun) => {
|
|
340
340
|
if (!dryRun) {
|
|
341
|
-
await (0,
|
|
341
|
+
await (0, promises_1.rm)(p.absolutePath, { recursive: true, force: true });
|
|
342
342
|
// the relative path is easier to digest, so use that for
|
|
343
343
|
// git operations and logging
|
|
344
344
|
return [p.relativePath];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.syncGenerator = syncGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ignore_1 = require("ignore");
|
|
5
6
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
6
7
|
const posix_1 = require("node:path/posix");
|
|
7
8
|
const ts = require("typescript");
|
|
@@ -84,28 +85,30 @@ async function syncGenerator(tree) {
|
|
|
84
85
|
patchTsconfigJsonReferences(tree, rawTsconfigContentsCache, rootTsconfigPath, updatedReferences);
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
const userOptions = nxJson.sync?.generatorOptions?.['@nx/js:typescript-sync'];
|
|
89
|
+
const { runtimeTsConfigFileNames } = {
|
|
90
|
+
runtimeTsConfigFileNames: userOptions?.runtimeTsConfigFileNames ??
|
|
91
|
+
COMMON_RUNTIME_TS_CONFIG_FILE_NAMES,
|
|
92
|
+
};
|
|
90
93
|
const collectedDependencies = new Map();
|
|
91
|
-
for (const [
|
|
92
|
-
if (!projectGraph.nodes[
|
|
93
|
-
projectGraph.nodes[
|
|
94
|
+
for (const [projectName, data] of Object.entries(projectGraph.dependencies)) {
|
|
95
|
+
if (!projectGraph.nodes[projectName] ||
|
|
96
|
+
projectGraph.nodes[projectName].data.root === '.' ||
|
|
94
97
|
!data.length) {
|
|
95
98
|
continue;
|
|
96
99
|
}
|
|
97
100
|
// Get the source project nodes for the source and target
|
|
98
|
-
const sourceProjectNode = projectGraph.nodes[
|
|
101
|
+
const sourceProjectNode = projectGraph.nodes[projectName];
|
|
99
102
|
// Find the relevant tsconfig file for the source project
|
|
100
103
|
const sourceProjectTsconfigPath = (0, devkit_1.joinPathFragments)(sourceProjectNode.data.root, 'tsconfig.json');
|
|
101
104
|
if (!tsconfigExists(tree, rawTsconfigContentsCache, sourceProjectTsconfigPath)) {
|
|
102
105
|
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
103
|
-
devkit_1.logger.warn(`Skipping project "${
|
|
106
|
+
devkit_1.logger.warn(`Skipping project "${projectName}" as there is no tsconfig.json file found in the project root "${sourceProjectNode.data.root}".`);
|
|
104
107
|
}
|
|
105
108
|
continue;
|
|
106
109
|
}
|
|
107
110
|
// Collect the dependencies of the source project
|
|
108
|
-
const dependencies = collectProjectDependencies(tree,
|
|
111
|
+
const dependencies = collectProjectDependencies(tree, projectName, projectGraph, collectedDependencies);
|
|
109
112
|
if (!dependencies.length) {
|
|
110
113
|
continue;
|
|
111
114
|
}
|
|
@@ -152,6 +155,7 @@ function tsconfigExists(tree, rawTsconfigContentsCache, tsconfigPath) {
|
|
|
152
155
|
function updateTsConfigReferences(tree, tsSysFromTree, rawTsconfigContentsCache, tsconfigHasCompositeEnabledCache, tsConfigPath, dependencies, projectRoot, projectRoots, runtimeTsConfigFileName, possibleRuntimeTsConfigFileNames) {
|
|
153
156
|
const stringifiedJsonContents = readRawTsconfigContents(tree, rawTsconfigContentsCache, tsConfigPath);
|
|
154
157
|
const tsConfig = (0, devkit_1.parseJson)(stringifiedJsonContents);
|
|
158
|
+
const ignoredReferences = new Set(tsConfig.nx?.sync?.ignoredReferences ?? []);
|
|
155
159
|
// We have at least one dependency so we can safely set it to an empty array if not already set
|
|
156
160
|
const references = [];
|
|
157
161
|
const originalReferencesSet = new Set();
|
|
@@ -159,10 +163,17 @@ function updateTsConfigReferences(tree, tsSysFromTree, rawTsconfigContentsCache,
|
|
|
159
163
|
for (const ref of tsConfig.references ?? []) {
|
|
160
164
|
const normalizedPath = normalizeReferencePath(ref.path);
|
|
161
165
|
originalReferencesSet.add(normalizedPath);
|
|
166
|
+
if (ignoredReferences.has(ref.path)) {
|
|
167
|
+
// we keep the user-defined ignored references
|
|
168
|
+
references.push(ref);
|
|
169
|
+
newReferencesSet.add(normalizedPath);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
162
172
|
// reference path is relative to the tsconfig file
|
|
163
173
|
const resolvedRefPath = getTsConfigPathFromReferencePath(tree, tsConfigPath, ref.path);
|
|
164
|
-
if (isProjectReferenceWithinNxProject(tree, rawTsconfigContentsCache, resolvedRefPath, projectRoot, projectRoots)
|
|
165
|
-
|
|
174
|
+
if (isProjectReferenceWithinNxProject(tree, rawTsconfigContentsCache, resolvedRefPath, projectRoot, projectRoots) ||
|
|
175
|
+
isProjectReferenceIgnored(tree, resolvedRefPath)) {
|
|
176
|
+
// we keep all references within the current Nx project or that are ignored
|
|
166
177
|
references.push(ref);
|
|
167
178
|
newReferencesSet.add(normalizedPath);
|
|
168
179
|
}
|
|
@@ -277,6 +288,17 @@ function isProjectReferenceWithinNxProject(tree, rawTsconfigContentsCache, refTs
|
|
|
277
288
|
// it's inside the project root, so it's an internal project reference
|
|
278
289
|
return true;
|
|
279
290
|
}
|
|
291
|
+
function isProjectReferenceIgnored(tree, refTsConfigPath) {
|
|
292
|
+
const ig = (0, ignore_1.default)();
|
|
293
|
+
if (tree.exists('.gitignore')) {
|
|
294
|
+
ig.add('.git');
|
|
295
|
+
ig.add(tree.read('.gitignore', 'utf-8'));
|
|
296
|
+
}
|
|
297
|
+
if (tree.exists('.nxignore')) {
|
|
298
|
+
ig.add(tree.read('.nxignore', 'utf-8'));
|
|
299
|
+
}
|
|
300
|
+
return ig.ignores(refTsConfigPath);
|
|
301
|
+
}
|
|
280
302
|
function getTsConfigDirName(tree, rawTsconfigContentsCache, tsConfigPath) {
|
|
281
303
|
return (rawTsconfigContentsCache.has(tsConfigPath)
|
|
282
304
|
? true
|
|
@@ -56,6 +56,10 @@ exports.createNodes = [
|
|
|
56
56
|
async function createNodesInternal(configFilePath, options, context, targetsCache) {
|
|
57
57
|
const projectRoot = (0, node_path_1.dirname)(configFilePath);
|
|
58
58
|
const fullConfigPath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
|
|
59
|
+
// Do not create a project for the workspace root tsconfig files.
|
|
60
|
+
if (projectRoot === '.') {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
59
63
|
// Do not create a project if package.json and project.json isn't there.
|
|
60
64
|
const siblingFiles = (0, node_fs_1.readdirSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot));
|
|
61
65
|
if (!siblingFiles.includes('package.json') &&
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CopyAssetsHandler = exports.defaultFileEventHandler = void 0;
|
|
4
4
|
const minimatch_1 = require("minimatch");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
5
6
|
const pathPosix = require("node:path/posix");
|
|
6
7
|
const path = require("node:path");
|
|
7
|
-
const fse = require("fs-extra");
|
|
8
8
|
const ignore_1 = require("ignore");
|
|
9
9
|
const fg = require("fast-glob");
|
|
10
10
|
const devkit_1 = require("@nx/devkit");
|
|
11
11
|
const client_1 = require("nx/src/daemon/client/client");
|
|
12
12
|
const defaultFileEventHandler = (events) => {
|
|
13
13
|
const dirs = new Set(events.map((event) => path.dirname(event.dest)));
|
|
14
|
-
dirs.forEach((d) =>
|
|
14
|
+
dirs.forEach((d) => (0, node_fs_1.mkdirSync)(d, { recursive: true }));
|
|
15
15
|
events.forEach((event) => {
|
|
16
16
|
if (event.type === 'create' || event.type === 'update') {
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if ((0, node_fs_1.lstatSync)(event.src).isFile()) {
|
|
18
|
+
(0, node_fs_1.copyFileSync)(event.src, event.dest);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
else if (event.type === 'delete') {
|
|
22
|
-
|
|
22
|
+
(0, node_fs_1.rmSync)(event.dest, { recursive: true, force: true });
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
devkit_1.logger.error(`Unknown file event: ${event.type}`);
|
|
@@ -37,10 +37,10 @@ class CopyAssetsHandler {
|
|
|
37
37
|
this.ignore = (0, ignore_1.default)();
|
|
38
38
|
const gitignore = pathPosix.join(opts.rootDir, '.gitignore');
|
|
39
39
|
const nxignore = pathPosix.join(opts.rootDir, '.nxignore');
|
|
40
|
-
if (
|
|
41
|
-
this.ignore.add(
|
|
42
|
-
if (
|
|
43
|
-
this.ignore.add(
|
|
40
|
+
if ((0, node_fs_1.existsSync)(gitignore))
|
|
41
|
+
this.ignore.add((0, node_fs_1.readFileSync)(gitignore).toString());
|
|
42
|
+
if ((0, node_fs_1.existsSync)(nxignore))
|
|
43
|
+
this.ignore.add((0, node_fs_1.readFileSync)(nxignore).toString());
|
|
44
44
|
this.assetGlobs = opts.assets.map((f) => {
|
|
45
45
|
let isGlob = false;
|
|
46
46
|
let pattern;
|
package/src/utils/inline.js
CHANGED
|
@@ -5,9 +5,8 @@ exports.handleInliningBuild = handleInliningBuild;
|
|
|
5
5
|
exports.postProcessInlinedDependencies = postProcessInlinedDependencies;
|
|
6
6
|
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
10
|
function isInlineGraphEmpty(inlineGraph) {
|
|
12
11
|
return Object.keys(inlineGraph.nodes).length === 0;
|
|
13
12
|
}
|
|
@@ -40,7 +39,7 @@ function postProcessInlinedDependencies(outputPath, parentOutputPath, inlineGrap
|
|
|
40
39
|
const destDepOutputPath = (0, path_1.join)(outputPath, inlineDependency.name);
|
|
41
40
|
const isBuildable = !!inlineDependency.buildOutputPath;
|
|
42
41
|
if (isBuildable) {
|
|
43
|
-
(0,
|
|
42
|
+
(0, node_fs_1.cpSync)(depOutputPath, destDepOutputPath, { recursive: true });
|
|
44
43
|
}
|
|
45
44
|
else {
|
|
46
45
|
movePackage(depOutputPath, destDepOutputPath);
|
|
@@ -51,7 +50,7 @@ function postProcessInlinedDependencies(outputPath, parentOutputPath, inlineGrap
|
|
|
51
50
|
destDepOutputPath + '/src';
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
markedForDeletion.forEach((path) => (0,
|
|
53
|
+
markedForDeletion.forEach((path) => (0, node_fs_1.rmSync)(path, { recursive: true, force: true }));
|
|
55
54
|
updateImports(outputPath, inlinedDepsDestOutputRecord);
|
|
56
55
|
}
|
|
57
56
|
function readBasePathAliases(context) {
|
|
@@ -60,7 +59,7 @@ function readBasePathAliases(context) {
|
|
|
60
59
|
function getRootTsConfigPath(context) {
|
|
61
60
|
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
62
61
|
const tsConfigPath = (0, path_1.join)(context.root, tsConfigName);
|
|
63
|
-
if ((0,
|
|
62
|
+
if ((0, node_fs_1.existsSync)(tsConfigPath)) {
|
|
64
63
|
return tsConfigPath;
|
|
65
64
|
}
|
|
66
65
|
}
|
|
@@ -157,7 +156,7 @@ function buildInlineGraphExternals(context, inlineProjectGraph, pathAliases) {
|
|
|
157
156
|
function movePackage(from, to) {
|
|
158
157
|
if (from === to)
|
|
159
158
|
return;
|
|
160
|
-
(0,
|
|
159
|
+
(0, node_fs_1.cpSync)(from, to, { recursive: true });
|
|
161
160
|
}
|
|
162
161
|
function updateImports(destOutputPath, inlinedDepsDestOutputRecord) {
|
|
163
162
|
const pathAliases = Object.keys(inlinedDepsDestOutputRecord);
|
|
@@ -168,13 +167,13 @@ function updateImports(destOutputPath, inlinedDepsDestOutputRecord) {
|
|
|
168
167
|
recursiveUpdateImport(destOutputPath, importRegex, inlinedDepsDestOutputRecord);
|
|
169
168
|
}
|
|
170
169
|
function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord, rootParentDir) {
|
|
171
|
-
const files = (0,
|
|
170
|
+
const files = (0, node_fs_1.readdirSync)(dirPath, { withFileTypes: true });
|
|
172
171
|
for (const file of files) {
|
|
173
172
|
// only check .js and .d.ts files
|
|
174
173
|
if (file.isFile() &&
|
|
175
174
|
(file.name.endsWith('.js') || file.name.endsWith('.d.ts'))) {
|
|
176
175
|
const filePath = (0, path_1.join)(dirPath, file.name);
|
|
177
|
-
const fileContent = (0,
|
|
176
|
+
const fileContent = (0, node_fs_1.readFileSync)(filePath, 'utf-8');
|
|
178
177
|
const updatedContent = fileContent.replace(importRegex, (matched) => {
|
|
179
178
|
const result = matched.replace(/['"]/g, '');
|
|
180
179
|
// If a match is the same as the rootParentDir, we're checking its own files so we return the matched as in no changes.
|
|
@@ -183,7 +182,7 @@ function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord
|
|
|
183
182
|
const importPath = `"${(0, path_1.relative)(dirPath, inlinedDepsDestOutputRecord[result])}"`;
|
|
184
183
|
return (0, devkit_1.normalizePath)(importPath);
|
|
185
184
|
});
|
|
186
|
-
(0,
|
|
185
|
+
(0, node_fs_1.writeFileSync)(filePath, updatedContent);
|
|
187
186
|
}
|
|
188
187
|
else if (file.isDirectory()) {
|
|
189
188
|
recursiveUpdateImport((0, path_1.join)(dirPath, file.name), importRegex, inlinedDepsDestOutputRecord, rootParentDir || file.name);
|
|
@@ -8,10 +8,9 @@ const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
9
9
|
const create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
10
10
|
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
11
12
|
const path_1 = require("path");
|
|
12
|
-
const fs_extra_1 = require("fs-extra");
|
|
13
13
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
14
|
const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
|
|
16
15
|
const get_main_file_dir_1 = require("../get-main-file-dir");
|
|
17
16
|
function updatePackageJson(options, context, target, dependencies, fileMap = null) {
|
|
@@ -60,7 +59,7 @@ function updatePackageJson(options, context, target, dependencies, fileMap = nul
|
|
|
60
59
|
}
|
|
61
60
|
else {
|
|
62
61
|
const lockFile = (0, lock_file_1.createLockFile)(packageJson, context.projectGraph, packageManager);
|
|
63
|
-
(0,
|
|
62
|
+
(0, node_fs_1.writeFileSync)(`${options.outputPath}/${(0, lock_file_1.getLockFileName)(packageManager)}`, lockFile, {
|
|
64
63
|
encoding: 'utf-8',
|
|
65
64
|
});
|
|
66
65
|
}
|
|
@@ -102,7 +101,7 @@ function addMissingDependencies(packageJson, { projectName, targetName, configur
|
|
|
102
101
|
configuration: configurationName,
|
|
103
102
|
}, {}, entry.node);
|
|
104
103
|
const depPackageJsonPath = (0, path_1.join)(root, outputs[0], 'package.json');
|
|
105
|
-
if ((0,
|
|
104
|
+
if ((0, node_fs_1.existsSync)(depPackageJsonPath)) {
|
|
106
105
|
const version = (0, devkit_1.readJsonFile)(depPackageJsonPath).version;
|
|
107
106
|
packageJson[propType] ??= {};
|
|
108
107
|
packageJson[propType][packageName] = version;
|
|
@@ -4,8 +4,8 @@ exports.compileSwc = compileSwc;
|
|
|
4
4
|
exports.compileSwcWatch = compileSwcWatch;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const node_child_process_1 = require("node:child_process");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
7
8
|
const node_path_1 = require("node:path");
|
|
8
|
-
const fs_extra_1 = require("fs-extra");
|
|
9
9
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
10
10
|
const print_diagnostics_1 = require("../typescript/print-diagnostics");
|
|
11
11
|
const run_type_check_1 = require("../typescript/run-type-check");
|
|
@@ -24,7 +24,7 @@ function getSwcCmd({ swcCliOptions: { swcrcPath, destPath, stripLeadingPaths },
|
|
|
24
24
|
else {
|
|
25
25
|
// If sourceRoot is not provided, check if `src` exists and use that instead.
|
|
26
26
|
// This is important for root projects to avoid compiling too many directories.
|
|
27
|
-
inputDir = (0,
|
|
27
|
+
inputDir = (0, node_fs_1.existsSync)((0, node_path_1.join)(root, projectRoot, 'src')) ? 'src' : '.';
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
let swcCmd = `node ${swcCLI} ${inputDir || '.'} -d ${destPath} --config-file=${swcrcPath} ${stripLeadingPaths ? '--strip-leading-paths' : ''}`;
|
|
@@ -38,7 +38,7 @@ function getTypeCheckOptions(normalizedOptions) {
|
|
|
38
38
|
? projectRoot
|
|
39
39
|
: sourceRoot
|
|
40
40
|
? sourceRoot
|
|
41
|
-
: (0,
|
|
41
|
+
: (0, node_fs_1.existsSync)((0, node_path_1.join)(root, projectRoot, 'src'))
|
|
42
42
|
? (0, node_path_1.join)(projectRoot, 'src')
|
|
43
43
|
: projectRoot;
|
|
44
44
|
const typeCheckOptions = {
|
|
@@ -57,7 +57,7 @@ function getTypeCheckOptions(normalizedOptions) {
|
|
|
57
57
|
async function compileSwc(context, normalizedOptions, postCompilationCallback) {
|
|
58
58
|
devkit_1.logger.log(`Compiling with SWC for ${context.projectName}...`);
|
|
59
59
|
if (normalizedOptions.clean) {
|
|
60
|
-
(0,
|
|
60
|
+
(0, node_fs_1.rmSync)(normalizedOptions.outputPath, { recursive: true, force: true });
|
|
61
61
|
}
|
|
62
62
|
const swcCmdLog = (0, node_child_process_1.execSync)(getSwcCmd(normalizedOptions), {
|
|
63
63
|
encoding: 'utf8',
|
|
@@ -89,7 +89,7 @@ async function* compileSwcWatch(context, normalizedOptions, postCompilationCallb
|
|
|
89
89
|
let typeCheckOptions;
|
|
90
90
|
let initialPostCompile = true;
|
|
91
91
|
if (normalizedOptions.clean) {
|
|
92
|
-
(0,
|
|
92
|
+
(0, node_fs_1.rmSync)(normalizedOptions.outputPath, { recursive: true, force: true });
|
|
93
93
|
}
|
|
94
94
|
return yield* (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
95
95
|
let processOnExit;
|