馃悰 bug report
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"
export default function Editor() {
const test = useCodeMirror({}) // $exports is not defined when scope-hoisted
}
Without being at all familiar with scope hoisting in Parcel, I would guess it might encounter an issue with @uiw/react-codemirrors simultaneous use of export * and export 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 of plasmo which leverages parcel@2.9.3).
馃帥 Configuration (.babelrc, package.json, cli command)
Encountered through CLI tool (plasmo), which just invokes Parcel with some plugins specific to browser extensions (here shouldScopeHoist 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:
import * as cm from '@uiw/react-codemirror'
// and then later ...
console.log(cm) // this line is required (or some other reference to cm)
const test = cm.useCodeMirror({}) // strangely, this works
馃敠 Context
馃捇 Code Sample
Repository for minimal reproduction of issue: https://github.com/tbrockman/parcel-scope-hoist-repro
馃實 Your Environment
| Software |
Version(s) |
| Parcel |
|
| Node |
|
| npm/Yarn |
|
| Operating System |
|
馃悰 bug report
Now encountering the following error when importing
@uiw/react-codemirrorand 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-codemirrors 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 ofplasmowhich leveragesparcel@2.9.3).馃帥 Configuration (.babelrc, package.json, cli command)
Encountered through CLI tool (
plasmo), which just invokes Parcel with some plugins specific to browser extensions (hereshouldScopeHoistis 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