parcel: $78fb23f46eb09f80$exports is not defined

We run into this problem after we added chartjs-plugin-datalabels to our project. When serving the result from parcel build we get the runtime error:

    Uncaught ReferenceError: $78fb23f46eb09f80$exports is not defined
    <anonymous> http://0.0.0.0:8000/index.059a8e3e.js:25

Disabling scope hoisting (--no-scope-hoist) makes it work. Parcel 2.7 works, 2.8.0 does not.

Removing the following line from package.json in chartjs-plugin-datalabels also makes it work:

"module": "dist/chartjs-plugin-datalabels.esm.js",

not sure if it’s relevant.

A minimal example for reproducing the error: https://ommej.se/files/tmp/parcel-6711.tar.gz. Steps to reproduce: $ npm install $ npm run build $ cd dist $ python3 -m http.server (or some other way to serve the files) visit the page in a browser, for example localhost:8000, the console will show the exception

_Originally posted by @lanker in https://github.com/parcel-bundler/parcel/issues/6711#issuecomment-1403472548_

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks, I already have a minimal reproduction for now:

// index.js
import { merge } from "../library/a.js";
console.log(merge);

// library/package.json
{ "sideEffects": ["a.js"] }

// library/a.js
export * from './b.js';

// library/b.js
export { merge0 as merge } from "./c.js";

// library/c.js
export function merge0() {return 2;}

output:

function $5847f4e170f13e39$export$78b9c0f15a94309a() {
    return 2;
}
console.log((0, $a33e92888f64d1df$exports.merge));

For reference, I’m having a similar issue when trying to import the ‘yaml’ package, because apparently its main index.js contains such export all/rename export instructions. My workaround for now has been to add an alias that directly points to the module where the definitions are located, "alias": { "yaml": "node_modules/yaml/browser/dist/index.js", ...}

Thanks @phfaist your hotfix works - see example error repository

"alias": { "d3": "d3/dist/d3.js"}

For reference, I’m having a similar issue when trying to import the ‘yaml’ package, because apparently its main index.js contains such export all/rename export instructions. My workaround for now has been to add an alias that directly points to the module where the definitions are located, "alias": { "yaml": "node_modules/yaml/browser/dist/index.js", ...}

Yes, it’s caused by having both a export * and then a renaming export {x as y} (as in my example)

I workaround by just doing console.log(d3) after the import (I wanted to check what was being inported, and… ¯\ (ツ) /¯ )

Have same issue as @tnarik with D3 and Parcel 2.8.3 version

import * as d3 from 'd3';

seems to be missing in the bundle and generates 87f3b181d7e461d2$exports is not defined error