experimental-scope-hoisting throw error: ReferenceError: require is not defined
See original GitHub issue🐛 bug report
when I enable experimental-scope-hoisting
,the result will throw error:
ReferenceError: require is not defined
🎛 Configuration (.babelrc, package.json, cli command)
// .babelrc
{
"presets": [
["@babel/env"],
"@babel/typescript",
["@babel/react"]
],
"plugins": [
["@babel/transform-runtime", {
"corejs": 2
}],
"@babel/syntax-dynamic-import",
["@babel/proposal-decorators", {"legacy": true}],
["@babel/proposal-class-properties"],
["import", { "libraryName": "antd", "style": true, "libraryDirectory": "es" }]
],
"env": {
"development": {
plugins: ["react-hot-loader/babel"]
}
},
"sourceMaps": true,
"retainLines": true
}
// package.json
build": "parcel build src/public/index.html --no-source-maps --experimental-scope-hoisting --no-minify",
🤔 Expected Behavior
enable --experimental-scope-hoisting
should not throw error。
😯 Current Behavior
enable --experimental-scope-hoisting
throw error: ReferenceError: require is not defined
💁 Possible Solution
🔦 Context
💻 Code Sample
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 1.12.3 |
Node | 10.14.1 |
npm/Yarn | 6.4.1 |
Operating System | macOS |
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How To Fix ReferenceError require is not defined in JavaScript
In this case, check your package.json file for an property called type . If that is set to module , ES6 modules will...
Read more >require is not defined in ES module scope, you can use import ...
The error output is : Requiring external module babel-register ReferenceError: require is not defined in ES module ...
Read more >Scope hoisting - Parcel
In production builds, Parcel concatenates modules into a single scope. This is called "scope hoisting". Parcel also statically analyzes the imports and ...
Read more >babel require is not defined | The AI Search Engine You Control
bug report. when I enable experimental-scope-hoisting ,the result will throw error: ReferenceError: require is not defined.
Read more >rollup.js
import the entire utils object with CommonJS const utils = require('. ... This will not throw an error if one of the entry...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unfortunately I’m not even using lodash, and I can’t figure out what’s causing the error.
Nice evil walk around. I turned to lodash-es to fix this issue but brings me to a next issue… Seems like
_.clone
will cause errors with tree shaking.$xxx$var$arrayBufferTag is undefined
Orz