Skip to content
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

[TreeShake] Reference error $<NUMBER>$exports is not defined if "--experimental-scope-hoisting" flag is used #1552

Closed
sujith97 opened this issue Jun 16, 2018 · 8 comments

Comments

@sujith97
Copy link

sujith97 commented Jun 16, 2018

🐛 bug report

Browser complains about the undefined variable $<NUMBER>$exports which looks like the bundled output here.

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

{
  "presets": [
    "env",
    "react"
  ],
  "plugins": [
    "babel-plugin-styled-components",
    "react-hot-loader/babel",
    "transform-class-properties",
    "transform-object-rest-spread"
  ]
}

🤔 Expected Behavior

It should build and have no issues as when I use parcel build without the tree shaking flag.

😯 Current Behavior

Builds fine but browser complains:
Uncaught ReferenceError: $37$exports is not defined

💁 Possible Solution

Needs research.

🔦 Context

Just the usual parcel production build:

parcel build --experimental-scope-hoisting client/scripts/index.js --public-url /

💻 Code Sample

N/A

🌍 Your Environment

Software Version(s)
Parcel "parcel-bundler": "^1.9.0"
Node v10.1.0
npm/Yarn v5.6.0
Operating System Mac OS v10.13.5
@sujith97 sujith97 changed the title [TreeShake] Reference error $<NUMBER>$exports is not defined for "--experimental-scope-hoisting" [TreeShake] Reference error $<NUMBER>$exports is not defined if "--experimental-scope-hoisting" flag is used Jun 16, 2018
@fathyb
Copy link
Contributor

fathyb commented Jun 16, 2018

Thanks! Could you give us the full output or the file responsible for the bug? You can use --no-minify to get a non-minified output with filenames.

@sujith97
Copy link
Author

You may convert it back to js.
index.js

@HenrikJoreteg
Copy link

If you need a full app you can run that appears to have the same issue see here: HenrikJoreteg/redux-bundler-example#1

@sujith97
Copy link
Author

@fathyb @devongovett Any update on this?

@HenrikJoreteg
Copy link

I'd love to get this sorted out as well so I can turn on this awesomeness in my app :)

@fathyb
Copy link
Contributor

fathyb commented Jul 8, 2018

@HenrikJoreteg your issue is different, #1683 fixes it
@sujith97 could you provide a reproduction?

@mischnic
Copy link
Member

mischnic commented Jan 6, 2019

@sujith97 Could you please provide some source code?

@devongovett
Copy link
Member

Closing. I tested using @HenrikJoreteg's app, and it appears to be working.

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

No branches or pull requests

5 participants