Closed wulucxy closed 5 years ago
Could you please provide a reproduction code sample? This is very likely related to https://www.npmjs.com/package/babel-plugin-import
Just had this happen to me. It happens with a very very minimal "app.js" as follows with
node_modules/.bin/parcel build --out-dir ../static --experimental-scope-hoisting app.js
import Vue from "vue";
import BootstrapVue from 'bootstrap-vue';
Vue.use(BootstrapVue);
(needs "bootstrap-vue": "^2.0.4", "vue": "^2.6.10")
Same issue here. No Solution for this?
Seems like if I have import _ from "lodash";
parcel will generate a line var Buffer = require("buffer").Buffer;
without adding require
Same issue here. No Solution for this?
At least a workaround. In my html file, I do
<script type="text/javascript">
window.require = function(e) { console.debug("require hack still
required //", e); return undefined; };
before loading any compiled JS, that at least allows things to proceed.
Cheers!
Same issue here. No Solution for this? At least a workaround. In my html file, I do before loading any compiled JS, that at least allows things to proceed. Cheers!
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
same issue here: $NYPs$var$arrayBufferTag is not defined
same issue here:
$NYPs$var$arrayBufferTag is not defined
Remove all use of .clone relater functions with spread operator. I had to get rid of .omit
Unfortunately I'm not even using lodash, and I can't figure out what's causing the error.
🐛 bug report
when I enable
experimental-scope-hoisting
,the result will throw error:ReferenceError: require is not defined
🎛 Configuration (.babelrc, package.json, cli command)
🤔 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