Skip to content

Named default export missing from bundle when using bundler-library #10108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chuckdries opened this issue Mar 12, 2025 · 2 comments
Open

Named default export missing from bundle when using bundler-library #10108

chuckdries opened this issue Mar 12, 2025 · 2 comments

Comments

@chuckdries
Copy link

I believe this is not a duplicate of #7622

🐛 bug report

In a project which uses @parcel/bundler-library, any statements that assign names to default exports (e.g. in a barrel file) such as export { default as some_name } from "./some_file", are missing from the bundle output.

🎛 Configuration (.babelrc, package.json, cli command)

//.parcelrc
{
  "extends": "@parcel/config-default",
  "bundler": "@parcel/bundler-library"
}
{
  "name": "parcel-export-default-as-bug",
  "version": "1.0.0",
  "description": "",
  "source": "src/index.ts",
  "module": "dist/index.mjs",
  "scripts": {
    "build": "parcel build"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@parcel/bundler-library": "^2.13.3",
    "parcel": "^2.13.3"
  }
}
// src/__localization__/index.js
export { default as en_us } from "./en_us.json";

🤔 Expected Behavior

Exported symbols should be exported in the bundle

😯 Current Behavior

Exported symbols are missing from the bundle. This is the entire file that is written to dist in the sample repo (linked below)

// dist/__localization__.hash.js
import $7squd$en_usaf30262bjs from "./en_us.af30262b.js";


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}



//# sourceMappingURL=__localization__.d99090b7.js.map

🔦 Context

We have an automated localization system which writes strings to JSON files, and writes a barrel file that looks like

export {default as en_us} from "./en_us.json"

We need these exports to make it into our final bundle.

I've found the following workaround does work

import en_us_json from "./en_us.json"
export const en_us = en_us_json

The issue is our localization infra generates and commits this file in CI, and we don't own that infra, so actually applying this workaround is basically impossible short of a prebuild script that uses sed or something.

💻 Code Sample

This repo is a minimal reproduction of the issue https://github.com/chuckdries/parcel-export-default-as-bug/

🌍 Your Environment

Software Version(s)
Parcel 2.13.3
Node 20.9.0
npm/Yarn npm
Operating System macos
@devongovett
Copy link
Member

devongovett commented Mar 15, 2025

What about this?

export * as en_us from './en_us.json'

Might be a default interop issue since JSON is not ESM.

@chuckdries
Copy link
Author

export * as en_us from './en_us.json' does appear to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants