@nx/js 19.0.4 → 19.0.6
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/babel.js +1 -1
- package/package.json +5 -5
- package/src/generators/library/files/jest-config/jest.config.__ext__ +1 -1
- package/src/generators/library/library.js +6 -0
- package/src/plugins/jest/start-local-registry.d.ts +3 -1
- package/src/plugins/jest/start-local-registry.js +3 -2
- package/src/utils/package-json/update-package-json.d.ts +2 -1
- package/src/utils/package-json/update-package-json.js +8 -8
package/babel.js
CHANGED
|
@@ -27,7 +27,7 @@ module.exports = function (api, options = {}) {
|
|
|
27
27
|
// All other options will fail in Jest since Node does not support some ES features
|
|
28
28
|
// such as import syntax.
|
|
29
29
|
isTest || process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID
|
|
30
|
-
? { targets: { node: 'current' }, loose
|
|
30
|
+
? { targets: { node: 'current' }, loose }
|
|
31
31
|
: createBabelPresetEnvOptions(options.useBuiltIns, isModern, loose),
|
|
32
32
|
],
|
|
33
33
|
[
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.6",
|
|
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": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"Tsc",
|
|
17
17
|
"CLI"
|
|
18
18
|
],
|
|
19
|
-
"main": "
|
|
19
|
+
"main": "src/index.js",
|
|
20
20
|
"typings": "src/index.d.ts",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"bugs": {
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"semver": "^7.5.3",
|
|
57
57
|
"source-map-support": "0.5.19",
|
|
58
58
|
"tslib": "^2.3.0",
|
|
59
|
-
"@nx/devkit": "19.0.
|
|
60
|
-
"@nx/workspace": "19.0.
|
|
61
|
-
"@nrwl/js": "19.0.
|
|
59
|
+
"@nx/devkit": "19.0.6",
|
|
60
|
+
"@nx/workspace": "19.0.6",
|
|
61
|
+
"@nrwl/js": "19.0.6"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"verdaccio": "^5.0.4"
|
|
@@ -20,7 +20,7 @@ if (swcJestConfig.swcrc === undefined) {
|
|
|
20
20
|
|
|
21
21
|
<% if(js) {%>module.exports =<% } else { %>export default<% } %> {
|
|
22
22
|
displayName: '<%= project %>',
|
|
23
|
-
preset: '<%= offsetFromRoot %>
|
|
23
|
+
preset: '<%= offsetFromRoot %><%= jestPreset %>',
|
|
24
24
|
transform: {
|
|
25
25
|
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
|
|
26
26
|
},
|
|
@@ -425,9 +425,11 @@ function replaceJestConfig(tree, options) {
|
|
|
425
425
|
if (tree.exists(existingJestConfig)) {
|
|
426
426
|
tree.delete(existingJestConfig);
|
|
427
427
|
}
|
|
428
|
+
const jestPreset = findRootJestPreset(tree) ?? 'jest.presets.js';
|
|
428
429
|
// replace with JS:SWC specific jest config
|
|
429
430
|
(0, devkit_1.generateFiles)(tree, filesDir, options.projectRoot, {
|
|
430
431
|
ext: options.js ? 'js' : 'ts',
|
|
432
|
+
jestPreset,
|
|
431
433
|
js: !!options.js,
|
|
432
434
|
project: options.name,
|
|
433
435
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
@@ -748,4 +750,8 @@ function logNxReleaseDocsInfo() {
|
|
|
748
750
|
title: `📦 To learn how to publish this library, see https://nx.dev/core-features/manage-releases.`,
|
|
749
751
|
});
|
|
750
752
|
}
|
|
753
|
+
function findRootJestPreset(tree) {
|
|
754
|
+
const ext = ['js', 'cjs', 'mjs'].find((ext) => tree.exists(`jest.preset.${ext}`));
|
|
755
|
+
return ext ? `jest.preset.${ext}` : null;
|
|
756
|
+
}
|
|
751
757
|
exports.default = libraryGenerator;
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
|
|
4
4
|
* @param storage the storage location for the local registry
|
|
5
5
|
* @param verbose whether to log verbose output
|
|
6
|
+
* @param clearStorage whether to clear the verdaccio storage before running the registry
|
|
6
7
|
*/
|
|
7
|
-
export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, }: {
|
|
8
|
+
export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, }: {
|
|
8
9
|
localRegistryTarget: string;
|
|
9
10
|
storage?: string;
|
|
10
11
|
verbose?: boolean;
|
|
12
|
+
clearStorage?: boolean;
|
|
11
13
|
}): Promise<() => void>;
|
|
12
14
|
export default startLocalRegistry;
|
|
@@ -7,14 +7,15 @@ const child_process_1 = require("child_process");
|
|
|
7
7
|
* @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
|
|
8
8
|
* @param storage the storage location for the local registry
|
|
9
9
|
* @param verbose whether to log verbose output
|
|
10
|
+
* @param clearStorage whether to clear the verdaccio storage before running the registry
|
|
10
11
|
*/
|
|
11
|
-
function startLocalRegistry({ localRegistryTarget, storage, verbose, }) {
|
|
12
|
+
function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, }) {
|
|
12
13
|
if (!localRegistryTarget) {
|
|
13
14
|
throw new Error(`localRegistryTarget is required`);
|
|
14
15
|
}
|
|
15
16
|
return new Promise((resolve, reject) => {
|
|
16
17
|
const childProcess = (0, child_process_1.fork)(require.resolve('nx'), [
|
|
17
|
-
...`run ${localRegistryTarget} --location none --clear true`.split(' '),
|
|
18
|
+
...`run ${localRegistryTarget} --location none --clear ${clearStorage ?? true}`.split(' '),
|
|
18
19
|
...(storage ? [`--storage`, storage] : []),
|
|
19
20
|
], { stdio: 'pipe' });
|
|
20
21
|
const listener = (data) => {
|
|
@@ -3,6 +3,7 @@ import { DependentBuildableProjectNode } from '../buildable-libs-utils';
|
|
|
3
3
|
import type { PackageJson } from 'nx/src/utils/package-json';
|
|
4
4
|
export type SupportedFormat = 'cjs' | 'esm';
|
|
5
5
|
export interface UpdatePackageJsonOption {
|
|
6
|
+
rootDir?: string;
|
|
6
7
|
projectRoot: string;
|
|
7
8
|
main: string;
|
|
8
9
|
additionalEntryPoints?: string[];
|
|
@@ -23,7 +24,7 @@ interface Exports {
|
|
|
23
24
|
'.': string;
|
|
24
25
|
[name: string]: string;
|
|
25
26
|
}
|
|
26
|
-
export declare function getExports(options: Pick<UpdatePackageJsonOption, 'main' | 'projectRoot' | 'outputFileName' | 'additionalEntryPoints'> & {
|
|
27
|
+
export declare function getExports(options: Pick<UpdatePackageJsonOption, 'main' | 'rootDir' | 'projectRoot' | 'outputFileName' | 'additionalEntryPoints'> & {
|
|
27
28
|
fileExt: string;
|
|
28
29
|
}): Exports;
|
|
29
30
|
export declare function getUpdatedPackageJsonContent(packageJson: PackageJson, options: UpdatePackageJsonOption): PackageJson;
|
|
@@ -99,7 +99,7 @@ function getExports(options) {
|
|
|
99
99
|
: (0, path_1.basename)(options.main).replace(/\.[tj]s$/, '');
|
|
100
100
|
const relativeMainFileDir = options.outputFileName
|
|
101
101
|
? './'
|
|
102
|
-
: (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(options.main, options.projectRoot);
|
|
102
|
+
: (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(options.main, options.rootDir ?? options.projectRoot);
|
|
103
103
|
const exports = {
|
|
104
104
|
'.': relativeMainFileDir + mainFile + options.fileExt,
|
|
105
105
|
};
|
|
@@ -123,23 +123,23 @@ function getUpdatedPackageJsonContent(packageJson, options) {
|
|
|
123
123
|
const hasCjsFormat = !options.format || options.format?.includes('cjs');
|
|
124
124
|
const hasEsmFormat = options.format?.includes('esm');
|
|
125
125
|
if (options.generateExportsField) {
|
|
126
|
-
packageJson.exports
|
|
126
|
+
packageJson.exports ??=
|
|
127
127
|
typeof packageJson.exports === 'string' ? {} : { ...packageJson.exports };
|
|
128
|
-
packageJson.exports['./package.json']
|
|
128
|
+
packageJson.exports['./package.json'] ??= './package.json';
|
|
129
129
|
}
|
|
130
130
|
if (hasEsmFormat) {
|
|
131
131
|
const esmExports = getExports({
|
|
132
132
|
...options,
|
|
133
133
|
fileExt: options.outputFileExtensionForEsm ?? '.js',
|
|
134
134
|
});
|
|
135
|
-
packageJson.module
|
|
135
|
+
packageJson.module ??= esmExports['.'];
|
|
136
136
|
if (!hasCjsFormat) {
|
|
137
137
|
packageJson.type = 'module';
|
|
138
138
|
packageJson.main ??= esmExports['.'];
|
|
139
139
|
}
|
|
140
140
|
if (options.generateExportsField) {
|
|
141
141
|
for (const [exportEntry, filePath] of Object.entries(esmExports)) {
|
|
142
|
-
packageJson.exports[exportEntry]
|
|
142
|
+
packageJson.exports[exportEntry] ??= hasCjsFormat
|
|
143
143
|
? { import: filePath }
|
|
144
144
|
: filePath;
|
|
145
145
|
}
|
|
@@ -153,7 +153,7 @@ function getUpdatedPackageJsonContent(packageJson, options) {
|
|
|
153
153
|
...options,
|
|
154
154
|
fileExt: options.outputFileExtensionForCjs ?? '.js',
|
|
155
155
|
});
|
|
156
|
-
packageJson.main
|
|
156
|
+
packageJson.main ??= cjsExports['.'];
|
|
157
157
|
if (!hasEsmFormat) {
|
|
158
158
|
packageJson.type = 'commonjs';
|
|
159
159
|
}
|
|
@@ -163,7 +163,7 @@ function getUpdatedPackageJsonContent(packageJson, options) {
|
|
|
163
163
|
packageJson.exports[exportEntry]['default'] ??= filePath;
|
|
164
164
|
}
|
|
165
165
|
else {
|
|
166
|
-
packageJson.exports[exportEntry]
|
|
166
|
+
packageJson.exports[exportEntry] ??= filePath;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -172,7 +172,7 @@ function getUpdatedPackageJsonContent(packageJson, options) {
|
|
|
172
172
|
const mainFile = (0, path_1.basename)(options.main).replace(/\.[tj]s$/, '');
|
|
173
173
|
const relativeMainFileDir = (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(options.main, options.projectRoot);
|
|
174
174
|
const typingsFile = `${relativeMainFileDir}${mainFile}.d.ts`;
|
|
175
|
-
packageJson.types
|
|
175
|
+
packageJson.types ??= typingsFile;
|
|
176
176
|
}
|
|
177
177
|
return packageJson;
|
|
178
178
|
}
|