@atlaspack/packager-js 2.14.5-canary.186 → 2.14.5-canary.189

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.
@@ -1225,18 +1225,24 @@ ${code}
1225
1225
  // for the symbol so that when the value changes the object property also changes. This is
1226
1226
  // required to simulate ESM live bindings. It's easier to do it this way rather than inserting
1227
1227
  // additional assignments after each mutation of the original binding.
1228
- prepend += `\n${usedExports.map(exp => {
1228
+ for (let exp of usedExports) {
1229
1229
  var _asset$symbols$get2;
1230
1230
  let resolved = this.getSymbolResolution(asset, asset,
1231
1231
  // @ts-expect-error TS2345
1232
1232
  exp, undefined, replacements);
1233
- let get = this.buildFunctionExpression([], resolved);
1234
- 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);
1235
- let set = !isEsmExport && asset.meta.hasCJSExports ? ', ' + this.buildFunctionExpression(['v'], `${resolved} = v`) : '';
1236
- return `$parcel$export($${assetId}$exports, ${JSON.stringify(exp)}, ${get}${set});`;
1237
- }).join('\n')}\n`;
1238
- this.usedHelpers.add('$parcel$export');
1239
- prependLineCount += 1 + usedExports.length;
1233
+ const meta = (_asset$symbols$get2 = asset.symbols.get(exp)) === null || _asset$symbols$get2 === void 0 ? void 0 : _asset$symbols$get2.meta;
1234
+ if ((0, _featureFlags().getFeatureFlag)('exportsRebindingOptimisation') && meta !== null && meta !== void 0 && meta.isStaticBindingSafe) {
1235
+ append += `$${assetId}$exports[${JSON.stringify(exp)}] = ${resolved};\n`;
1236
+ } else {
1237
+ var _asset$symbols$get3;
1238
+ let get = this.buildFunctionExpression([], resolved);
1239
+ let isEsmExport = !!((_asset$symbols$get3 = asset.symbols.get(exp)) !== null && _asset$symbols$get3 !== void 0 && (_asset$symbols$get3 = _asset$symbols$get3.meta) !== null && _asset$symbols$get3 !== void 0 && _asset$symbols$get3.isEsm);
1240
+ let set = !isEsmExport && asset.meta.hasCJSExports ? ', ' + this.buildFunctionExpression(['v'], `${resolved} = v`) : '';
1241
+ prepend += `$parcel$export($${assetId}$exports, ${JSON.stringify(exp)}, ${get}${set});\n`;
1242
+ this.usedHelpers.add('$parcel$export');
1243
+ prependLineCount += 1 + usedExports.length;
1244
+ }
1245
+ }
1240
1246
  }
1241
1247
  }
1242
1248
  return [prepend, prependLineCount, append];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-js",
3
- "version": "2.14.5-canary.186+f6532d7a4",
3
+ "version": "2.14.5-canary.189+0684997c1",
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.1-canary.254+f6532d7a4",
20
- "@atlaspack/feature-flags": "2.14.1-canary.254+f6532d7a4",
21
- "@atlaspack/plugin": "2.14.5-canary.186+f6532d7a4",
22
- "@atlaspack/rust": "3.2.1-canary.186+f6532d7a4",
23
- "@atlaspack/types": "2.14.5-canary.186+f6532d7a4",
24
- "@atlaspack/utils": "2.14.5-canary.186+f6532d7a4",
19
+ "@atlaspack/diagnostic": "2.14.1-canary.257+0684997c1",
20
+ "@atlaspack/feature-flags": "2.14.1-canary.257+0684997c1",
21
+ "@atlaspack/plugin": "2.14.5-canary.189+0684997c1",
22
+ "@atlaspack/rust": "3.2.1-canary.189+0684997c1",
23
+ "@atlaspack/types": "2.14.5-canary.189+0684997c1",
24
+ "@atlaspack/utils": "2.14.5-canary.189+0684997c1",
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": "f6532d7a4f7f007bd4e5e36af04dd466f0b9f572"
35
+ "gitHead": "0684997c127a6204af1376b36e556fddd1ba5557"
36
36
  }
@@ -1648,29 +1648,37 @@ ${code}
1648
1648
  // for the symbol so that when the value changes the object property also changes. This is
1649
1649
  // required to simulate ESM live bindings. It's easier to do it this way rather than inserting
1650
1650
  // additional assignments after each mutation of the original binding.
1651
- prepend += `\n${usedExports
1652
- .map((exp) => {
1653
- let resolved = this.getSymbolResolution(
1654
- asset,
1655
- asset,
1656
- // @ts-expect-error TS2345
1651
+ for (let exp of usedExports) {
1652
+ let resolved = this.getSymbolResolution(
1653
+ asset,
1654
+ asset,
1655
+ // @ts-expect-error TS2345
1656
+ exp,
1657
+ undefined,
1658
+ replacements,
1659
+ );
1660
+ const meta = asset.symbols.get(exp)?.meta;
1661
+ if (
1662
+ getFeatureFlag('exportsRebindingOptimisation') &&
1663
+ meta?.isStaticBindingSafe
1664
+ ) {
1665
+ append += `$${assetId}$exports[${JSON.stringify(
1657
1666
  exp,
1658
- undefined,
1659
- replacements,
1660
- );
1667
+ )}] = ${resolved};\n`;
1668
+ } else {
1661
1669
  let get = this.buildFunctionExpression([], resolved);
1662
1670
  let isEsmExport = !!asset.symbols.get(exp)?.meta?.isEsm;
1663
1671
  let set =
1664
1672
  !isEsmExport && asset.meta.hasCJSExports
1665
1673
  ? ', ' + this.buildFunctionExpression(['v'], `${resolved} = v`)
1666
1674
  : '';
1667
- return `$parcel$export($${assetId}$exports, ${JSON.stringify(
1675
+ prepend += `$parcel$export($${assetId}$exports, ${JSON.stringify(
1668
1676
  exp,
1669
- )}, ${get}${set});`;
1670
- })
1671
- .join('\n')}\n`;
1672
- this.usedHelpers.add('$parcel$export');
1673
- prependLineCount += 1 + usedExports.length;
1677
+ )}, ${get}${set});\n`;
1678
+ this.usedHelpers.add('$parcel$export');
1679
+ prependLineCount += 1 + usedExports.length;
1680
+ }
1681
+ }
1674
1682
  }
1675
1683
  }
1676
1684