Open krishna-santosh opened 1 year ago
Start a new pull request in StackBlitz Codeflow.
It is enough to add deno
to get a failing build (no need to add prisma
).
However the error is different:
Error during SSG
getPlatform is not iterable (cannot read property Symbol(Symbol.iterator))
Pathname: /
Plugin: qwik-ssg
File: /home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:9038:34
9037| const RouterOutlet = /* @__PURE__ */ componentQrl(/*#__PURE__*/ inlinedQrl(s_e0ssiDXoeAM, "s_e0ssiDXoeAM"));
9038| const QACTION_KEY = "qaction";
9039| const resolveHead = (endpoint, routeLocation, contentModules, locale)=>{
| ^
9040| const head = createDocumentHead();
9041| const getData = (loaderOrAction)=>{
at shim (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:9038:34)
at AsyncFunction.s_e0ssiDXoeAM (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:9053:24)
at AsyncFunction.invoke (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:744:46)
at eval (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:4644:28)
at then (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:186:79)
at eval (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:4634:20)
at eval (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:1332:28)
at safeCall (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:179:25)
at executeComponent (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:1332:12)
at renderSSRComponent (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:1591:6)
However the error is different:
Error during SSG getPlatform is not iterable (cannot read property Symbol(Symbol.iterator)) Pathname: / Plugin: qwik-ssg File: /home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:9038:34 9037| const RouterOutlet = /* @__PURE__ */ componentQrl(/*#__PURE__*/ inlinedQrl(s_e0ssiDXoeAM, "s_e0ssiDXoeAM")); 9038| const QACTION_KEY = "qaction"; 9039| const resolveHead = (endpoint, routeLocation, contentModules, locale)=>{ | ^ 9040| const head = createDocumentHead(); 9041| const getData = (loaderOrAction)=>{ at shim (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:9038:34) at AsyncFunction.s_e0ssiDXoeAM (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:9053:24) at AsyncFunction.invoke (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:744:46) at eval (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:4644:28) at then (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:186:79) at eval (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:4634:20) at eval (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:1332:28) at safeCall (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:179:25) at executeComponent (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:1332:12) at renderSSRComponent (file:///home/projects/qwik-starter-2irmfx/server/assets/@qwik-city-plan-00ac1429.js:1591:6)
This can be separate issue in itself.
It is enough to add
deno
to get a failing build (no need to addprisma
).
In my case the problem was with deno and prisma combined, build was failing when i add prisma.
This is happening with prisma and node as well
Adding an alias in vite.config.ts
resolved this
resolve: {
alias: {
".prisma/client/index-browser": "./node_modules/.prisma/client/index-browser.js"
}
},
Disclaimer: I did not try this with Deno, yet, but I hope it will help.
Could you try that and let us know if that works for?
I found out that the "Invalid module" error could be solved with 2 aliases, see my repro here: https://github.com/Jolg42/prisma-repro-21094
This is what worked for me: https://github.com/Jolg42/prisma-repro-21094/blob/main/adapters/vercel-edge/vite.config.ts
import { vercelEdgeAdapter } from "@builder.io/qwik-city/adapters/vercel-edge/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";
export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ["src/entry.vercel-edge.tsx", "@qwik-city-plan"],
},
outDir: ".vercel/output/functions/_qwik-city.func",
},
plugins: [vercelEdgeAdapter()],
resolve: {
alias: {
".prisma/client/default": "./node_modules/.prisma/client/default.js",
"./query_engine_bg.wasm?module": "./node_modules/.prisma/client/query_engine_bg.wasm?init",
},
},
};
});
I found out about this in Vite's docs here https://vitejs.dev/guide/features#webassembly
Pre-compiled .wasm files can be imported with ?init.
Originally posted by @Jolg42 in https://github.com/prisma/prisma/issues/21094#issuecomment-2142474474
@krishna-santosh Did you solve the problem?
Tried both solutions proposed by @sarat1669 and @Jolg42, but unfortunately they both didn't work.
vite v5.3.1 building SSR bundle for production...
".prisma/client/index-browser" is imported by ".prisma/client/index-browser?commonjs-external", but could not be resolved β treating it as an external dependency.
β 44 modules transformed.
server/build/q-C4YPi7sT.css 4.85 kB
server/entry.ssr.js 0.07 kB
server/@qwik-city-plan.js 41.01 kB
server/entry.deno.js 51.10 kB
server/q-BulQp7W4.js 60.24 kB
server/q-BN1iqjfz.js 348.71 kB
β built in 5.39s
error during build:
TypeError [PLUGIN_ERROR]: Invalid module ".prisma/client/index-browser" is not a valid package name imported from /home/user/Code/Test/qwik-app/server/@qwik-city-plan.js
at parsePackageName (node:internal/modules/esm/resolve:768:11)
at packageResolve (node:internal/modules/esm/resolve:792:5)
at moduleResolve (node:internal/modules/esm/resolve:914:18)
at defaultResolve (node:internal/modules/esm/resolve:1119:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:541:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
undefined
Thanks @krishna-santosh In the Prisma docs I found
previewFeatures = ["deno"]
Are you using this configuration?
I added it to schema.prisma
and tried building the project again, but the result is still the same.
Related issue: https://github.com/prisma/prisma/issues/21094
this would be fixed by using deno run's --unstable-sloppy-imports
for the .js in the import path, but I am not sure if that can be added to vercel configs.
Which component is affected?
Qwik Rollup / Vite plugin
Describe the bug
Added Prisma and Deno adapter to Starter App and tried to build with
npm run build
Build Failed.
Output:
Reproduction
https://stackblitz.com/edit/qwik-starter-2irmfx
Steps to reproduce
npm create qwik@latest cd qwik-app npm install npm run qwik add prisma npm run qwik add deno npm run build
System Info
Additional Information
No response