Mát*_*lya 2 firebase typescript server-side-rendering firebase-admin vite
I've been using this vite-plugin-ssr with firebase functions happily until one day firebase-admin bailed on me. My setup was working until I deleted my node modules and reinstalled my dependencies. It seems that vite is bundling firebase-admin with the client even though there are no imports in clientside code referring to firebase-admin, only in the .page.server.ts files. How do I specify to vite or rollup to not bundle firebase-admin into the dist/client directory?
I would really appreciate some pointers... I've spent 24hrs + on this one issue and at this point I am considering switching the SSR off, or copying the files to a fresh project. Basically I just want a clean setup with this simple stack:
\nvite + SSR (using vite-plugin-ssr)> vite build "--config" "vite-ssr.config.ts"\n\nnode_modules/@firebase/util/node_modules/tslib/tslib.es6.js'fast-crc32c' is imported by fast-crc32c?commonjs-external, but could not be resolved \xe2\x80\x93 treating it as an external dependency\ntransforming (2472) \n\xe2\x9c\x93 2478 modules transformed.\n'default' is not exported by node_modules/firebase/app/dist/index.esm.js, imported by node_modules/firebase-admin/node_modules/@firebase/database/dist/index.esm.js\nfile: /Users/mateh/github/control-me/web-app/node_modules/firebase-admin/node_modules/@firebase/database/dist/index.esm.js:1:7\n1: import firebase from 'firebase/app';\n ^\nRun Code Online (Sandbox Code Playgroud)\nThings I have tried:
\nallowSyntheticDefaultImports in tsconfig, did not make a differencenode_modules to import * from '@firebase/app'. The build will pass this way but the client will not be able to use the fast-crc32c module.fast-crc32c模块无济于事,firebase-admin代码中某处存在通用对象未定义错误,显然它不适合在浏览器的客户端上运行。firebase安装在客户端 package.json 并且仅 firebase-admin is in the serverside functions package.json, issue still persists.将其添加到我的vite配置中修复了它:
build: {
rollupOptions: {
external: ['firebase-admin'],
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3243 次 |
| 最近记录: |