@nx/js 16.8.0-beta.3 → 16.8.0-beta.5

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.
Files changed (49) hide show
  1. package/babel.js +7 -8
  2. package/package.json +5 -5
  3. package/src/executors/node/lib/kill-tree.js +42 -45
  4. package/src/executors/node/node.impl.js +190 -189
  5. package/src/executors/node/schema.json +1 -1
  6. package/src/executors/swc/swc.impl.js +82 -70
  7. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +7 -4
  8. package/src/executors/tsc/lib/batch/watch.js +42 -49
  9. package/src/executors/tsc/lib/get-task-options.js +8 -6
  10. package/src/executors/tsc/lib/get-tsconfig.js +16 -5
  11. package/src/executors/tsc/lib/normalize-options.js +9 -2
  12. package/src/executors/tsc/lib/typescript-compilation.js +21 -24
  13. package/src/executors/tsc/tsc.batch-impl.js +133 -132
  14. package/src/executors/tsc/tsc.impl.js +54 -50
  15. package/src/executors/verdaccio/verdaccio.impl.js +64 -55
  16. package/src/generators/convert-to-swc/convert-to-swc.js +6 -9
  17. package/src/generators/init/init.js +86 -92
  18. package/src/generators/library/library.d.ts +1 -1
  19. package/src/generators/library/library.js +290 -203
  20. package/src/generators/setup-build/generator.js +120 -113
  21. package/src/generators/setup-verdaccio/generator.js +45 -50
  22. package/src/migrations/update-13-8-5/update-node-executor.js +17 -21
  23. package/src/migrations/update-13-8-5/update-swcrc.js +23 -27
  24. package/src/migrations/update-14-1-5/update-swcrc-path.js +17 -20
  25. package/src/migrations/update-15-8-0/rename-swcrc-config.js +57 -60
  26. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
  27. package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +19 -24
  28. package/src/plugins/jest/start-local-registry.js +4 -6
  29. package/src/plugins/rollup/type-definitions.js +21 -24
  30. package/src/utils/add-babel-inputs.js +1 -2
  31. package/src/utils/assets/assets.js +1 -2
  32. package/src/utils/assets/copy-assets-handler.js +48 -59
  33. package/src/utils/assets/index.js +20 -23
  34. package/src/utils/buildable-libs-utils.js +9 -13
  35. package/src/utils/find-npm-dependencies.d.ts +1 -0
  36. package/src/utils/find-npm-dependencies.js +25 -15
  37. package/src/utils/generate-globs.js +3 -3
  38. package/src/utils/inline.js +5 -10
  39. package/src/utils/package-json/get-npm-scope.js +2 -2
  40. package/src/utils/package-json/index.js +22 -25
  41. package/src/utils/package-json/update-package-json.js +26 -23
  42. package/src/utils/prettier.js +21 -24
  43. package/src/utils/swc/compile-swc.js +101 -106
  44. package/src/utils/typescript/compile-typescript-files.js +7 -8
  45. package/src/utils/typescript/print-diagnostics.js +13 -16
  46. package/src/utils/typescript/run-type-check.js +62 -59
  47. package/src/utils/typescript/ts-config.js +3 -5
  48. package/src/utils/typescript/tsnode-register.js +1 -1
  49. package/src/utils/watch-for-single-file-changes.js +13 -17
@@ -4,4 +4,5 @@ import { type ProjectGraph, type ProjectGraphProjectNode, type ProjectFileMap }
4
4
  */
5
5
  export declare function findNpmDependencies(workspaceRoot: string, sourceProject: ProjectGraphProjectNode, projectGraph: ProjectGraph, projectFileMap: ProjectFileMap, buildTarget: string, options?: {
6
6
  includeTransitiveDependencies?: boolean;
7
+ ignoredFiles?: string[];
7
8
  }): Record<string, string>;
@@ -18,9 +18,10 @@ function findNpmDependencies(workspaceRoot, sourceProject, projectGraph, project
18
18
  }
19
19
  const results = {};
