@atlaspack/transformer-js 3.2.3-dev.73 → 3.2.3-dev.95
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 +22 -3
- package/package.json +8 -8
- package/src/JSTransformer.js +10 -1
package/lib/JSTransformer.js
CHANGED
|
@@ -25,6 +25,13 @@ function _rust() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
function _assert() {
|
|
29
|
+
const data = _interopRequireDefault(require("assert"));
|
|
30
|
+
_assert = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
28
35
|
function _browserslist() {
|
|
29
36
|
const data = _interopRequireDefault(require("browserslist"));
|
|
30
37
|
_browserslist = function () {
|
|
@@ -177,7 +184,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
177
184
|
}
|
|
178
185
|
reactRefresh = options.hmrOptions && options.mode === 'development' && Boolean((packageJson === null || packageJson === void 0 || (_packageJson$dependen2 = packageJson.dependencies) === null || _packageJson$dependen2 === void 0 ? void 0 : _packageJson$dependen2.react) || (packageJson === null || packageJson === void 0 || (_packageJson$devDepen2 = packageJson.devDependencies) === null || _packageJson$devDepen2 === void 0 ? void 0 : _packageJson$devDepen2.react) || (packageJson === null || packageJson === void 0 || (_packageJson$peerDepe2 = packageJson.peerDependencies) === null || _packageJson$peerDepe2 === void 0 ? void 0 : _packageJson$peerDepe2.react));
|
|
179
186
|
const compilerOptions = (_await$config$getConf = await config.getConfigFrom(options.projectRoot + '/index', ['tsconfig.json', 'jsconfig.json'], {
|
|
180
|
-
readTracking:
|
|
187
|
+
readTracking: true
|
|
181
188
|
})) === null || _await$config$getConf === void 0 || (_await$config$getConf = _await$config$getConf.contents) === null || _await$config$getConf === void 0 ? void 0 : _await$config$getConf.compilerOptions;
|
|
182
189
|
|
|
183
190
|
// Use explicitly defined JSX options in tsconfig.json over inferred values from dependencies.
|
|
@@ -306,6 +313,9 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
306
313
|
if (options.env.NODE_ENV != null) {
|
|
307
314
|
env.NODE_ENV = options.env.NODE_ENV;
|
|
308
315
|
}
|
|
316
|
+
if (process.env.ATLASPACK_BUILD_ENV === 'test') {
|
|
317
|
+
env.ATLASPACK_BUILD_ENV = 'test';
|
|
318
|
+
}
|
|
309
319
|
} else if (Array.isArray(config === null || config === void 0 ? void 0 : config.inlineEnvironment)) {
|
|
310
320
|
for (let match of (0, _utils().globMatch)(Object.keys(options.env), config.inlineEnvironment)) {
|
|
311
321
|
env[match] = String(options.env[match]);
|
|
@@ -374,6 +384,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
374
384
|
standalone: asset.query.has('standalone'),
|
|
375
385
|
inline_constants: config.inlineConstants,
|
|
376
386
|
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
387
|
+
hmr_improvements: options.featureFlags.hmrImprovements,
|
|
377
388
|
magic_comments: Boolean(config === null || config === void 0 ? void 0 : config.magicComments),
|
|
378
389
|
callMacro: asset.isSource ? async (err, src, exportName, args, loc) => {
|
|
379
390
|
let mod;
|
|
@@ -399,7 +410,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
399
410
|
}
|
|
400
411
|
try {
|
|
401
412
|
if (typeof mod[exportName] === 'function') {
|
|
402
|
-
|
|
413
|
+
let ctx = {
|
|
403
414
|
// Allows macros to emit additional assets to add as dependencies (e.g. css).
|
|
404
415
|
addAsset(a) {
|
|
405
416
|
let k = String(macroAssets.length);
|
|
@@ -458,7 +469,8 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
458
469
|
invalidateOnBuild() {
|
|
459
470
|
asset.invalidateOnBuild();
|
|
460
471
|
}
|
|
461
|
-
}
|
|
472
|
+
};
|
|
473
|
+
return mod[exportName].apply(ctx, args);
|
|
462
474
|
} else {
|
|
463
475
|
throw new Error(`"${exportName}" in "${src}" is not a function.`);
|
|
464
476
|
}
|
|
@@ -630,6 +642,13 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
630
642
|
});
|
|
631
643
|
} else if (dep.kind === 'File') {
|
|
632
644
|
asset.invalidateOnFileChange(dep.specifier);
|
|
645
|
+
} else if (dep.kind === 'Id') {
|
|
646
|
+
// Record parcelRequire calls so that the dev packager can add them as dependencies.
|
|
647
|
+
// This allows the HMR runtime to collect parents across async boundaries (through runtimes).
|
|
648
|
+
// TODO: ideally this would result as an actual dep in the graph rather than asset.meta.
|
|
649
|
+
asset.meta.hmrDeps ??= [];
|
|
650
|
+
(0, _assert().default)(Array.isArray(asset.meta.hmrDeps));
|
|
651
|
+
asset.meta.hmrDeps.push(dep.specifier);
|
|
633
652
|
} else {
|
|
634
653
|
let meta = {
|
|
635
654
|
kind: dep.kind
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-js",
|
|
3
|
-
"version": "3.2.3-dev.
|
|
3
|
+
"version": "3.2.3-dev.95+d8e35a83e",
|
|
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.
|
|
26
|
-
"@atlaspack/feature-flags": "2.14.1-dev.
|
|
27
|
-
"@atlaspack/plugin": "2.14.5-dev.
|
|
28
|
-
"@atlaspack/rust": "3.2.1-dev.
|
|
29
|
-
"@atlaspack/utils": "2.14.5-dev.
|
|
30
|
-
"@atlaspack/workers": "2.14.5-dev.
|
|
25
|
+
"@atlaspack/diagnostic": "2.14.1-dev.163+d8e35a83e",
|
|
26
|
+
"@atlaspack/feature-flags": "2.14.1-dev.163+d8e35a83e",
|
|
27
|
+
"@atlaspack/plugin": "2.14.5-dev.95+d8e35a83e",
|
|
28
|
+
"@atlaspack/rust": "3.2.1-dev.95+d8e35a83e",
|
|
29
|
+
"@atlaspack/utils": "2.14.5-dev.95+d8e35a83e",
|
|
30
|
+
"@atlaspack/workers": "2.14.5-dev.95+d8e35a83e",
|
|
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": "
|
|
42
|
+
"gitHead": "d8e35a83e480e0811b63a319e88ffe9a2cd509e6"
|
|
43
43
|
}
|
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 invariant from 'assert';
|
|
15
16
|
import browserslist from 'browserslist';
|
|
16
17
|
import semver from 'semver';
|
|
17
18
|
import nullthrows from 'nullthrows';
|
|
@@ -211,7 +212,7 @@ export default (new Transformer({
|
|
|
211
212
|
options.projectRoot + '/index',
|
|
212
213
|
['tsconfig.json', 'jsconfig.json'],
|
|
213
214
|
{
|
|
214
|
-
readTracking:
|
|
215
|
+
readTracking: true,
|
|
215
216
|
},
|
|
216
217
|
)
|
|
217
218
|
)?.contents?.compilerOptions;
|
|
@@ -474,6 +475,7 @@ export default (new Transformer({
|
|
|
474
475
|
standalone: asset.query.has('standalone'),
|
|
475
476
|
inline_constants: config.inlineConstants,
|
|
476
477
|
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
478
|
+
hmr_improvements: options.featureFlags.hmrImprovements,
|
|
477
479
|
magic_comments: Boolean(config?.magicComments),
|
|
478
480
|
callMacro: asset.isSource
|
|
479
481
|
? async (err, src, exportName, args, loc) => {
|
|
@@ -780,6 +782,13 @@ export default (new Transformer({
|
|
|
780
782
|
});
|
|
781
783
|
} else if (dep.kind === 'File') {
|
|
782
784
|
asset.invalidateOnFileChange(dep.specifier);
|
|
785
|
+
} else if (dep.kind === 'Id') {
|
|
786
|
+
// Record parcelRequire calls so that the dev packager can add them as dependencies.
|
|
787
|
+
// This allows the HMR runtime to collect parents across async boundaries (through runtimes).
|
|
788
|
+
// TODO: ideally this would result as an actual dep in the graph rather than asset.meta.
|
|
789
|
+
asset.meta.hmrDeps ??= [];
|
|
790
|
+
invariant(Array.isArray(asset.meta.hmrDeps));
|
|
791
|
+
asset.meta.hmrDeps.push(dep.specifier);
|
|
783
792
|
} else {
|
|
784
793
|
let meta: JSONObject = {kind: dep.kind};
|
|
785
794
|
if (dep.attributes) {
|