@atlaspack/transformer-js 3.2.3-dev.14 → 3.2.3-dev.55

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.
@@ -163,7 +163,7 @@ var _default = exports.default = new (_plugin().Transformer)({
163
163
  let pkg = await config.getPackage();
164
164
  let isJSX, pragma, pragmaFrag, jsxImportSource, automaticJSXRuntime, reactRefresh, decorators, useDefineForClassFields;
165
165
  if (config.isSource) {
166
- var _pkg$dependencies2, _pkg$devDependencies2, _pkg$peerDependencies2, _tsconfig$contents;
166
+ var _pkg$dependencies2, _pkg$devDependencies2, _pkg$peerDependencies2, _await$config$getConf, _await$config$getConf2;
167
167
  let reactLib;
168
168
  if (pkg !== null && pkg !== void 0 && pkg.alias && pkg.alias['react']) {
169
169
  // e.g.: `{ alias: { "react": "preact/compat" } }`
@@ -176,8 +176,9 @@ var _default = exports.default = new (_plugin().Transformer)({
176
176
  });
177
177
  }
178
178
  reactRefresh = options.hmrOptions && options.mode === 'development' && Boolean((pkg === null || pkg === void 0 || (_pkg$dependencies2 = pkg.dependencies) === null || _pkg$dependencies2 === void 0 ? void 0 : _pkg$dependencies2.react) || (pkg === null || pkg === void 0 || (_pkg$devDependencies2 = pkg.devDependencies) === null || _pkg$devDependencies2 === void 0 ? void 0 : _pkg$devDependencies2.react) || (pkg === null || pkg === void 0 || (_pkg$peerDependencies2 = pkg.peerDependencies) === null || _pkg$peerDependencies2 === void 0 ? void 0 : _pkg$peerDependencies2.react));
179
- let tsconfig = await config.getConfigFrom(options.projectRoot + '/index', ['tsconfig.json', 'jsconfig.json']);
180
- let compilerOptions = tsconfig === null || tsconfig === void 0 || (_tsconfig$contents = tsconfig.contents) === null || _tsconfig$contents === void 0 ? void 0 : _tsconfig$contents.compilerOptions;
179
+ const compilerOptions = (0, _featureFlags().getFeatureFlag)('granularTsConfigInvalidation') ? (_await$config$getConf = await config.getConfigFrom(options.projectRoot + '/index', ['tsconfig.json', 'jsconfig.json'], {
180
+ configKey: 'compilerOptions'
181
+ })) === null || _await$config$getConf === void 0 ? void 0 : _await$config$getConf.contents : (_await$config$getConf2 = await config.getConfigFrom(options.projectRoot + '/index', ['tsconfig.json', 'jsconfig.json'])) === null || _await$config$getConf2 === void 0 || (_await$config$getConf2 = _await$config$getConf2.contents) === null || _await$config$getConf2 === void 0 ? void 0 : _await$config$getConf2.compilerOptions;
181
182
 
182
183
  // Use explicitly defined JSX options in tsconfig.json over inferred values from dependencies.
183
184
  pragma = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFactory) || (reactLib ? JSX_PRAGMA[reactLib].pragma : undefined);
@@ -305,6 +306,9 @@ var _default = exports.default = new (_plugin().Transformer)({
305
306
  if (options.env.NODE_ENV != null) {
306
307
  env.NODE_ENV = options.env.NODE_ENV;
307
308
  }
309
+ if (process.env.ATLASPACK_BUILD_ENV === 'test') {
310
+ env.ATLASPACK_BUILD_ENV = 'test';
311
+ }
308
312
  } else if (Array.isArray(config === null || config === void 0 ? void 0 : config.inlineEnvironment)) {
309
313
  for (let match of (0, _utils().globMatch)(Object.keys(options.env), config.inlineEnvironment)) {
310
314
  env[match] = String(options.env[match]);
@@ -398,7 +402,7 @@ var _default = exports.default = new (_plugin().Transformer)({
398
402
  }
399
403
  try {
400
404
  if (typeof mod[exportName] === 'function') {
401
- return mod[exportName].apply({
405
+ let ctx = {
402
406
  // Allows macros to emit additional assets to add as dependencies (e.g. css).
403
407
  addAsset(a) {
404
408
  let k = String(macroAssets.length);
@@ -457,7 +461,8 @@ var _default = exports.default = new (_plugin().Transformer)({
457
461
  invalidateOnBuild() {
458
462
  asset.invalidateOnBuild();
459
463
  }
460
- }, args);
464
+ };
465
+ return mod[exportName].apply(ctx, args);
461
466
  } else {
462
467
  throw new Error(`"${exportName}" in "${src}" is not a function.`);
463
468
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-js",
3
- "version": "3.2.3-dev.14+8c369e38c",
3
+ "version": "3.2.3-dev.55+5a11f33c5",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,12 +22,12 @@
22
22
  "src"
23
23
  ],
24
24
  "dependencies": {
25
- "@atlaspack/diagnostic": "2.14.1-dev.82+8c369e38c",
26
- "@atlaspack/feature-flags": "2.14.1-dev.82+8c369e38c",
27
- "@atlaspack/plugin": "2.14.5-dev.14+8c369e38c",
28
- "@atlaspack/rust": "3.2.1-dev.14+8c369e38c",
29
- "@atlaspack/utils": "2.14.5-dev.14+8c369e38c",
30
- "@atlaspack/workers": "2.14.5-dev.14+8c369e38c",
25
+ "@atlaspack/diagnostic": "2.14.1-dev.123+5a11f33c5",
26
+ "@atlaspack/feature-flags": "2.14.1-dev.123+5a11f33c5",
27
+ "@atlaspack/plugin": "2.14.5-dev.55+5a11f33c5",
28
+ "@atlaspack/rust": "3.2.1-dev.55+5a11f33c5",
29
+ "@atlaspack/utils": "2.14.5-dev.55+5a11f33c5",
30
+ "@atlaspack/workers": "2.14.5-dev.55+5a11f33c5",
31
31
  "@parcel/source-map": "^2.1.1",
32
32
  "@swc/helpers": "^0.5.15",
33
33
  "browserslist": "^4.6.6",
@@ -39,5 +39,5 @@
39
39
  "@atlaspack/core": "^2.13.1"
40
40
  },
41
41
  "type": "commonjs",
42
- "gitHead": "8c369e38ccd428409811114aebd6044c27f90705"
42
+ "gitHead": "5a11f33c51ff74d1cf8d4b72cfa0fda833aa980a"
43
43
  }
@@ -206,11 +206,22 @@ export default (new Transformer({
206
206
  pkg?.peerDependencies?.react,
207
207
  );
208
208
 
209
- let tsconfig = await config.getConfigFrom<TSConfig>(
210
- options.projectRoot + '/index',
211
- ['tsconfig.json', 'jsconfig.json'],
212
- );
213
- let compilerOptions = tsconfig?.contents?.compilerOptions;
209
+ const compilerOptions: TSConfig['compilerOptions'] = getFeatureFlag(
210
+ 'granularTsConfigInvalidation',
211
+ )
212
+ ? (
213
+ await config.getConfigFrom<TSConfig['compilerOptions']>(
214
+ options.projectRoot + '/index',
215
+ ['tsconfig.json', 'jsconfig.json'],
216
+ {configKey: 'compilerOptions'},
217
+ )
218
+ )?.contents
219
+ : (
220
+ await config.getConfigFrom<TSConfig>(
221
+ options.projectRoot + '/index',
222
+ ['tsconfig.json', 'jsconfig.json'],
223
+ )
224
+ )?.contents?.compilerOptions;
214
225
 
215
226
  // Use explicitly defined JSX options in tsconfig.json over inferred values from dependencies.
216
227
  pragma =