@atlaspack/transformer-js 3.4.2 → 4.0.1

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.
@@ -137,6 +137,9 @@ const CONFIG_SCHEMA = {
137
137
  }
138
138
  }]
139
139
  },
140
+ addReactDisplayName: {
141
+ type: 'boolean'
142
+ },
140
143
  magicComments: {
141
144
  type: 'boolean'
142
145
  },
@@ -238,8 +241,9 @@ var _default = exports.default = new (_plugin().Transformer)({
238
241
  let inlineFS = !ignoreFS;
239
242
  let inlineConstants = false;
240
243
  let magicComments = false;
244
+ let addReactDisplayName = false;
241
245
  if (conf && conf.contents) {
242
- var _conf$contents, _conf$contents2, _conf$contents3, _conf$contents4;
246
+ var _conf$contents, _conf$contents2, _conf$contents3, _conf$contents4, _conf$contents5;
243
247
  _utils().validateSchema.diagnostic(CONFIG_SCHEMA, {
244
248
  data: conf.contents,
245
249
  // FIXME
@@ -249,16 +253,18 @@ var _default = exports.default = new (_plugin().Transformer)({
249
253
  },
250
254
  // FIXME
251
255
  '@atlaspack/transformer-js', 'Invalid config for @atlaspack/transformer-js');
252
-
256
+ addReactDisplayName =
257
+ // @ts-expect-error TS2339
258
+ ((_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.addReactDisplayName) ?? addReactDisplayName;
253
259
  // @ts-expect-error TS2339
254
- magicComments = ((_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.magicComments) ?? magicComments;
260
+ magicComments = ((_conf$contents2 = conf.contents) === null || _conf$contents2 === void 0 ? void 0 : _conf$contents2.magicComments) ?? magicComments;
255
261
  // @ts-expect-error TS2339
256
- inlineEnvironment = ((_conf$contents2 = conf.contents) === null || _conf$contents2 === void 0 ? void 0 : _conf$contents2.inlineEnvironment) ?? inlineEnvironment;
262
+ inlineEnvironment = ((_conf$contents3 = conf.contents) === null || _conf$contents3 === void 0 ? void 0 : _conf$contents3.inlineEnvironment) ?? inlineEnvironment;
257
263
  // @ts-expect-error TS2339
258
- inlineFS = ((_conf$contents3 = conf.contents) === null || _conf$contents3 === void 0 ? void 0 : _conf$contents3.inlineFS) ?? inlineFS;
264
+ inlineFS = ((_conf$contents4 = conf.contents) === null || _conf$contents4 === void 0 ? void 0 : _conf$contents4.inlineFS) ?? inlineFS;
259
265
  inlineConstants =
260
266
  // @ts-expect-error TS2339
261
- ((_conf$contents4 = conf.contents) === null || _conf$contents4 === void 0 ? void 0 : _conf$contents4.unstable_inlineConstants) ?? inlineConstants;
267
+ ((_conf$contents5 = conf.contents) === null || _conf$contents5 === void 0 ? void 0 : _conf$contents5.unstable_inlineConstants) ?? inlineConstants;
262
268
  }
263
269
  return {
264
270
  isJSX,
@@ -269,6 +275,7 @@ var _default = exports.default = new (_plugin().Transformer)({
269
275
  inlineEnvironment,
270
276
  inlineFS,
271
277
  inlineConstants,
278
+ addReactDisplayName,
272
279
  reactRefresh,
273
280
  decorators,
274
281
  useDefineForClassFields,
@@ -395,7 +402,7 @@ var _default = exports.default = new (_plugin().Transformer)({
395
402
  insert_node_globals: !asset.env.isNode() && asset.env.sourceType !== 'script',
396
403
  node_replacer: asset.env.isNode(),
397
404
  is_browser: asset.env.isBrowser(),
398
- is_worker: asset.env.isWorker(),
405
+ is_worker: asset.env.isWorker() || asset.env.isTesseract(),
399
406
  env,
400
407
  is_type_script: asset.type === 'ts' || asset.type === 'tsx',
401
408
  is_jsx: isJSX,
@@ -404,7 +411,7 @@ var _default = exports.default = new (_plugin().Transformer)({
404
411
  automatic_jsx_runtime: Boolean(config === null || config === void 0 ? void 0 : config.automaticJSXRuntime),
405
412
  jsx_import_source: config === null || config === void 0 ? void 0 : config.jsxImportSource,
406
413
  is_development: options.mode === 'development',
407
- react_refresh: asset.env.isBrowser() && !asset.env.isLibrary && !asset.env.isWorker() && !asset.env.isWorklet() && Boolean(config === null || config === void 0 ? void 0 : config.reactRefresh),
414
+ react_refresh: asset.env.isBrowser() && !asset.env.isLibrary && !asset.env.isWorker() && !asset.env.isTesseract() && !asset.env.isWorklet() && Boolean(config === null || config === void 0 ? void 0 : config.reactRefresh),
408
415
  decorators: Boolean(config === null || config === void 0 ? void 0 : config.decorators),
409
416
  use_define_for_class_fields: Boolean(config === null || config === void 0 ? void 0 : config.useDefineForClassFields),
410
417
  targets,
@@ -421,6 +428,7 @@ var _default = exports.default = new (_plugin().Transformer)({
421
428
  conditional_bundling: options.featureFlags.conditionalBundlingApi,
422
429
  hmr_improvements: options.featureFlags.hmrImprovements,
423
430
  computed_properties_fix: options.featureFlags.unusedComputedPropertyFix,
431
+ add_display_name: Boolean(config.addReactDisplayName),
424
432
  magic_comments: Boolean(config === null || config === void 0 ? void 0 : config.magicComments) || (0, _featureFlags().getFeatureFlag)('supportWebpackChunkName'),
425
433
  callMacro: asset.isSource ? async (err, src, exportName, args, loc) => {
426
434
  let mod;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-js",
3
- "version": "3.4.2",
3
+ "version": "4.0.1",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,10 +11,11 @@
11
11
  },
12
12
  "main": "./lib/JSTransformer.js",
13
13
  "source": "./src/JSTransformer.ts",
14
- "types": "./lib/JSTransformer.d.ts",
14
+ "types": "./lib/types/JSTransformer.d.ts",
15
15
  "scripts": {
16
16
  "test": "mocha",
17
- "check-ts": "tsc --emitDeclarationOnly --rootDir src"
17
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
18
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
18
19
  },
19
20
  "engines": {
20
21
  "node": ">= 16.0.0"
@@ -25,12 +26,12 @@
25
26
  ],
26
27
  "dependencies": {
27
28
  "@atlaspack/diagnostic": "2.14.2",
28
- "@atlaspack/feature-flags": "2.21.0",
29
- "@atlaspack/plugin": "2.14.23",
30
- "@atlaspack/rust": "3.5.0",
29
+ "@atlaspack/feature-flags": "2.23.0",
30
+ "@atlaspack/plugin": "2.14.25",
31
+ "@atlaspack/rust": "3.6.0",
31
32
  "@parcel/source-map": "^2.1.1",
32
- "@atlaspack/utils": "2.18.0",
33
- "@atlaspack/workers": "2.14.23",
33
+ "@atlaspack/utils": "2.18.2",
34
+ "@atlaspack/workers": "2.14.25",
34
35
  "@swc/helpers": "^0.5.15",
35
36
  "browserslist": "^4.6.6",
36
37
  "nullthrows": "^1.1.1",
@@ -38,7 +39,7 @@
38
39
  "semver": "^7.5.2"
39
40
  },
40
41
  "peerDependencies": {
41
- "@atlaspack/core": "^2.13.1"
42
+ "@atlaspack/core": "2.23.1"
42
43
  },
43
44
  "type": "commonjs"
44
- }
45
+ }
@@ -108,6 +108,9 @@ const CONFIG_SCHEMA: SchemaEntity = {
108
108
  },
109
109
  ],
110
110
  },
111
+ addReactDisplayName: {
112
+ type: 'boolean',
113
+ },
111
114
  magicComments: {
112
115
  type: 'boolean',
113
116
  },
@@ -298,6 +301,7 @@ export default new Transformer({
298
301
  let inlineFS = !ignoreFS;
299
302
  let inlineConstants = false;
300
303
  let magicComments = false;
304
+ let addReactDisplayName = false;
301
305
 
302
306
  if (conf && conf.contents) {
303
307
  validateSchema.diagnostic(
@@ -314,6 +318,9 @@ export default new Transformer({
314
318
  'Invalid config for @atlaspack/transformer-js',
315
319
  );
316
320
 
321
+ addReactDisplayName =
322
+ // @ts-expect-error TS2339
323
+ conf.contents?.addReactDisplayName ?? addReactDisplayName;
317
324
  // @ts-expect-error TS2339
318
325
  magicComments = conf.contents?.magicComments ?? magicComments;
319
326
  // @ts-expect-error TS2339
@@ -334,6 +341,7 @@ export default new Transformer({
334
341
  inlineEnvironment,
335
342
  inlineFS,
336
343
  inlineConstants,
344
+ addReactDisplayName,
337
345
  reactRefresh,
338
346
  decorators,
339
347
  useDefineForClassFields,
@@ -478,7 +486,7 @@ export default new Transformer({
478
486
  !asset.env.isNode() && asset.env.sourceType !== 'script',
479
487
  node_replacer: asset.env.isNode(),
480
488
  is_browser: asset.env.isBrowser(),
481
- is_worker: asset.env.isWorker(),
489
+ is_worker: asset.env.isWorker() || asset.env.isTesseract(),
482
490
  env,
483
491
  is_type_script: asset.type === 'ts' || asset.type === 'tsx',
484
492
  is_jsx: isJSX,
@@ -491,6 +499,7 @@ export default new Transformer({
491
499
  asset.env.isBrowser() &&
492
500
  !asset.env.isLibrary &&
493
501
  !asset.env.isWorker() &&
502
+ !asset.env.isTesseract() &&
494
503
  !asset.env.isWorklet() &&
495
504
  Boolean(config?.reactRefresh),
496
505
  decorators: Boolean(config?.decorators),
@@ -510,6 +519,7 @@ export default new Transformer({
510
519
  conditional_bundling: options.featureFlags.conditionalBundlingApi,
511
520
  hmr_improvements: options.featureFlags.hmrImprovements,
512
521
  computed_properties_fix: options.featureFlags.unusedComputedPropertyFix,
522
+ add_display_name: Boolean(config.addReactDisplayName),
513
523
  magic_comments:
514
524
  Boolean(config?.magicComments) ||
515
525
  getFeatureFlag('supportWebpackChunkName'),