solid
solid copied to clipboard
`Illegal reassignment of import ...`-bug when setting imported function to ref-prop
Describe the bug
// binding.ts
export function binding(element){
}
// this_does_not_work.ts
import {binding} from "./binding"
import {render} from "solid-js/web"
render(() => <div ref={binding}/>, document.body)
If you run this in development mode it will run without error, but when building it we get the Illegal reassignment of import ...
-bug. Something with the transform that it tries to ref={element => binding = element}
instead of calling the function.
When you alias the import it will not fail:
// this_does_work.ts
import {binding} from "./binding"
import {render} from "solid-js/web"
const _binding = (element) => binding(element)
render(() => <div ref={_binding}/>, document.body)
Your Example Website or App
https://github.com/bigmistqke/illegal-solid-bug
Steps to Reproduce the Bug or Issue
- run
pnpm dev
-> runs perfect - run
pnpm build
->Illegal reassignment of import "binding" in "src/index.tsx"
error
Expected behavior
I expected the binding-function to be called and the transform not try to assign to imports.
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response