@nx/js 0.0.0-pr-29703-8312c59 → 0.0.0-pr-29705-bc2a0dd
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": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29705-bc2a0dd",
|
|
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": "0.0.0-pr-
|
|
43
|
-
"@nx/workspace": "0.0.0-pr-
|
|
42
|
+
"@nx/devkit": "0.0.0-pr-29705-bc2a0dd",
|
|
43
|
+
"@nx/workspace": "0.0.0-pr-29705-bc2a0dd",
|
|
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",
|
|
@@ -24,6 +24,7 @@ const versions_1 = require("../../utils/versions");
|
|
|
24
24
|
const init_1 = require("../init/init");
|
|
25
25
|
const generator_1 = require("../setup-verdaccio/generator");
|
|
26
26
|
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
27
|
+
const get_import_path_1 = require("../../utils/get-import-path");
|
|
27
28
|
const defaultOutputDirectory = 'dist';
|
|
28
29
|
async function libraryGenerator(tree, schema) {
|
|
29
30
|
return await libraryGeneratorInternal(tree, {
|
|
@@ -43,6 +44,11 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
43
44
|
formatter: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree) ? 'none' : 'prettier',
|
|
44
45
|
}));
|
|
45
46
|
const options = await normalizeOptions(tree, schema);
|
|
47
|
+
// If we are using the new TS solution
|
|
48
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
49
|
+
if (options.isUsingTsSolutionConfig) {
|
|
50
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
|
|
51
|
+
}
|
|
46
52
|
createFiles(tree, options);
|
|
47
53
|
await configureProject(tree, options);
|
|
48
54
|
if (!options.skipPackageJson) {
|
|
@@ -138,11 +144,6 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
138
144
|
return json;
|
|
139
145
|
});
|
|
140
146
|
}
|
|
141
|
-
// If we are using the new TS solution
|
|
142
|
-
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
143
|
-
if (options.isUsingTsSolutionConfig) {
|
|
144
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
|
|
145
|
-
}
|
|
146
147
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.projectRoot);
|
|
147
148
|
if (!options.skipFormat) {
|
|
148
149
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -243,8 +244,19 @@ async function configureProject(tree, options) {
|
|
|
243
244
|
if (!projectConfiguration.tags?.length) {
|
|
244
245
|
delete projectConfiguration.tags;
|
|
245
246
|
}
|
|
247
|
+
// We want a minimal setup, so unless targets and tags are set, just skip the `nx` property in `package.json`.
|
|
248
|
+
if (options.isUsingTsSolutionConfig) {
|
|
249
|
+
delete projectConfiguration.projectType;
|
|
250
|
+
// SWC executor has logic around sourceRoot and `--strip-leading-paths`. If it is not set then dist will contain the `src` folder rather than being flat.
|
|
251
|
+
// TODO(leo): Look at how we can remove the dependency on sourceRoot for SWC.
|
|
252
|
+
if (options.bundler !== 'swc') {
|
|
253
|
+
delete projectConfiguration.sourceRoot;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
246
256
|
// empty targets are cleaned up automatically by `updateProjectConfiguration`
|
|
247
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.
|
|
257
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.isUsingTsSolutionConfig
|
|
258
|
+
? options.importPath ?? options.name
|
|
259
|
+
: options.name, projectConfiguration);
|
|
248
260
|
}
|
|
249
261
|
else if (options.config === 'workspace' || options.config === 'project') {
|
|
250
262
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, projectConfiguration);
|
|
@@ -638,7 +650,9 @@ async function normalizeOptions(tree, options) {
|
|
|
638
650
|
return {
|
|
639
651
|
...options,
|
|
640
652
|
fileName,
|
|
641
|
-
name:
|
|
653
|
+
name: isUsingTsSolutionConfig
|
|
654
|
+
? (0, get_import_path_1.getImportPath)(tree, projectName)
|
|
655
|
+
: projectName,
|
|
642
656
|
projectNames,
|
|
643
657
|
projectRoot,
|
|
644
658
|
parsedTags,
|
|
@@ -5,3 +5,4 @@ export declare function assertNotUsingTsSolutionSetup(tree: Tree, pluginName: st
|
|
|
5
5
|
export declare function findRuntimeTsConfigName(tree: Tree, projectRoot: string): string | null;
|
|
6
6
|
export declare function updateTsconfigFiles(tree: Tree, projectRoot: string, runtimeTsconfigFileName: string, compilerOptions: Record<string, string | boolean | string[]>, exclude?: string[], rootDir?: string): void;
|
|
7
7
|
export declare function addProjectToTsSolutionWorkspace(tree: Tree, projectDir: string): void;
|
|
8
|
+
export declare function getProjectType(tree: Tree, projectRoot: string, projectType?: 'library' | 'application'): 'library' | 'application';
|
|
@@ -6,6 +6,7 @@ exports.assertNotUsingTsSolutionSetup = assertNotUsingTsSolutionSetup;
|
|
|
6
6
|
exports.findRuntimeTsConfigName = findRuntimeTsConfigName;
|
|
7
7
|
exports.updateTsconfigFiles = updateTsconfigFiles;
|
|
8
8
|
exports.addProjectToTsSolutionWorkspace = addProjectToTsSolutionWorkspace;
|
|
9
|
+
exports.getProjectType = getProjectType;
|
|
9
10
|
const devkit_1 = require("@nx/devkit");
|
|
10
11
|
const posix_1 = require("node:path/posix");
|
|
11
12
|
const tree_1 = require("nx/src/generators/tree");
|
|
@@ -172,3 +173,19 @@ function addProjectToTsSolutionWorkspace(tree, projectDir) {
|
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
}
|
|
176
|
+
function getProjectType(tree, projectRoot, projectType) {
|
|
177
|
+
if (projectType)
|
|
178
|
+
return projectType;
|
|
179
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.lib.json')))
|
|
180
|
+
return 'library';
|
|
181
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.app.json')))
|
|
182
|
+
return 'application';
|
|
183
|
+
// If there are no exports, assume it is an application since both buildable and non-buildable libraries have exports.
|
|
184
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(projectRoot, 'package.json');
|
|
185
|
+
const packageJson = tree.exists(packageJsonPath)
|
|
186
|
+
? (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))
|
|
187
|
+
: null;
|
|
188
|
+
if (packageJson?.exports)
|
|
189
|
+
return 'library';
|
|
190
|
+
return 'application';
|
|
191
|
+
}
|