[@web/test-runner] Very basic Solid.js example not working inside Web Test Runner unit test
Hi, I've got a very basic Solid.js effect example not working within Web Test Runner.
Here's the most minimal reproduction.
The WTR config defines an import map to import Solid.js from CDN.
The same example, with the same importmap, works fine on CodePen.
Any idea if there's something in WTR's environment that could be messing with globals to somehow cause this?
A workaround is to change this,
import { createEffect } from "solid-js"
import { createMutable } from "solid-js/store"
to this
// import { createEffect } from "solid-js"
// import { createMutable } from "solid-js/store"
const { createEffect } = await eval('import("solid-js")')
const { createMutable } = await eval('import("solid-js/store")')
and it works!
To workaround missing type definitions due to eval, I can do this:
const { createEffect } = /** @type {typeof import("solid-js")} */ (await eval('import("solid-js")'))
const { createMutable } = /** @type {typeof import("solid-js/store")} */ (await eval('import("solid-js/store")'))
It appears that WTR's default build is transforming the code (f.e. the import statements) that leads to the breakage for some reason. Importing natively, based on the importmap pointing to CDN, works fine.
(I have solid-js installed locally only for making type definitions available.)
It would be nicer if I could disable all source transformation to keep native import working as expected:
- https://github.com/modernweb-dev/web/issues/2986