solidjs / vite-plugin-solid

A simple integration to run solid-js with vite
440 stars 51 forks source link

2.8.1 vite dev server : Uncaught ReferenceError: _tmpl$ is not defined #134

Closed lzyor closed 10 months ago

lzyor commented 10 months ago

on 2.8.1

simple project as:

// package.json
{
  "dependencies": {
    "solid-js": "^1.8.11",
    "vite": "^5.0.11",
    "vite-plugin-solid": "^2.8.1"
  }
}

// index.jsx (copy from solidjs tutorial)
import { render } from "solid-js/web";
import { createSignal } from "solid-js";

function Counter() {
  const [count, setCount] = createSignal(0);
  setInterval(() => setCount(count() + 1), 1000);
  return <div>Count: {count()}</div>;
}
render(() => <Counter />, document.getElementById('root'));

// vite.config.js
import { defineConfig } from "vite";
import solidPlugin from "vite-plugin-solid";

export default defineConfig({
  plugins: [ solidPlugin()],
  server: {port: 3000},
  build: {target: "esnext"},
});

run:

npx vite

browser get:

Uncaught ReferenceError: _tmpl$ is not defined

nothing rendered

but...

"vite-plugin-solid": "=2.8.0"

work fine

env

node v18.18.0 npm 9.8.1 kubuntu 22.04

lzyor commented 10 months ago

There is a big difference in the output of vite dev server versions 2.8.1 and 2.8.0: 2.8.1-dev-server-output.js.log 2.8.0-dev-server-output.js.log

The vite build output of both versions is normal and the same.

lxsmnsyc commented 10 months ago

No templates are being generated at all. Might be an issue with dom-expressions.

lxsmnsyc commented 10 months ago

Upon testing, I think this was solid-refresh's issue. Weird that templates are not being generated at all.

GrayFrost commented 10 months ago

image
meet same issue: vite-plugin-solid 2.8.1

floratmin commented 10 months ago

When running vite-plugin-solid 2.8.1 with vitest I get the additional info

The exported identifier "App" is not declared in Babel's scope tracker
as a JavaScript value binding, and "@babel/plugin-transform-typescript"
never encountered it as a TypeScript type declaration.
It will be treated as a JavaScript value.

This problem is likely caused by another plugin injecting
"App" without registering it in the scope tracker. If you are the author
 of that plugin, please use "scope.registerDeclaration(declarationPath)".
stderr | file:/home/workspac/node_modules/.pnpm/solid-js@1.8.11/node_modules/solid-js/dist/dev.js:1747:67
You appear to have multiple instances of Solid. This can lead to unexpected behavior.

stderr | src/App.test.tsx > App > should render the app
computations created outside a `createRoot` or `render` will never be disposed
Kapelianovych commented 5 months ago

Hello. I encountered this issue on version 2.10.2. Among 10 _tmpl$ variables the first one is missing. I tried downgrade - the dev server sent me a bunch of errors. On the 2.11.0.beta-0 9 of 10 variables are missing. For context, I have Stage 3 decorators in my files, so I had to add the babel plugin to vite-plugin-solid:

{
  babel: {
    plugins: [
      ['@babel/plugin-proposal-decorators', { version: '2023-11' }],
    ],
  },
}

And the same as the original issue - only dev server is affected.

Edit: the solution for me is to use the @babel/plugin-syntax-decorators instead of the one above to just enhance the Babel parser and skip decorators transformation.