20
20
  function collectAll(currentProject, collectedDeps) {
21
- if (seen === null || seen === void 0 ? void 0 : seen.has(currentProject.name))
21
+ if (seen?.has(currentProject.name))
22
22
  return;
23
- collectDependenciesFromFileMap(workspaceRoot, currentProject, projectGraph, projectFileMap, buildTarget, collectedDeps);
23
+ seen?.add(currentProject.name);
24
+ collectDependenciesFromFileMap(workspaceRoot, currentProject, projectGraph, projectFileMap, buildTarget, options.ignoredFiles, collectedDeps);
24
25
  collectHelperDependencies(workspaceRoot, currentProject, projectGraph, buildTarget, collectedDeps);
25
26
  if (options.includeTransitiveDependencies) {
26
27
  const projectDeps = projectGraph.dependencies[currentProject.name];
@@ -37,14 +38,20 @@ function findNpmDependencies(workspaceRoot, sourceProject, projectGraph, project
37
38
  exports.findNpmDependencies = findNpmDependencies;
38
39
  // Keep track of workspace libs we already read package.json for so we don't read from disk again.
39
40
  const seenWorkspaceDeps = {};
40
- function collectDependenciesFromFileMap(workspaceRoot, sourceProject, projectGraph, projectFileMap, buildTarget, npmDeps) {
41
+ function collectDependenciesFromFileMap(workspaceRoot, sourceProject, projectGraph, projectFileMap, buildTarget, ignoredFiles, npmDeps) {
41
42
  const rawFiles = projectFileMap[sourceProject.name];
42
43
  if (!rawFiles)
43
44
  return;
44
- // Cannot read inputs if the target does not exist on the project.
45
- if (!sourceProject.data.targets[buildTarget])
46
- return;
47
- const inputs = (0, task_hasher_1.getTargetInputs)((0, configuration_1.readNxJson)(), sourceProject, buildTarget).selfInputs;
45
+ // If build target does not exist in project, use all files as input.
46
+ // This is needed for transitive dependencies for apps -- where libs may not be buildable.
47
+ const inputs = sourceProject.data.targets[buildTarget]
48
+ ? (0, task_hasher_1.getTargetInputs)((0, configuration_1.readNxJson)(), sourceProject, buildTarget).selfInputs
49
+ : ['{projectRoot}/**/*'];
50
+ if (ignoredFiles) {
51
+ for (const pattern of ignoredFiles) {
52
+ inputs.push(`!${pattern}`);
53
+ }
54
+ }
48
55
  const files = (0, task_hasher_1.filterUsingGlobPatterns)(sourceProject.data.root, projectFileMap[sourceProject.name] || [], inputs);
49
56
  for (const fileData of files) {
50
57
  if (!fileData.deps ||
@@ -56,7 +63,7 @@ function collectDependenciesFromFileMap(workspaceRoot, sourceProject, projectGra
56
63
  const target = (0, project_graph_1.fileDataDepTarget)(dep);
57
64
  // If the node is external, then read package info from `data`.
58
65
  const externalDep = projectGraph.externalNodes[target];
59
- if ((externalDep === null || externalDep === void 0 ? void 0 : externalDep.type) === 'npm') {
66
+ if (externalDep?.type === 'npm') {
60
67
  npmDeps[externalDep.data.packageName] = externalDep.data.version;
61
68
  continue;
62
69
  }
@@ -70,7 +77,11 @@ function collectDependenciesFromFileMap(workspaceRoot, sourceProject, projectGra
70
77
  }
71
78
  else {
72
79
  const packageJson = readPackageJson(workspaceDep, workspaceRoot);
73
- if (packageJson) {
80
+ if (
81
+ // Check that this is a buildable project, otherwise it cannot be a dependency in package.json.
82
+ workspaceDep.data.targets[buildTarget] &&
83
+ // Make sure package.json exists and has a valid name.
84
+ packageJson?.name) {
74
85
  // This is a workspace lib so we can't reliably read in a specific version since it depends on how the workspace is set up.
75
86
  // ASSUMPTION: Most users will use '*' for workspace lib versions. Otherwise, they can manually update it.
76
87
  npmDeps[packageJson.name] = '*';
@@ -90,14 +101,13 @@ function readPackageJson(project, workspaceRoot) {
90
101
  return null;
91
102
  }
92
103
  function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, buildTarget, npmDeps) {
93
- var _a, _b, _c, _d;
94
104
  const target = sourceProject.data.targets[buildTarget];
95
105
  if (!target)
96
106
  return;
97
- if (target.executor === '@nx/js:tsc' && ((_a = target.options) === null || _a === void 0 ? void 0 : _a.tsConfig)) {
107
+ if (target.executor === '@nx/js:tsc' && target.options?.tsConfig) {
98
108
  const tsConfig = (0, ts_config_1.readTsConfig)((0, path_1.join)(workspaceRoot, target.options.tsConfig));
99
- if (tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.options['importHelpers']) {
100
- npmDeps['tslib'] = (_b = projectGraph.externalNodes['npm:tslib']) === null || _b === void 0 ? void 0 : _b.data.version;
109
+ if (tsConfig?.options['importHelpers']) {
110
+ npmDeps['tslib'] = projectGraph.externalNodes['npm:tslib']?.data.version;
101
111
  }
102
112
  }
103
113
  if (target.executor === '@nx/js:swc') {
@@ -107,9 +117,9 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
107
117
  const swcConfig = (0, fileutils_1.fileExists)(swcConfigPath)
108
118
  ? (0, devkit_1.readJsonFile)(swcConfigPath)
109
119
  : {};
110
- if ((_c = swcConfig === null || swcConfig === void 0 ? void 0 : swcConfig.jsc) === null || _c === void 0 ? void 0 : _c.externalHelpers) {
120
+ if (swcConfig?.jsc?.externalHelpers) {
111
121
  npmDeps['@swc/helpers'] =
112
- (_d = projectGraph.externalNodes['npm:@swc/helpers']) === null || _d === void 0 ? void 0 : _d.data.version;
122
+ projectGraph.externalNodes['npm:@swc/helpers']?.data.version;
113
123
  }
114
124
  }
115
125
  }
@@ -37,7 +37,7 @@ function createGlobPatternsForDependencies(dirPath, fileGlobPattern) {
37
37
  }
38
38
  }
39
39
  catch (e) {
40
- throw new Error(`createGlobPatternsForDependencies: Error when trying to determine main project.\n${e === null || e === void 0 ? void 0 : e.message}`);
40
+ throw new Error(`createGlobPatternsForDependencies: Error when trying to determine main project.\n${e?.message}`);
41
41
  }
42
42
  // generate the glob
43
43
  try {
@@ -47,7 +47,7 @@ function createGlobPatternsForDependencies(dirPath, fileGlobPattern) {
47
47
  const children = (0, fs_1.readdirSync)((0, path_1.resolve)(workspace_root_1.workspaceRoot, dirPath));
48
48
  for (const child of children) {
49
49
  const childPath = (0, path_1.join)(dirPath, child);
50
- if ((ig === null || ig === void 0 ? void 0 : ig.ignores(childPath)) ||
50
+ if (ig?.ignores(childPath) ||
51
51
  !(0, fs_1.lstatSync)((0, path_1.resolve)(workspace_root_1.workspaceRoot, childPath)).isDirectory()) {
52
52
  continue;
53
53
  }
@@ -74,7 +74,7 @@ due to missing "sourceRoot" in the dependencies' project configuration
74
74
  return dirsToUse.map((sourceDir) => (0, path_1.resolve)(workspace_root_1.workspaceRoot, (0, devkit_1.joinPathFragments)(sourceDir, fileGlobPattern)));
75
75
  }
76
76
  catch (e) {
77
- throw new Error(`createGlobPatternsForDependencies: Error when generating globs.\n${e === null || e === void 0 ? void 0 : e.message}`);
77
+ throw new Error(`createGlobPatternsForDependencies: Error when generating globs.\n${e?.message}`);
78
78
  }
79
79
  }
80
80
  exports.createGlobPatternsForDependencies = createGlobPatternsForDependencies;
@@ -10,9 +10,8 @@ function isInlineGraphEmpty(inlineGraph) {
10
10
  }
11
11
  exports.isInlineGraphEmpty = isInlineGraphEmpty;
12
12
  function handleInliningBuild(context, options, tsConfigPath, projectName = context.projectName) {
13
- var _a;
14
13
  const tsConfigJson = (0, devkit_1.readJsonFile)(tsConfigPath);
15
- const pathAliases = ((_a = tsConfigJson['compilerOptions']) === null || _a === void 0 ? void 0 : _a['paths']) || readBasePathAliases(context);
14
+ const pathAliases = tsConfigJson['compilerOptions']?.['paths'] || readBasePathAliases(context);
16
15
  const inlineGraph = createInlineGraph(context, options, pathAliases, projectName);
17
16
  if (isInlineGraphEmpty(inlineGraph)) {
18
17
  return inlineGraph;
@@ -56,8 +55,7 @@ function postProcessInlinedDependencies(outputPath, parentOutputPath, inlineGrap
56
55
  }
57
56
  exports.postProcessInlinedDependencies = postProcessInlinedDependencies;
58
57
  function readBasePathAliases(context) {
59
- var _a;
60
- return (_a = (0, devkit_1.readJsonFile)(getRootTsConfigPath(context))) === null || _a === void 0 ? void 0 : _a['compilerOptions']['paths'];
58
+ return (0, devkit_1.readJsonFile)(getRootTsConfigPath(context))?.['compilerOptions']['paths'];
61
59
  }
62
60
  function getRootTsConfigPath(context) {
63
61
  for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
@@ -82,8 +80,6 @@ function projectNodeToInlineProjectNode(projectNode, pathAlias = '', buildOutput
82
80
  };
83
81
  }
84
82
  function createInlineGraph(context, options, pathAliases, projectName, inlineGraph = emptyInlineGraph()) {
85
- var _a;
86
- var _b;
87
83
  if (options.external == null)
88
84
  return inlineGraph;
89
85
  const projectDependencies = context.projectGraph.dependencies[projectName] || [];
@@ -124,7 +120,7 @@ function createInlineGraph(context, options, pathAliases, projectName, inlineGra
124
120
  !options.external.includes(projectDependency.target)) ||
125
121
  !buildOutputPath;
126
122
  if (shouldInline) {
127
- (_a = (_b = inlineGraph.dependencies)[projectName]) !== null && _a !== void 0 ? _a : (_b[projectName] = []);
123
+ inlineGraph.dependencies[projectName] ??= [];
128
124
  inlineGraph.dependencies[projectName].push(projectDependency.target);
129
125
  }
130
126
  inlineGraph.nodes[projectDependency.target] =
@@ -136,7 +132,7 @@ function createInlineGraph(context, options, pathAliases, projectName, inlineGra
136
132
  return inlineGraph;
137
133
  }
138
134
  function buildInlineGraphExternals(context, inlineProjectGraph, pathAliases) {
139
- const allNodes = Object.assign({}, context.projectGraph.nodes);
135
+ const allNodes = { ...context.projectGraph.nodes };
140
136
  for (const [parent, dependencies] of Object.entries(inlineProjectGraph.dependencies)) {
141
137
  if (allNodes[parent]) {
142
138
  delete allNodes[parent];
@@ -204,8 +200,7 @@ function getPathAliasForPackage(packageNode, pathAliases) {
204
200
  return '';
205
201
  }
206
202
  function getBuildOutputPath(projectName, context, options) {
207
- var _a, _b;
208
- const projectTargets = (_b = (_a = context.projectGraph.nodes[projectName]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.targets;
203
+ const projectTargets = context.projectGraph.nodes[projectName]?.data?.targets;
209
204
  if (!projectTargets)
210
205
  return '';
211
206
  const buildTarget = options.externalBuildTargets.find((buildTarget) => projectTargets[buildTarget]);
@@ -8,13 +8,13 @@ const devkit_1 = require("@nx/devkit");
8
8
  function getNpmScope(tree) {
9
9
  const nxJson = (0, devkit_1.readNxJson)(tree);
10
10
  // TODO(v17): Remove reading this from nx.json
11
- if (nxJson === null || nxJson === void 0 ? void 0 : nxJson.npmScope) {
11
+ if (nxJson?.npmScope) {
12
12
  return nxJson.npmScope;
13
13
  }
14
14
  const { name } = tree.exists('package.json')
15
15
  ? (0, devkit_1.readJson)(tree, 'package.json')
16
16
  : { name: null };
17
- if (name === null || name === void 0 ? void 0 : name.startsWith('@')) {
17
+ if (name?.startsWith('@')) {
18
18
  return name.split('/')[0].substring(1);
19
19
  }
20
20
  }
@@ -1,33 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.copyPackageJson = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const watch_for_single_file_changes_1 = require("../watch-for-single-file-changes");
6
5
  const update_package_json_1 = require("./update-package-json");
7
6
  const check_dependencies_1 = require("../check-dependencies");
8
- function copyPackageJson(_options, context) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- if (!context.target.options.tsConfig) {
11
- throw new Error(`Could not find tsConfig option for "${context.targetName}" target of "${context.projectName}" project. Check that your project configuration is correct.`);
12
- }
13
- let { target, dependencies, projectRoot } = (0, check_dependencies_1.checkDependencies)(context, context.target.options.tsConfig);
14
- const options = Object.assign(Object.assign({}, _options), { projectRoot });
15
- if (options.extraDependencies) {
16
- dependencies.push(...options.extraDependencies);
17
- }
18
- if (options.overrideDependencies) {
19
- dependencies = options.overrideDependencies;
20
- }
21
- if (options.watch) {
22
- const dispose = yield (0, watch_for_single_file_changes_1.watchForSingleFileChanges)(context.projectName, options.projectRoot, 'package.json', () => (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies));
23
- // Copy it once before changes
24
- (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
25
- return { success: true, stop: dispose };
26
- }
27
- else {
28
- (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
29
- return { success: true };
30
- }
31
- });
7
+ async function copyPackageJson(_options, context) {
8
+ if (!context.target.options.tsConfig) {
9
+ throw new Error(`Could not find tsConfig option for "${context.targetName}" target of "${context.projectName}" project. Check that your project configuration is correct.`);
10
+ }
11
+ let { target, dependencies, projectRoot } = (0, check_dependencies_1.checkDependencies)(context, context.target.options.tsConfig);
12
+ const options = { ..._options, projectRoot };
13
+ if (options.extraDependencies) {
14
+ dependencies.push(...options.extraDependencies);
15
+ }
16
+ if (options.overrideDependencies) {
17
+ dependencies = options.overrideDependencies;
18
+ }
19
+ if (options.watch) {
20
+ const dispose = await (0, watch_for_single_file_changes_1.watchForSingleFileChanges)(context.projectName, options.projectRoot, 'package.json', () => (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies));
21
+ // Copy it once before changes
22
+ (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
23
+ return { success: true, stop: dispose };
24
+ }
25
+ else {
26
+ (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
27
+ return { success: true };
28
+ }
32
29
  }
33
30
  exports.copyPackageJson = copyPackageJson;
@@ -14,10 +14,9 @@ const fs_1 = require("fs");
14
14
  const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
15
15
  const get_main_file_dir_1 = require("../get-main-file-dir");
16
16
  function updatePackageJson(options, context, target, dependencies, fileMap = null) {
17
- var _a;
18
17
  let packageJson;
19
18
  if (fileMap == null) {
20
- fileMap = ((_a = (0, nx_deps_cache_1.readProjectFileMapCache)()) === null || _a === void 0 ? void 0 : _a.projectFileMap) || {};
19
+ fileMap = (0, nx_deps_cache_1.readProjectFileMapCache)()?.projectFileMap || {};
21
20
  }
22
21
  if (options.updateBuildableProjectDepsInPackageJson) {
23
22
  packageJson = (0, create_package_json_1.createPackageJson)(context.projectName, context.projectGraph, {
@@ -42,8 +41,9 @@ function updatePackageJson(options, context, target, dependencies, fileMap = nul
42
41
  // save files
43
42
  (0, devkit_1.writeJsonFile)(`${options.outputPath}/package.json`, packageJson);
44
43
  if (options.generateLockfile) {
45
- const lockFile = (0, lock_file_1.createLockFile)(packageJson);
46
- (0, fs_extra_1.writeFileSync)(`${options.outputPath}/${(0, lock_file_1.getLockFileName)()}`, lockFile, {
44
+ const packageManager = (0, devkit_1.detectPackageManager)(context.root);
45
+ const lockFile = (0, lock_file_1.createLockFile)(packageJson, context.projectGraph, packageManager);
46
+ (0, fs_extra_1.writeFileSync)(`${options.outputPath}/${(0, lock_file_1.getLockFileName)(packageManager)}`, lockFile, {
47
47
  encoding: 'utf-8',
48
48
  });
49
49
  }
@@ -52,24 +52,23 @@ exports.updatePackageJson = updatePackageJson;
52
52
  function addMissingDependencies(packageJson, { projectName, targetName, configurationName, root }, dependencies, propType = 'dependencies') {
53
53
  const workspacePackageJson = (0, devkit_1.readJsonFile)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'package.json'));
54
54
  dependencies.forEach((entry) => {
55
- var _a, _b, _c, _d, _e, _f, _g, _h;
56
55
  if ((0, operators_1.isNpmProject)(entry.node)) {
57
56
  const { packageName, version } = entry.node.data;
58
- if (((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a[packageName]) ||
59
- ((_b = packageJson.devDependencies) === null || _b === void 0 ? void 0 : _b[packageName]) ||
60
- ((_c = packageJson.peerDependencies) === null || _c === void 0 ? void 0 : _c[packageName])) {
57
+ if (packageJson.dependencies?.[packageName] ||
58
+ packageJson.devDependencies?.[packageName] ||
59
+ packageJson.peerDependencies?.[packageName]) {
61
60
  return;
62
61
  }
63
- if ((_d = workspacePackageJson.devDependencies) === null || _d === void 0 ? void 0 : _d[packageName]) {
62
+ if (workspacePackageJson.devDependencies?.[packageName]) {
64
63
  return;
65
64
  }
66
- (_e = packageJson[propType]) !== null && _e !== void 0 ? _e : (packageJson[propType] = {});
65
+ packageJson[propType] ??= {};
67
66
  packageJson[propType][packageName] = version;
68
67
  }
69
68
  else {
70
69
  const packageName = entry.name;
71
- if (!((_f = packageJson.dependencies) === null || _f === void 0 ? void 0 : _f[packageName]) &&
72
- !((_g = packageJson.peerDependencies) === null || _g === void 0 ? void 0 : _g[packageName])) {
70
+ if (!packageJson.dependencies?.[packageName] &&
71
+ !packageJson.peerDependencies?.[packageName]) {
73
72
  const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
74
73
  overrides: {},
75
74
  target: {
@@ -81,7 +80,7 @@ function addMissingDependencies(packageJson, { projectName, targetName, configur
81
80
  const depPackageJsonPath = (0, path_1.join)(root, outputs[0], 'package.json');
82
81
  if ((0, fs_1.existsSync)(depPackageJsonPath)) {
83
82
  const version = (0, devkit_1.readJsonFile)(depPackageJsonPath).version;
84
- (_h = packageJson[propType]) !== null && _h !== void 0 ? _h : (packageJson[propType] = {});
83
+ packageJson[propType] ??= {};
85
84
  packageJson[propType][packageName] = version;
86
85
  }
87
86
  }
@@ -114,22 +113,23 @@ function getExports(options) {
114
113
  }
115
114
  exports.getExports = getExports;
116
115
  function getUpdatedPackageJsonContent(packageJson, options) {
117
- var _a, _b, _c, _d, _e, _f, _g;
118
- var _h;
119
116
  // Default is CJS unless esm is explicitly passed.
120
- const hasCjsFormat = !options.format || ((_a = options.format) === null || _a === void 0 ? void 0 : _a.includes('cjs'));
121
- const hasEsmFormat = (_b = options.format) === null || _b === void 0 ? void 0 : _b.includes('esm');
117
+ const hasCjsFormat = !options.format || options.format?.includes('cjs');
118
+ const hasEsmFormat = options.format?.includes('esm');
122
119
  if (options.generateExportsField) {
123
120
  packageJson.exports =
124
- typeof packageJson.exports === 'string' ? {} : Object.assign({}, packageJson.exports);
121
+ typeof packageJson.exports === 'string' ? {} : { ...packageJson.exports };
125
122
  packageJson.exports['./package.json'] = './package.json';
126
123
  }
127
124
  if (hasEsmFormat) {
128
- const esmExports = getExports(Object.assign(Object.assign({}, options), { fileExt: (_c = options.outputFileExtensionForEsm) !== null && _c !== void 0 ? _c : '.js' }));
125
+ const esmExports = getExports({
126
+ ...options,
127
+ fileExt: options.outputFileExtensionForEsm ?? '.js',
128
+ });
129
129
  packageJson.module = esmExports['.'];
130
130
  if (!hasCjsFormat) {
131
131
  packageJson.type = 'module';
132
- (_d = packageJson.main) !== null && _d !== void 0 ? _d : (packageJson.main = esmExports['.']);
132
+ packageJson.main ??= esmExports['.'];
133
133
  }
134
134
  if (options.generateExportsField) {
135
135
  for (const [exportEntry, filePath] of Object.entries(esmExports)) {
@@ -143,7 +143,10 @@ function getUpdatedPackageJsonContent(packageJson, options) {
143
143
  // Bundlers like rollup and esbuild supports .cjs for CJS and .js for ESM.
144
144
  // Bundlers/Compilers like webpack, tsc, swc do not have different file extensions (unless you use .mts or .cts in source).
145
145
  if (hasCjsFormat) {
146
- const cjsExports = getExports(Object.assign(Object.assign({}, options), { fileExt: (_e = options.outputFileExtensionForCjs) !== null && _e !== void 0 ? _e : '.js' }));
146
+ const cjsExports = getExports({
147
+ ...options,
148
+ fileExt: options.outputFileExtensionForCjs ?? '.js',
149
+ });
147
150
  packageJson.main = cjsExports['.'];
148
151
  if (!hasEsmFormat) {
149
152
  packageJson.type = 'commonjs';
@@ -151,7 +154,7 @@ function getUpdatedPackageJsonContent(packageJson, options) {
151
154
  if (options.generateExportsField) {
152
155
  for (const [exportEntry, filePath] of Object.entries(cjsExports)) {
153
156
  if (hasEsmFormat) {
154
- (_f = (_h = packageJson.exports[exportEntry])['default']) !== null && _f !== void 0 ? _f : (_h['default'] = filePath);
157
+ packageJson.exports[exportEntry]['default'] ??= filePath;
155
158
  }
156
159
  else {
157
160
  packageJson.exports[exportEntry] = filePath;
@@ -163,7 +166,7 @@ function getUpdatedPackageJsonContent(packageJson, options) {
163
166
  const mainFile = (0, path_1.basename)(options.main).replace(/\.[tj]s$/, '');
164
167
  const relativeMainFileDir = (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(options.main, options.projectRoot);
165
168
  const typingsFile = `${relativeMainFileDir}${mainFile}.d.ts`;
166
- packageJson.types = (_g = packageJson.types) !== null && _g !== void 0 ? _g : typingsFile;
169
+ packageJson.types = packageJson.types ?? typingsFile;
167
170
  }
168
171
  return packageJson;
169
172
  }
@@ -1,37 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveUserExistingPrettierConfig = void 0;
4
- const tslib_1 = require("tslib");
5
4
  let prettier;
6
5
  try {
7
6
  prettier = require('prettier');
8
7
  }
9
- catch (_a) { }
10
- function resolveUserExistingPrettierConfig() {
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- if (!prettier) {
8
+ catch { }
9
+ async function resolveUserExistingPrettierConfig() {
10
+ if (!prettier) {
11
+ return null;
12
+ }
13
+ try {
14
+ const filepath = await prettier.resolveConfigFile();
15
+ if (!filepath) {
13
16
  return null;
14
17
  }
15
- try {
16
- const filepath = yield prettier.resolveConfigFile();
17
- if (!filepath) {
18
- return null;
19
- }
20
- const config = yield prettier.resolveConfig(process.cwd(), {
21
- useCache: false,
22
- config: filepath,
23
- });
24
- if (!config) {
25
- return null;
26
- }
27
- return {
28
- sourceFilepath: filepath,
29
- config: config,
30
- };
31
- }
32
- catch (_a) {
18
+ const config = await prettier.resolveConfig(process.cwd(), {
19
+ useCache: false,
20
+ config: filepath,
21
+ });
22
+ if (!config) {
33
23
  return null;
34
24
  }
35
- });
25
+ return {
26
+ sourceFilepath: filepath,
27
+ config: config,
28
+ };
29
+ }
30
+ catch {
31
+ return null;
32
+ }
36
33
  }
37
34
  exports.resolveUserExistingPrettierConfig = resolveUserExistingPrettierConfig;