fastify / fastify-vite

Fastify plugin for Vite integration.
MIT License
859 stars 72 forks source link

[Solid] Solid example is not working #73

Closed ghost closed 2 years ago

ghost commented 2 years ago

Prerequisites

Fastify version

3.27.4

Plugin version

No response

Node.js version

16.14.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

PopOS 21.10

Description

Hello, I want to use fastify vite for a solid js application. But I don't know why but it seems fastify-vite is incompatible with solid-app-router. As I see maybe there is an invalid configuration who display this error :

❯ pnpm dev                                

> fastify-solid@1.0.0 dev /home/quentin/Documents/dev/fastify-solid
> ts-node-dev --no-notify --respawn --transpile-only ./src/app.ts

[INFO] 08:33:43 ts-node-dev ver. 1.1.8 (using ts-node ver. 9.1.1, typescript ver. 4.6.3)
8:33:44 AM [vite] Error when evaluating SSR module @app/client.jsx:
file:///home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/solid-app-router@0.3.2_solid-js@1.3.13/node_modules/solid-app-router/dist/index.js:1
import { isServer, template, createComponent as createComponent$1, mergeProps, spread, insert, effect, setAttribute } from 'solid-js/web';
                                                                                               ^^^^^^
SyntaxError: The requested module 'solid-js/web' does not provide an export named 'effect'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at nodeImport (/home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/vite@2.8.6/node_modules/vite/dist/node/chunks/dep-9c153816.js:56262:21)
    at eval (@app/client.jsx:14:31)
    at instantiateModule (/home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/vite@2.8.6/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:9)
8:33:44 AM [vite] Error when evaluating SSR module /home/quentin/Documents/dev/fastify-solid/src/@app/entry/server.jsx:
file:///home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/solid-app-router@0.3.2_solid-js@1.3.13/node_modules/solid-app-router/dist/index.js:1
import { isServer, template, createComponent as createComponent$1, mergeProps, spread, insert, effect, setAttribute } from 'solid-js/web';
                                                                                               ^^^^^^
SyntaxError: The requested module 'solid-js/web' does not provide an export named 'effect'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at nodeImport (/home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/vite@2.8.6/node_modules/vite/dist/node/chunks/dep-9c153816.js:56262:21)
    at eval (@app/client.jsx:14:31)
    at instantiateModule (/home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/vite@2.8.6/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:9)
file:///home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/solid-app-router@0.3.2_solid-js@1.3.13/node_modules/solid-app-router/dist/index.js:1
import { isServer, template, createComponent as createComponent$1, mergeProps, spread, insert, effect, setAttribute } from 'solid-js/web';
                                                                                               ^^^^^^
SyntaxError: The requested module 'solid-js/web' does not provide an export named 'effect'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at nodeImport (/home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/vite@2.8.6/node_modules/vite/dist/node/chunks/dep-9c153816.js:56262:21)
    at eval (@app/client.jsx:14:31)
    at instantiateModule (/home/quentin/Documents/dev/fastify-solid/node_modules/.pnpm/vite@2.8.6/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:9)
[ERROR] 08:33:44 SyntaxError: The requested module 'solid-js/web' does not provide an export named 'effect'

I see an issue who have the same error : https://github.com/solidjs/solid-app-router/issues/80

Steps to Reproduce

I give a reproduction repository : https://github.com/qlaffont-flexper/fastify-solid-vite-example

Expected Behavior

No response

galvez commented 2 years ago

Thanks @qlaffont-flexper — the Solid adapter is still quite new and experimental, so this should be useful debugging it.

ghost commented 2 years ago

Yes, no problem logically you have everything to debug it. Tell me if I can help by any way. ^^

galvez commented 2 years ago

SyntaxError: The requested module 'solid-js/web' does not provide an export named 'effect'

I have ran into this same exact issue myself. For now I have deprecated the Solid example until I'm able to debug it.

Will update this issue when there are news in that front.

knpwrs commented 2 years ago

This appears to be a bug with solid. solid-app-router is importing effect from solid-js/web, but that module indeed only has two export statements and neither include effect:

export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, mergeProps } from 'solid-js';
// ...
export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle };
knpwrs commented 2 years ago

Reported at: https://github.com/solidjs/vite-plugin-solid/issues/40

galvez commented 2 years ago

I ran into that — I've tracked it down to the plugin missing the ssr setting. See the new working example.

galvez commented 2 years ago

Oh, interesting, you're getting that with that new example — so weird. It works for me but I'll check again.

galvez commented 2 years ago

I'm unable to reproduce, the example boots and runs fine for me.

Screen Shot 2022-06-04 at 17 26 51