Closed mischnic closed 3 years ago
Looks like swc is trying to throw the error "pragma and pragmaFrag cannot be set when runtime is automatic" (and MDX does emit those as comments)
(So there are two problems: panic instead of the error message itself, and the actual pragma error)
Hmm so should we disable the automatic runtime if @jsxFrag
is somewhere in the source code?
swc might be happy if mdx emits /** @jsxRuntime classic */
(at least the Babel plugin supports that: https://babeljs.io/docs/en/babel-plugin-transform-react-jsx)
Error still happening for me on ^2.0.0-nightly.811
, even tho i don't import any MDX files?
> parcel --no-hmr src/index.html src/sandbox/index.html
Server running at http://localhost:1234
β Building index.tsx...
thread '<unnamed>' panicked at 'cannot access a scoped thread local variable without calling `set` first', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-1.0.0\src\lib.rs:168:9
Server running at http://localhost:1234
Γ Build failed.
@parcel/transformer-js: cannot access a scoped thread local
variable without calling `set` first
Error: cannot access a scoped thread local variable without
calling `set` first
at Object.transform
(C:\dev\oz\web\node_modules\@parcel\transformer-js\lib\JSTransformer.js:355:31)
at processTicksAndRejections
(node:internal/process/task_queues:96:5)
at async Transformation.runTransformer
(C:\dev\oz\web\node_modules\@parcel\core\lib\Transformation.js:604:5)
at async Transformation.runPipeline
(C:\dev\oz\web\node_modules\@parcel\core\lib\Transformation.js:357:36)
at async Transformation.runPipelines
(C:\dev\oz\web\node_modules\@parcel\core\lib\Transformation.js:241:40)
at async Transformation.run
(C:\dev\oz\web\node_modules\@parcel\core\lib\Transformation.js:167:19)
at async Child.handleRequest
(C:\dev\oz\web\node_modules\@parcel\workers\lib\child.js:217:9)
Not really sure what is causing that error in my project.
Can you share a reproduction?
Here's a repro, https://github.com/Banou26/parcel-bug-6605
After some more testing, deleting my package-lock and my node_modules(not sure if those did anything TBH), plus setting parcel as watch
mode, allow parcel to not throw. But the moment i re-enable the http-server by removing watch
, it starts throwing again.
And it also looks like the watch mode is actually broken and doesn't ~re-build on file changes~ build at all, even though it prints
Bundling...
β Built in 45ms
Same result after deleting the .parcel-cache
folder
Also, While working on the repro for another issue, i confirmed? that this issue only happens when using the JSX pragma, as its the same repro, without the pragma at the top of the file, and it doesn't throw.
Thanks banou, that helped me out of a pickle. Kinda counterintuitive the remove the pragma like that.
I cam here from SO.
I hit
@parcel/transformer-js: cannot access a scoped thread local variable without calling `set` first
when compiling a component (even if the component was not referenced anywhere):
export const Component = ({children})=>{
return (
<div style={{
fontFamily: 'Arial',
}}>
<Something/>
{...children}
</div>
);
}
and solved by replacing {...children}
with {children}
.
Hope this helps someone!
Just ran into this. Thank you very much!
Further to @CreativeCactus it looks like Parcel crashes out with this error when you spread any array (not just children
):
const Boom = () => {
const littleBoom = ['hello', 'world']
return <div>{...littleBoom.map(el => el)}</div>
}
I'll make sure this "Spread children are not supported in React" message is shown in this case (instead of this panic).
I'm seeing the same error on v2.5.0 with XML namespaced attributes in <svg>
tags when they're incorrectly included in JSX in their colon-separated form.
e.g.
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="26"
height="26"
viewBox="0 0 26 26"
>
gives
thread '<unnamed>' panicked at 'cannot access a scoped thread local variable without calling `set` first', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-1.0.0\src\lib.rs:168:9
π¨ Build failed.
@parcel/transformer-js: cannot access a scoped thread local variable without calling `set` first
(Correct syntax would be this)
<svg
...
xmlnsXlink="http://www.w3.org/1999/xlink"
...
>
I assume there's an equivalent babel error similar to spreading children that also isn't getting through, perhaps already fixed by #8032, but just mentioning for posterity.
π bug report
Importing an MDX file causes a Rust panic
π― Current Behavior
Context
"last working run was June 29, so likely a regression in 2.0.0-nightly.746"
π» Code Sample
parcel build index.js
package.json:
π Your Environment