@nx/js 20.3.2 → 20.3.4
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/js",
|
|
3
|
-
"version": "20.3.
|
|
3
|
+
"version": "20.3.4",
|
|
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": "20.3.
|
|
43
|
-
"@nx/workspace": "20.3.
|
|
42
|
+
"@nx/devkit": "20.3.4",
|
|
43
|
+
"@nx/workspace": "20.3.4",
|
|
44
44
|
"@zkochan/js-yaml": "0.0.7",
|
|
45
45
|
"babel-plugin-const-enum": "^1.0.1",
|
|
46
46
|
"babel-plugin-macros": "^2.8.0",
|
|
@@ -23,6 +23,7 @@ const ts_solution_setup_1 = require("../../utils/typescript/ts-solution-setup");
|
|
|
23
23
|
const versions_1 = require("../../utils/versions");
|
|
24
24
|
const init_1 = require("../init/init");
|
|
25
25
|
const generator_1 = require("../setup-verdaccio/generator");
|
|
26
|
+
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
26
27
|
const defaultOutputDirectory = 'dist';
|
|
27
28
|
async function libraryGenerator(tree, schema) {
|
|
28
29
|
return await libraryGeneratorInternal(tree, {
|
|
@@ -133,6 +134,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
133
134
|
if (options.isUsingTsSolutionConfig) {
|
|
134
135
|
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
|
|
135
136
|
}
|
|
137
|
+
(0, sort_fields_1.sortPackageJsonFields)(tree, options.projectRoot);
|
|
136
138
|
if (!options.skipFormat) {
|
|
137
139
|
await (0, devkit_1.formatFiles)(tree);
|
|
138
140
|
}
|
|
@@ -305,19 +307,21 @@ async function addLint(tree, options) {
|
|
|
305
307
|
ruleSeverity = value;
|
|
306
308
|
ruleOptions = {};
|
|
307
309
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
|
|
310
|
+
const ignoredFiles = new Set(ruleOptions.ignoredFiles ?? []);
|
|
311
|
+
if (options.bundler === 'vite') {
|
|
312
|
+
ignoredFiles.add('{projectRoot}/vite.config.{js,ts,mjs,mts}');
|
|
312
313
|
}
|
|
313
314
|
else if (options.bundler === 'rollup') {
|
|
314
|
-
|
|
315
|
-
ruleOptions.ignoredFiles.push('{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}');
|
|
316
|
-
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
|
|
315
|
+
ignoredFiles.add('{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}');
|
|
317
316
|
}
|
|
318
317
|
else if (options.bundler === 'esbuild') {
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
ignoredFiles.add('{projectRoot}/esbuild.config.{js,ts,mjs,mts}');
|
|
319
|
+
}
|
|
320
|
+
if (options.unitTestRunner === 'vitest') {
|
|
321
|
+
ignoredFiles.add('{projectRoot}/vite.config.{js,ts,mjs,mts}');
|
|
322
|
+
}
|
|
323
|
+
if (ignoredFiles.size) {
|
|
324
|
+
ruleOptions.ignoredFiles = Array.from(ignoredFiles);
|
|
321
325
|
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
|
|
322
326
|
}
|
|
323
327
|
return o;
|
|
@@ -478,6 +482,12 @@ function createFiles(tree, options) {
|
|
|
478
482
|
return json;
|
|
479
483
|
});
|
|
480
484
|
}
|
|
485
|
+
else if (!options.isUsingTsSolutionConfig &&
|
|
486
|
+
options.useProjectJson &&
|
|
487
|
+
(!options.bundler || options.bundler === 'none') &&
|
|
488
|
+
!(options.projectRoot === '.')) {
|
|
489
|
+
tree.delete(packageJsonPath);
|
|
490
|
+
}
|
|
481
491
|
if (options.minimal && !(options.projectRoot === '.')) {
|
|
482
492
|
tree.delete((0, path_1.join)(options.projectRoot, 'README.md'));
|
|
483
493
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortPackageJsonFields = sortPackageJsonFields;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function sortPackageJsonFields(tree, projectRoot) {
|
|
6
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(projectRoot, 'package.json');
|
|
7
|
+
if (!tree.exists(packageJsonPath))
|
|
8
|
+
return;
|
|
9
|
+
(0, devkit_1.updateJson)(tree, packageJsonPath, (json) => {
|
|
10
|
+
// Note that these are fields that our generators may use, so it's not exhaustive.
|
|
11
|
+
const orderedTopFields = new Set([
|
|
12
|
+
'name',
|
|
13
|
+
'version',
|
|
14
|
+
'private',
|
|
15
|
+
'description',
|
|
16
|
+
'type',
|
|
17
|
+
'main',
|
|
18
|
+
'module',
|
|
19
|
+
'types',
|
|
20
|
+
'exports',
|
|
21
|
+
]);
|
|
22
|
+
const orderedBottomFields = new Set([
|
|
23
|
+
'dependencies',
|
|
24
|
+
'devDependencies',
|
|
25
|
+
'peerDependencies',
|
|
26
|
+
'optionalDependencies',
|
|
27
|
+
]);
|
|
28
|
+
const otherFields = new Set(Object.keys(json).filter((k) => !orderedTopFields.has(k) && !orderedBottomFields.has(k)));
|
|
29
|
+
const allFields = [
|
|
30
|
+
...orderedTopFields,
|
|
31
|
+
...otherFields,
|
|
32
|
+
...orderedBottomFields,
|
|
33
|
+
];
|
|
34
|
+
const sortedJson = {};
|
|
35
|
+
for (const k of allFields) {
|
|
36
|
+
sortedJson[k] = json[k];
|
|
37
|
+
}
|
|
38
|
+
return sortedJson;
|
|
39
|
+
});
|
|
40
|
+
}
|