solid icon indicating copy to clipboard operation
solid copied to clipboard

`Illegal reassignment of import ...`-bug when setting imported function to ref-prop

Open bigmistqke opened this issue 4 months ago • 1 comments

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

  1. run pnpm dev -> runs perfect
  2. 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

bigmistqke avatar Sep 28 '24 14:09 bigmistqke