@atlaspack/packager-js 2.21.4-dev-optimised-prelude-6fa233c65.0 → 2.21.4-dev-export-func-removal-960dd335d.0
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/ScopeHoistingPackager.js +14 -8
- package/lib/helpers.js +3 -38
- package/lib/types/helpers.d.ts +1 -2
- package/package.json +8 -8
- package/src/ScopeHoistingPackager.ts +16 -19
- package/src/helpers.ts +1 -36
|
@@ -1144,9 +1144,11 @@ ${code}
|
|
|
1144
1144
|
symbol, undefined, replacements);
|
|
1145
1145
|
let get = this.buildFunctionExpression([], resolvedSymbol);
|
|
1146
1146
|
let set = asset.meta.hasCJSExports ? ', ' + this.buildFunctionExpression(['v'], `${resolvedSymbol} = v`) : '';
|
|
1147
|
-
prepend += `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1148
|
-
|
|
1149
|
-
|
|
1147
|
+
// prepend += `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1148
|
+
// symbol,
|
|
1149
|
+
// )}, ${get}${set});\n`;
|
|
1150
|
+
// this.usedHelpers.add('$parcel$export');
|
|
1151
|
+
append += `$${assetId}$exports[${JSON.stringify(symbol)}] = ${resolvedSymbol};\n`;
|
|
1150
1152
|
}
|
|
1151
1153
|
}
|
|
1152
1154
|
}
|
|
@@ -1184,7 +1186,7 @@ ${code}
|
|
|
1184
1186
|
// for the symbol so that when the value changes the object property also changes. This is
|
|
1185
1187
|
// required to simulate ESM live bindings. It's easier to do it this way rather than inserting
|
|
1186
1188
|
// additional assignments after each mutation of the original binding.
|
|
1187
|
-
|
|
1189
|
+
append += `\n${usedExports.map(exp => {
|
|
1188
1190
|
var _asset$symbols$get2;
|
|
1189
1191
|
let resolved = this.getSymbolResolution(asset, asset,
|
|
1190
1192
|
// @ts-expect-error TS2345
|
|
@@ -1192,12 +1194,16 @@ ${code}
|
|
|
1192
1194
|
let get = this.buildFunctionExpression([], resolved);
|
|
1193
1195
|
let isEsmExport = !!((_asset$symbols$get2 = asset.symbols.get(exp)) !== null && _asset$symbols$get2 !== void 0 && (_asset$symbols$get2 = _asset$symbols$get2.meta) !== null && _asset$symbols$get2 !== void 0 && _asset$symbols$get2.isEsm);
|
|
1194
1196
|
let set = !isEsmExport && asset.meta.hasCJSExports ? ', ' + this.buildFunctionExpression(['v'], `${resolved} = v`) : '';
|
|
1195
|
-
return `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1197
|
+
// return `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1198
|
+
// exp,
|
|
1199
|
+
// )}, ${get}${set});`;
|
|
1200
|
+
return `$${assetId}$exports[${JSON.stringify(exp)}] = ${resolved};\n`;
|
|
1196
1201
|
}).join('\n')}\n`;
|
|
1197
|
-
this.usedHelpers.add('$parcel$export');
|
|
1198
|
-
prependLineCount += 1 + usedExports.length;
|
|
1202
|
+
// this.usedHelpers.add('$parcel$export');
|
|
1203
|
+
// prependLineCount += 1 + usedExports.length;
|
|
1199
1204
|
}
|
|
1200
1205
|
}
|
|
1206
|
+
|
|
1201
1207
|
return [prepend, prependLineCount, append];
|
|
1202
1208
|
}
|
|
1203
1209
|
buildBundlePrelude() {
|
|
@@ -1245,7 +1251,7 @@ ${code}
|
|
|
1245
1251
|
// Conditional deps may be loaded before entrypoints on the server
|
|
1246
1252
|
this.hasConditionalDependency();
|
|
1247
1253
|
if (mightBeFirstJS) {
|
|
1248
|
-
let preludeCode = (
|
|
1254
|
+
let preludeCode = (0, _helpers.prelude)(this.parcelRequireName);
|
|
1249
1255
|
res += preludeCode;
|
|
1250
1256
|
if (enableSourceMaps) {
|
|
1251
1257
|
lines += (0, _utils().countLines)(preludeCode) - 1;
|
package/lib/helpers.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
6
|
+
exports.prelude = exports.helpers = exports.fnExpr = exports.bundleQueuePrelude = void 0;
|
|
7
|
+
const prelude = parcelRequireName => `
|
|
8
8
|
var $parcel$modules = {};
|
|
9
9
|
var $parcel$inits = {};
|
|
10
10
|
|
|
@@ -37,42 +37,7 @@ if (parcelRequire == null) {
|
|
|
37
37
|
|
|
38
38
|
var parcelRegister = parcelRequire.register;
|
|
39
39
|
`;
|
|
40
|
-
exports.
|
|
41
|
-
const preludeNew = parcelRequireName => `
|
|
42
|
-
var $parcel$modules = {};
|
|
43
|
-
var $parcel$inits = {};
|
|
44
|
-
|
|
45
|
-
var parcelRequire = $parcel$global[${JSON.stringify(parcelRequireName)}];
|
|
46
|
-
|
|
47
|
-
if (parcelRequire == null) {
|
|
48
|
-
parcelRequire = function(id) {
|
|
49
|
-
var mod = $parcel$modules[id];
|
|
50
|
-
if (mod !== undefined) {
|
|
51
|
-
return mod.exports;
|
|
52
|
-
}
|
|
53
|
-
var init = $parcel$inits[id];
|
|
54
|
-
if (init !== undefined) {
|
|
55
|
-
delete $parcel$inits[id];
|
|
56
|
-
var module = {id: id, exports: {}};
|
|
57
|
-
$parcel$modules[id] = module;
|
|
58
|
-
init.call(module.exports, module, module.exports);
|
|
59
|
-
return module.exports;
|
|
60
|
-
}
|
|
61
|
-
var err = new Error("Cannot find module '" + id + "'");
|
|
62
|
-
err.code = 'MODULE_NOT_FOUND';
|
|
63
|
-
throw err;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
parcelRequire.register = function register(id, init) {
|
|
67
|
-
$parcel$inits[id] = init;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
$parcel$global[${JSON.stringify(parcelRequireName)}] = parcelRequire;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
var parcelRegister = parcelRequire.register;
|
|
74
|
-
`;
|
|
75
|
-
exports.preludeNew = preludeNew;
|
|
40
|
+
exports.prelude = prelude;
|
|
76
41
|
const fnExpr = (env, params, body) => {
|
|
77
42
|
let block = `{ ${body.join(' ')} }`;
|
|
78
43
|
if (env.supports('arrow-functions')) {
|
package/lib/types/helpers.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Environment } from '@atlaspack/types';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const preludeNew: (parcelRequireName: string) => string;
|
|
2
|
+
export declare const prelude: (parcelRequireName: string) => string;
|
|
4
3
|
export declare const fnExpr: (env: Environment, params: Array<string>, body: Array<string>) => string;
|
|
5
4
|
export declare const bundleQueuePrelude: (env: Environment) => string;
|
|
6
5
|
export declare const helpers: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-js",
|
|
3
|
-
"version": "2.21.4-dev-
|
|
3
|
+
"version": "2.21.4-dev-export-func-removal-960dd335d.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"node": ">= 16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.14.4-dev-
|
|
20
|
-
"@atlaspack/feature-flags": "2.23.3-dev-
|
|
21
|
-
"@atlaspack/plugin": "2.14.28-dev-
|
|
22
|
-
"@atlaspack/rust": "3.6.3-dev-
|
|
23
|
-
"@atlaspack/types": "2.15.18-dev-
|
|
24
|
-
"@atlaspack/utils": "2.18.5-dev-
|
|
19
|
+
"@atlaspack/diagnostic": "2.14.4-dev-export-func-removal-960dd335d.0",
|
|
20
|
+
"@atlaspack/feature-flags": "2.23.3-dev-export-func-removal-960dd335d.0",
|
|
21
|
+
"@atlaspack/plugin": "2.14.28-dev-export-func-removal-960dd335d.0",
|
|
22
|
+
"@atlaspack/rust": "3.6.3-dev-export-func-removal-960dd335d.0",
|
|
23
|
+
"@atlaspack/types": "2.15.18-dev-export-func-removal-960dd335d.0",
|
|
24
|
+
"@atlaspack/utils": "2.18.5-dev-export-func-removal-960dd335d.0",
|
|
25
25
|
"@parcel/source-map": "^2.1.1",
|
|
26
26
|
"globals": "^13.2.0",
|
|
27
27
|
"nullthrows": "^1.1.1",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
33
33
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "960dd335d08a04220a07b36f4bb83cd7e130903e"
|
|
36
36
|
}
|
|
@@ -29,13 +29,7 @@ import {outdent} from 'outdent';
|
|
|
29
29
|
import {ESMOutputFormat} from './ESMOutputFormat';
|
|
30
30
|
import {CJSOutputFormat} from './CJSOutputFormat';
|
|
31
31
|
import {GlobalOutputFormat} from './GlobalOutputFormat';
|
|
32
|
-
import {
|
|
33
|
-
preludeOld,
|
|
34
|
-
preludeNew,
|
|
35
|
-
helpers,
|
|
36
|
-
bundleQueuePrelude,
|
|
37
|
-
fnExpr,
|
|
38
|
-
} from './helpers';
|
|
32
|
+
import {prelude, helpers, bundleQueuePrelude, fnExpr} from './helpers';
|
|
39
33
|
import {
|
|
40
34
|
replaceScriptDependencies,
|
|
41
35
|
getSpecifier,
|
|
@@ -1549,11 +1543,13 @@ ${code}
|
|
|
1549
1543
|
? ', ' +
|
|
1550
1544
|
this.buildFunctionExpression(['v'], `${resolvedSymbol} = v`)
|
|
1551
1545
|
: '';
|
|
1552
|
-
prepend += `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1546
|
+
// prepend += `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1547
|
+
// symbol,
|
|
1548
|
+
// )}, ${get}${set});\n`;
|
|
1549
|
+
// this.usedHelpers.add('$parcel$export');
|
|
1550
|
+
append += `$${assetId}$exports[${JSON.stringify(
|
|
1553
1551
|
symbol,
|
|
1554
|
-
)}
|
|
1555
|
-
this.usedHelpers.add('$parcel$export');
|
|
1556
|
-
prependLineCount++;
|
|
1552
|
+
)}] = ${resolvedSymbol};\n`;
|
|
1557
1553
|
}
|
|
1558
1554
|
}
|
|
1559
1555
|
}
|
|
@@ -1593,7 +1589,7 @@ ${code}
|
|
|
1593
1589
|
// for the symbol so that when the value changes the object property also changes. This is
|
|
1594
1590
|
// required to simulate ESM live bindings. It's easier to do it this way rather than inserting
|
|
1595
1591
|
// additional assignments after each mutation of the original binding.
|
|
1596
|
-
|
|
1592
|
+
append += `\n${usedExports
|
|
1597
1593
|
.map((exp) => {
|
|
1598
1594
|
let resolved = this.getSymbolResolution(
|
|
1599
1595
|
asset,
|
|
@@ -1609,13 +1605,16 @@ ${code}
|
|
|
1609
1605
|
!isEsmExport && asset.meta.hasCJSExports
|
|
1610
1606
|
? ', ' + this.buildFunctionExpression(['v'], `${resolved} = v`)
|
|
1611
1607
|
: '';
|
|
1612
|
-
return `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1608
|
+
// return `$parcel$export($${assetId}$exports, ${JSON.stringify(
|
|
1609
|
+
// exp,
|
|
1610
|
+
// )}, ${get}${set});`;
|
|
1611
|
+
return `$${assetId}$exports[${JSON.stringify(
|
|
1613
1612
|
exp,
|
|
1614
|
-
)}
|
|
1613
|
+
)}] = ${resolved};\n`;
|
|
1615
1614
|
})
|
|
1616
1615
|
.join('\n')}\n`;
|
|
1617
|
-
this.usedHelpers.add('$parcel$export');
|
|
1618
|
-
prependLineCount += 1 + usedExports.length;
|
|
1616
|
+
// this.usedHelpers.add('$parcel$export');
|
|
1617
|
+
// prependLineCount += 1 + usedExports.length;
|
|
1619
1618
|
}
|
|
1620
1619
|
}
|
|
1621
1620
|
|
|
@@ -1683,9 +1682,7 @@ ${code}
|
|
|
1683
1682
|
this.hasConditionalDependency();
|
|
1684
1683
|
|
|
1685
1684
|
if (mightBeFirstJS) {
|
|
1686
|
-
let preludeCode = (
|
|
1687
|
-
getFeatureFlag('useNewPrelude') ? preludeNew : preludeOld
|
|
1688
|
-
)(this.parcelRequireName);
|
|
1685
|
+
let preludeCode = prelude(this.parcelRequireName);
|
|
1689
1686
|
res += preludeCode;
|
|
1690
1687
|
if (enableSourceMaps) {
|
|
1691
1688
|
lines += countLines(preludeCode) - 1;
|
package/src/helpers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {Environment} from '@atlaspack/types';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const prelude = (parcelRequireName: string): string => `
|
|
4
4
|
var $parcel$modules = {};
|
|
5
5
|
var $parcel$inits = {};
|
|
6
6
|
|
|
@@ -34,41 +34,6 @@ if (parcelRequire == null) {
|
|
|
34
34
|
var parcelRegister = parcelRequire.register;
|
|
35
35
|
`;
|
|
36
36
|
|
|
37
|
-
export const preludeNew = (parcelRequireName: string): string => `
|
|
38
|
-
var $parcel$modules = {};
|
|
39
|
-
var $parcel$inits = {};
|
|
40
|
-
|
|
41
|
-
var parcelRequire = $parcel$global[${JSON.stringify(parcelRequireName)}];
|
|
42
|
-
|
|
43
|
-
if (parcelRequire == null) {
|
|
44
|
-
parcelRequire = function(id) {
|
|
45
|
-
var mod = $parcel$modules[id];
|
|
46
|
-
if (mod !== undefined) {
|
|
47
|
-
return mod.exports;
|
|
48
|
-
}
|
|
49
|
-
var init = $parcel$inits[id];
|
|
50
|
-
if (init !== undefined) {
|
|
51
|
-
delete $parcel$inits[id];
|
|
52
|
-
var module = {id: id, exports: {}};
|
|
53
|
-
$parcel$modules[id] = module;
|
|
54
|
-
init.call(module.exports, module, module.exports);
|
|
55
|
-
return module.exports;
|
|
56
|
-
}
|
|
57
|
-
var err = new Error("Cannot find module '" + id + "'");
|
|
58
|
-
err.code = 'MODULE_NOT_FOUND';
|
|
59
|
-
throw err;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
parcelRequire.register = function register(id, init) {
|
|
63
|
-
$parcel$inits[id] = init;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
$parcel$global[${JSON.stringify(parcelRequireName)}] = parcelRequire;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var parcelRegister = parcelRequire.register;
|
|
70
|
-
`;
|
|
71
|
-
|
|
72
37
|
export const fnExpr = (
|
|
73
38
|
env: Environment,
|
|
74
39
|
params: Array<string>,
|