@atlaspack/transformer-js 3.1.1-dev.10 → 3.1.1-dev.107
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/lib/JSTransformer.js +34 -12
- package/package.json +12 -10
- package/src/JSTransformer.js +35 -12
package/lib/JSTransformer.js
CHANGED
|
@@ -25,6 +25,13 @@ function _rust() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
function _core() {
|
|
29
|
+
const data = require("@atlaspack/core");
|
|
30
|
+
_core = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
28
35
|
function _browserslist() {
|
|
29
36
|
const data = _interopRequireDefault(require("browserslist"));
|
|
30
37
|
_browserslist = function () {
|
|
@@ -71,6 +78,7 @@ function _featureFlags() {
|
|
|
71
78
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
72
79
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
73
80
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
81
|
+
const esm_helpers_specifier = (0, _core().isSuperPackage)() ? './esmodule-helpers.js' : '@atlaspack/transformer-js/src/esmodule-helpers.js';
|
|
74
82
|
const JSX_EXTENSIONS = {
|
|
75
83
|
jsx: true,
|
|
76
84
|
tsx: true
|
|
@@ -345,7 +353,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
345
353
|
module_id: asset.id,
|
|
346
354
|
project_root: options.projectRoot,
|
|
347
355
|
replace_env: !asset.env.isNode(),
|
|
348
|
-
inline_fs: Boolean(config === null || config === void 0 ? void 0 : config.inlineFS) && !asset.env.isNode(),
|
|
356
|
+
inline_fs: process.env.ATLASPACK_SUPER_BUILD === 'true' || Boolean(config === null || config === void 0 ? void 0 : config.inlineFS) && !asset.env.isNode(),
|
|
349
357
|
insert_node_globals: !asset.env.isNode() && asset.env.sourceType !== 'script',
|
|
350
358
|
node_replacer: asset.env.isNode(),
|
|
351
359
|
is_browser: asset.env.isBrowser(),
|
|
@@ -374,6 +382,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
374
382
|
inline_constants: config.inlineConstants,
|
|
375
383
|
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
376
384
|
magic_comments: Boolean(config === null || config === void 0 ? void 0 : config.magicComments),
|
|
385
|
+
esm_helpers_specifier,
|
|
377
386
|
callMacro: asset.isSource ? async (err, src, exportName, args, loc) => {
|
|
378
387
|
let mod;
|
|
379
388
|
try {
|
|
@@ -466,7 +475,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
466
475
|
let stack = (err.stack || '').split('\n').slice(1);
|
|
467
476
|
let message = err.message;
|
|
468
477
|
for (let line of stack) {
|
|
469
|
-
if (line.includes(__filename)) {
|
|
478
|
+
if (line.includes( /*#__ATLASPACK_IGNORE__*/__filename)) {
|
|
470
479
|
break;
|
|
471
480
|
}
|
|
472
481
|
message += '\n' + line;
|
|
@@ -704,7 +713,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
704
713
|
priority: dep.kind === 'DynamicImport' ? 'lazy' : dep.kind === 'ConditionalImport' ? 'conditional' : 'sync',
|
|
705
714
|
isOptional: dep.is_optional,
|
|
706
715
|
meta,
|
|
707
|
-
resolveFrom: isHelper ? __filename : undefined,
|
|
716
|
+
resolveFrom: isHelper ? /*#__ATLASPACK_IGNORE__*/__filename : undefined,
|
|
708
717
|
range,
|
|
709
718
|
env
|
|
710
719
|
});
|
|
@@ -866,16 +875,29 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
866
875
|
}
|
|
867
876
|
}
|
|
868
877
|
if (needs_esm_helpers) {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
878
|
+
if ((0, _core().isSuperPackage)()) {
|
|
879
|
+
asset.addDependency({
|
|
880
|
+
specifier: esm_helpers_specifier,
|
|
881
|
+
specifierType: 'esm',
|
|
882
|
+
resolveFrom: /*#__ATLASPACK_IGNORE__*/__filename,
|
|
883
|
+
env: {
|
|
884
|
+
includeNodeModules: {
|
|
885
|
+
'@atlaspack/super': true
|
|
886
|
+
}
|
|
876
887
|
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
888
|
+
});
|
|
889
|
+
} else {
|
|
890
|
+
asset.addDependency({
|
|
891
|
+
specifier: esm_helpers_specifier,
|
|
892
|
+
specifierType: 'esm',
|
|
893
|
+
resolveFrom: /*#__ATLASPACK_IGNORE__*/__filename,
|
|
894
|
+
env: {
|
|
895
|
+
includeNodeModules: {
|
|
896
|
+
'@atlaspack/transformer-js': true
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}
|
|
879
901
|
}
|
|
880
902
|
}
|
|
881
903
|
asset.type = 'js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-js",
|
|
3
|
-
"version": "3.1.1-dev.
|
|
3
|
+
"version": "3.1.1-dev.107+4f5d524fd",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,20 +15,22 @@
|
|
|
15
15
|
"test": "mocha"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
|
-
"atlaspack": "^2.14.1-dev.10+1adc60d42",
|
|
19
18
|
"node": ">= 16.0.0"
|
|
20
19
|
},
|
|
21
20
|
"files": [
|
|
22
21
|
"lib",
|
|
23
22
|
"src"
|
|
24
23
|
],
|
|
24
|
+
"atlaspackReferences": [
|
|
25
|
+
"src/esmodule-helpers.js"
|
|
26
|
+
],
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@atlaspack/diagnostic": "2.14.1-dev.
|
|
27
|
-
"@atlaspack/feature-flags": "2.14.1-dev.
|
|
28
|
-
"@atlaspack/plugin": "2.14.1-dev.
|
|
29
|
-
"@atlaspack/rust": "3.0.1-dev.
|
|
30
|
-
"@atlaspack/utils": "2.14.1-dev.
|
|
31
|
-
"@atlaspack/workers": "2.14.1-dev.
|
|
28
|
+
"@atlaspack/diagnostic": "2.14.1-dev.107+4f5d524fd",
|
|
29
|
+
"@atlaspack/feature-flags": "2.14.1-dev.107+4f5d524fd",
|
|
30
|
+
"@atlaspack/plugin": "2.14.1-dev.107+4f5d524fd",
|
|
31
|
+
"@atlaspack/rust": "3.0.1-dev.107+4f5d524fd",
|
|
32
|
+
"@atlaspack/utils": "2.14.1-dev.107+4f5d524fd",
|
|
33
|
+
"@atlaspack/workers": "2.14.1-dev.107+4f5d524fd",
|
|
32
34
|
"@parcel/source-map": "^2.1.1",
|
|
33
35
|
"@swc/helpers": "^0.5.15",
|
|
34
36
|
"browserslist": "^4.6.6",
|
|
@@ -37,8 +39,8 @@
|
|
|
37
39
|
"semver": "^7.5.2"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
40
|
-
"@atlaspack/core": "^2.
|
|
42
|
+
"@atlaspack/core": "^2.13.1"
|
|
41
43
|
},
|
|
42
44
|
"type": "commonjs",
|
|
43
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "4f5d524fdb28f9955f3a26abe0115d7545eb41f4"
|
|
44
46
|
}
|
package/src/JSTransformer.js
CHANGED
|
@@ -12,6 +12,7 @@ import type {Diagnostic} from '@atlaspack/diagnostic';
|
|
|
12
12
|
import SourceMap from '@parcel/source-map';
|
|
13
13
|
import {Transformer} from '@atlaspack/plugin';
|
|
14
14
|
import {transform, transformAsync} from '@atlaspack/rust';
|
|
15
|
+
import {isSuperPackage} from '@atlaspack/core';
|
|
15
16
|
import browserslist from 'browserslist';
|
|
16
17
|
import semver from 'semver';
|
|
17
18
|
import nullthrows from 'nullthrows';
|
|
@@ -23,6 +24,10 @@ import {validateSchema, remapSourceLocation, globMatch} from '@atlaspack/utils';
|
|
|
23
24
|
import pkg from '../package.json';
|
|
24
25
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
25
26
|
|
|
27
|
+
const esm_helpers_specifier = isSuperPackage()
|
|
28
|
+
? './esmodule-helpers.js'
|
|
29
|
+
: '@atlaspack/transformer-js/src/esmodule-helpers.js';
|
|
30
|
+
|
|
26
31
|
const JSX_EXTENSIONS = {
|
|
27
32
|
jsx: true,
|
|
28
33
|
tsx: true,
|
|
@@ -435,7 +440,9 @@ export default (new Transformer({
|
|
|
435
440
|
module_id: asset.id,
|
|
436
441
|
project_root: options.projectRoot,
|
|
437
442
|
replace_env: !asset.env.isNode(),
|
|
438
|
-
inline_fs:
|
|
443
|
+
inline_fs:
|
|
444
|
+
process.env.ATLASPACK_SUPER_BUILD === 'true' ||
|
|
445
|
+
(Boolean(config?.inlineFS) && !asset.env.isNode()),
|
|
439
446
|
insert_node_globals:
|
|
440
447
|
!asset.env.isNode() && asset.env.sourceType !== 'script',
|
|
441
448
|
node_replacer: asset.env.isNode(),
|
|
@@ -471,6 +478,7 @@ export default (new Transformer({
|
|
|
471
478
|
inline_constants: config.inlineConstants,
|
|
472
479
|
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
473
480
|
magic_comments: Boolean(config?.magicComments),
|
|
481
|
+
esm_helpers_specifier,
|
|
474
482
|
callMacro: asset.isSource
|
|
475
483
|
? async (err, src, exportName, args, loc) => {
|
|
476
484
|
let mod;
|
|
@@ -574,7 +582,7 @@ export default (new Transformer({
|
|
|
574
582
|
let stack = (err.stack || '').split('\n').slice(1);
|
|
575
583
|
let message = err.message;
|
|
576
584
|
for (let line of stack) {
|
|
577
|
-
if (line.includes(__filename)) {
|
|
585
|
+
if (line.includes(/*#__ATLASPACK_IGNORE__*/ __filename)) {
|
|
578
586
|
break;
|
|
579
587
|
}
|
|
580
588
|
message += '\n' + line;
|
|
@@ -878,7 +886,9 @@ export default (new Transformer({
|
|
|
878
886
|
: 'sync',
|
|
879
887
|
isOptional: dep.is_optional,
|
|
880
888
|
meta,
|
|
881
|
-
resolveFrom: isHelper
|
|
889
|
+
resolveFrom: isHelper
|
|
890
|
+
? /*#__ATLASPACK_IGNORE__*/ __filename
|
|
891
|
+
: undefined,
|
|
882
892
|
range,
|
|
883
893
|
env,
|
|
884
894
|
});
|
|
@@ -1066,16 +1076,29 @@ export default (new Transformer({
|
|
|
1066
1076
|
}
|
|
1067
1077
|
|
|
1068
1078
|
if (needs_esm_helpers) {
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1079
|
+
if (isSuperPackage()) {
|
|
1080
|
+
asset.addDependency({
|
|
1081
|
+
specifier: esm_helpers_specifier,
|
|
1082
|
+
specifierType: 'esm',
|
|
1083
|
+
resolveFrom: /*#__ATLASPACK_IGNORE__*/ __filename,
|
|
1084
|
+
env: {
|
|
1085
|
+
includeNodeModules: {
|
|
1086
|
+
'@atlaspack/super': true,
|
|
1087
|
+
},
|
|
1076
1088
|
},
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1089
|
+
});
|
|
1090
|
+
} else {
|
|
1091
|
+
asset.addDependency({
|
|
1092
|
+
specifier: esm_helpers_specifier,
|
|
1093
|
+
specifierType: 'esm',
|
|
1094
|
+
resolveFrom: /*#__ATLASPACK_IGNORE__*/ __filename,
|
|
1095
|
+
env: {
|
|
1096
|
+
includeNodeModules: {
|
|
1097
|
+
'@atlaspack/transformer-js': true,
|
|
1098
|
+
},
|
|
1099
|
+
},
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1079
1102
|
}
|
|
1080
1103
|
}
|
|
1081
1104
|
|