You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stumbled upon corrupted logic after transpiling using Parcel, ONLY on parcel build but not parcel watch when using object property value shorthand syntax
When I tried enabling Babel transpiling, both parcel build and parcel watch will work perfectly!
The script generated by parcel watch will work perfectly but not with script generated by parcel build where the transpiling corrupted the logic Comparison:
Generated by parcel watch
"use strict";varcjsA=require("./cjsA.js");varcjsB=require("./cjsB.js");// Didn't corrupt the logicvarregistry={cjsA: cjsA,cjsB: cjsB};vargetEntry=function(type){varentries=registry[type].entries;// Will return entries as expected when calling getEntry('cjsA')return{entries: entries,metadata: "value"};};exports=module.exports={getEntry: getEntry};
Generated by parcel build
var$a9U6j=parcelRequire("a9U6j");var$3PdFn=parcelRequire("3PdFn");// Corrupted the logic,constregistry={
$a9U6j,
$3PdFn
};constgetEntry=(type)=>{const{ entries }=registry[type];// Will return undefined when calling getEntry('cjsA')return{
entries,metadata: "value"};};exports=module.exports={
getEntry
};
If this is caused by expected behaviour of Parcel's scope hoisting, atleast making sure it's also error when using parcel watch will make it less frustrating, to avoid the bug only reproducible in production but not during development
🌍 Your Environment
Software
Version(s)
Parcel
2.4.1
Node
14.18.2
npm
v8.5.4
Operating System
Windows 10
The text was updated successfully, but these errors were encountered:
🐛 bug report
Stumbled upon corrupted logic after transpiling using Parcel, ONLY on
parcel build
but notparcel watch
when using object property value shorthand syntaxWhen I tried enabling Babel transpiling, both
parcel build
andparcel watch
will work perfectly!🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Not have corrupted logic on
parcel build
, produce consistent logic betweenparcel build
andparcel watch
💻 Code Sample
Reproduceable environment: https://github.com/nadhifikbarw/parcel-bug
The main code is pretty simple, written in CJS.
common/cjsA.js
common/cjsB.js
common/index.js
These code being used in browser bundling, simply like:
src\app\script.js
The script generated by
parcel watch
will work perfectly but not with script generated byparcel build
where the transpiling corrupted the logic Comparison:Generated by parcel watch
Generated by parcel build
If this is caused by expected behaviour of Parcel's scope hoisting, atleast making sure it's also error when using
parcel watch
will make it less frustrating, to avoid the bug only reproducible in production but not during development🌍 Your Environment
The text was updated successfully, but these errors were encountered: