@parcel/packager-js 2.0.0-dev.1528 → 2.0.0-dev.1548

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.
@@ -271,6 +271,7 @@ class ScopeHoistingPackager {
271
271
  // TODO: handle ESM exports of wrapped entry assets...
272
272
  let entry = this.bundle.getMainEntry();
273
273
  if (entry && !this.wrappedAssets.has(entry.id)) {
274
+ let hasNamespace = entry.symbols.hasExportSymbol('*');
274
275
  for (let {
275
276
  asset,
276
277
  exportAs,
@@ -279,6 +280,12 @@ class ScopeHoistingPackager {
279
280
  } of this.bundleGraph.getExportedSymbols(entry)) {
280
281
  if (typeof symbol === 'string') {
281
282
  var _this$exportedSymbols, _entry$symbols$get2;
283
+ // If the module has a namespace (e.g. commonjs), and this is not an entry, only export the namespace
284
+ // as default, without individual exports. This mirrors the importing logic in addExternal, avoiding
285
+ // extra unused exports and potential for non-identifier export names.
286
+ if (hasNamespace && this.isAsyncBundle && exportAs !== '*') {
287
+ continue;
288
+ }
282
289
  let symbols = (_this$exportedSymbols = this.exportedSymbols.get(symbol === '*' ? (0, _nullthrows().default)((_entry$symbols$get2 = entry.symbols.get('*')) === null || _entry$symbols$get2 === void 0 ? void 0 : _entry$symbols$get2.local) : symbol)) === null || _this$exportedSymbols === void 0 ? void 0 : _this$exportedSymbols.exportAs;
283
290
  if (!symbols) {
284
291
  symbols = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/packager-js",
3
- "version": "2.0.0-dev.1528+70889ca07",
3
+ "version": "2.0.0-dev.1548+79b158883",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,17 +17,17 @@
17
17
  "source": "src/index.js",
18
18
  "engines": {
19
19
  "node": ">= 12.0.0",
20
- "parcel": "^2.0.0-dev.1526+70889ca07"
20
+ "parcel": "^2.0.0-dev.1546+79b158883"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/diagnostic": "2.0.0-dev.1528+70889ca07",
24
- "@parcel/plugin": "2.0.0-dev.1528+70889ca07",
25
- "@parcel/rust": "2.12.1-dev.3151+70889ca07",
23
+ "@parcel/diagnostic": "2.0.0-dev.1548+79b158883",
24
+ "@parcel/plugin": "2.0.0-dev.1548+79b158883",
25
+ "@parcel/rust": "2.12.1-dev.3171+79b158883",
26
26
  "@parcel/source-map": "^2.1.1",
27
- "@parcel/types": "2.0.0-dev.1528+70889ca07",
28
- "@parcel/utils": "2.0.0-dev.1528+70889ca07",
27
+ "@parcel/types": "2.0.0-dev.1548+79b158883",
28
+ "@parcel/utils": "2.0.0-dev.1548+79b158883",
29
29
  "globals": "^13.2.0",
30
30
  "nullthrows": "^1.1.1"
31
31
  },
32
- "gitHead": "70889ca07dccb95e21e4c6a2844d632e3723faf4"
32
+ "gitHead": "79b158883170daac9cd17bdecfebff163bc99e52"
33
33
  }
@@ -354,6 +354,8 @@ export class ScopeHoistingPackager {
354
354
  // TODO: handle ESM exports of wrapped entry assets...
355
355
  let entry = this.bundle.getMainEntry();
356
356
  if (entry && !this.wrappedAssets.has(entry.id)) {
357
+ let hasNamespace = entry.symbols.hasExportSymbol('*');
358
+
357
359
  for (let {
358
360
  asset,
359
361
  exportAs,
@@ -361,6 +363,13 @@ export class ScopeHoistingPackager {
361
363
  exportSymbol,
362
364
  } of this.bundleGraph.getExportedSymbols(entry)) {
363
365
  if (typeof symbol === 'string') {
366
+ // If the module has a namespace (e.g. commonjs), and this is not an entry, only export the namespace
367
+ // as default, without individual exports. This mirrors the importing logic in addExternal, avoiding
368
+ // extra unused exports and potential for non-identifier export names.
369
+ if (hasNamespace && this.isAsyncBundle && exportAs !== '*') {
370
+ continue;
371
+ }
372
+
364
373
  let symbols = this.exportedSymbols.get(
365
374
  symbol === '*' ? nullthrows(entry.symbols.get('*')?.local) : symbol,
366
375
  )?.exportAs;