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
Now encountering the following error when importing @uiw/react-codemirror and using scope hoisting.
ReferenceError: $74eb372235a18b7a$exports is not defined
<anonymous> editor.tsx:5
React 7
q scheduler.production.min.js:13
X scheduler.production.min.js:14
EventHandlerNonNull* scheduler.production.min.js:14
g index.70a7763b.js:1
<anonymous> index.js:4
g index.70a7763b.js:1
<anonymous> index.70a7763b.js:1
g index.70a7763b.js:1
<anonymous> React
With code like:
import{useCodeMirror}from"@uiw/react-codemirror"exportdefaultfunctionEditor(){consttest=useCodeMirror({})// $exports is not defined when scope-hoisted}
Encountered through CLI tool (plasmo), which just invokes Parcel with some plugins specific to browser extensions (here shouldScopeHoist is set to true).
Scope-hoisting shouldn't remove code used at runtime.
😯 Current Behavior
Scope-hoisting is removing code which is used at runtime.
💁 Possible Solution
It appears that using a console.log (or presumably any function referencing the imported library?) like the following prevents the code from being pruned:
import*ascmfrom'@uiw/react-codemirror'// and then later ...console.log(cm)// this line is required (or some other reference to cm)consttest=cm.useCodeMirror({})// strangely, this works
tbrockman
changed the title
Regression in scope-hoisting (between 2.9.3->2.12.0 and nightly), TypeError: (0 , $7DSBz.useCodeMirror) is not a function
Regression in scope-hoisting (between 2.9.3->2.12.0, includes nightly), $74eb372235a18b7a$exports is not defined
Oct 6, 2024
Updated the report with a link to a repo for reproducing the issue, and changed the bug description to reflect how the issue appears in that repo (rather than how the issue appears when using plasmo, which invokes parcel programmatically).
@mischnic encountered this when moving to nightly after the previous issue I had which ya helped me with (and confirmed it exists in 2.12.0 as well). Not sure if there's anything I can do to help fix this here or if this is something that's already on someones roadmap, but I'm open to looking into it depending on how long it might take a new contributor to work on it.
While I found a workaround for my use case by adding code to prevent it from being undefined after scope-hoisting, this was apart of a greater issue of upgrading plasmo to a newer version of parcel, which is blocked if it seems like it'll potentially lead to some subset of people having unexpected runtime errors.
🐛 bug report
Now encountering the following error when importing
@uiw/react-codemirror
and using scope hoisting.With code like:
Without being at all familiar with scope hoisting in Parcel, I would guess it might encounter an issue with
@uiw/react-codemirror
s simultaneous use ofexport *
andexport default
. Previously this did not cause any issue at runtime (for example https://github.com/tbrockman/browser-extension-for-opentelemetry currently builds and works fine using a version ofplasmo
which leverages[email protected]
).🎛 Configuration (.babelrc, package.json, cli command)
Encountered through CLI tool (
plasmo
), which just invokes Parcel with some plugins specific to browser extensions (hereshouldScopeHoist
is set to true).See https://github.com/tbrockman/parcel-scope-hoist-repro for reproducing the bug directly using
parcel
.🤔 Expected Behavior
Scope-hoisting shouldn't remove code used at runtime.
😯 Current Behavior
Scope-hoisting is removing code which is used at runtime.
💁 Possible Solution
It appears that using a
console.log
(or presumably any function referencing the imported library?) like the following prevents the code from being pruned:🔦 Context
💻 Code Sample
Repository for minimal reproduction of issue: https://github.com/tbrockman/parcel-scope-hoist-repro
🌍 Your Environment
The text was updated successfully, but these errors were encountered: