@nx/js 18.2.0-beta.0 → 18.2.0-beta.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/babel.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path_1 = require("path");
4
+ const semver_1 = require("semver");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  module.exports = function (api, options = {}) {
6
7
  api.assertVersion(7);
@@ -27,22 +28,7 @@ module.exports = function (api, options = {}) {
27
28
  // such as import syntax.
28
29
  isTest || process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID
29
30
  ? { targets: { node: 'current' }, loose: true }
30
- : {
31
- // Allow importing core-js in entrypoint and use browserslist to select polyfills.
32
- useBuiltIns: options.useBuiltIns ?? 'entry',
33
- corejs: options.useBuiltIns !== false
34
- ? // Setting the minor version as well for better optimization (See: https://github.com/zloirock/core-js#babelpreset-env)
35
- '3.36'
36
- : null,
37
- // Do not transform modules to CJS
38
- modules: false,
39
- targets: isModern ? { esmodules: 'intersect' } : undefined,
40
- bugfixes: true,
41
- // Exclude transforms that make all code slower
42
- exclude: ['transform-typeof-symbol'],
43
- // This must match the setting for `@babel/plugin-proposal-class-properties`
44
- loose,
45
- },
31
+ : createBabelPresetEnvOptions(options.useBuiltIns, isModern, loose),
46
32
  ],
47
33
  [
48
34
  require.resolve('@babel/preset-typescript'),
@@ -92,3 +78,34 @@ module.exports = function (api, options = {}) {
92
78
  ],
93
79
  };
94
80
  };
81
+ function createBabelPresetEnvOptions(useBuiltIns, isModern, loose) {
82
+ const presetOptions = {
83
+ // Do not transform modules to CJS
84
+ modules: false,
85
+ targets: isModern ? { esmodules: 'intersect' } : undefined,
86
+ bugfixes: true,
87
+ // Exclude transforms that make all code slower
88
+ exclude: ['transform-typeof-symbol'],
89
+ // This must match the setting for `@babel/plugin-proposal-class-properties`
90
+ loose,
91
+ };
92
+ // If core-js is installed then set corresponding options, otherwise don't use core-js.
93
+ // Previously, core-js was required for all projects, but it is not longer required when using only stable JS features that does not need to be transpiled.
94
+ const coreJsVersion = findCoreJsVersion();
95
+ if (coreJsVersion) {
96
+ presetOptions.useBuiltIns = useBuiltIns ?? 'entry';
97
+ presetOptions.corejs = useBuiltIns !== false ? coreJsVersion : null;
98
+ }
99
+ return presetOptions;
100
+ }
101
+ function findCoreJsVersion() {
102
+ try {
103
+ // nx-ignore-next-line
104
+ const v = require('core-js/package.json').version;
105
+ const { major, minor } = (0, semver_1.parse)(v);
106
+ return `${major}.${minor}`;
107
+ }
108
+ catch (e) {
109
+ return null;
110
+ }
111
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "18.2.0-beta.0",
3
+ "version": "18.2.0-beta.2",
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": {
@@ -57,9 +57,9 @@
57
57
  "semver": "^7.5.3",
58
58
  "source-map-support": "0.5.19",
59
59
  "tslib": "^2.3.0",
60
- "@nx/devkit": "18.2.0-beta.0",
61
- "@nx/workspace": "18.2.0-beta.0",
62
- "@nrwl/js": "18.2.0-beta.0"
60
+ "@nx/devkit": "18.2.0-beta.2",
61
+ "@nx/workspace": "18.2.0-beta.2",
62
+ "@nrwl/js": "18.2.0-beta.2"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "verdaccio": "^5.0.4"
@@ -121,8 +121,9 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
121
121
  return;
122
122
  if (target.executor === '@nx/js:tsc' && target.options?.tsConfig) {
123
123
  const tsConfig = (0, ts_config_1.readTsConfig)((0, path_1.join)(workspaceRoot, target.options.tsConfig));
124
- if (tsConfig?.options['importHelpers']) {
125
- npmDeps['tslib'] = projectGraph.externalNodes['npm:tslib']?.data.version;
124
+ if (tsConfig?.options['importHelpers'] &&
125
+ projectGraph.externalNodes['npm:tslib']?.type === 'npm') {
126
+ npmDeps['tslib'] = projectGraph.externalNodes['npm:tslib'].data.version;
126
127
  }
127
128
  }
128
129
  if (target.executor === '@nx/js:swc') {
@@ -132,9 +133,10 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
132
133
  const swcConfig = (0, fileutils_1.fileExists)(swcConfigPath)
133
134
  ? (0, devkit_1.readJsonFile)(swcConfigPath)
134
135
  : {};
135
- if (swcConfig?.jsc?.externalHelpers) {
136
+ if (swcConfig?.jsc?.externalHelpers &&
137
+ projectGraph.externalNodes['npm:@swc/helpers']?.type === 'npm') {
136
138
  npmDeps['@swc/helpers'] =
137
- projectGraph.externalNodes['npm:@swc/helpers']?.data.version;
139
+ projectGraph.externalNodes['npm:@swc/helpers'].data.version;
138
140
  }
139
141
  }
140
142
  }