Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails when importing firebase firestore #2595

Closed
JakubBlaha opened this issue Oct 13, 2021 · 6 comments
Closed

Build fails when importing firebase firestore #2595

JakubBlaha opened this issue Oct 13, 2021 · 6 comments
Labels

Comments

@JakubBlaha
Copy link

Describe the bug

When working with firebase firestore, pnpm build fails with the following error.

 ~/reproduce/vite-firebase-error │ on master  pnpm build                                                                                                                                                     ✔ 

> vite-firebase-error@0.0.1 build /home/jakub/reproduce/vite-firebase-error
> svelte-kit build

vite v2.6.7 building for production...
transforming (45) node_modules/.pnpm/@firebase+webchannel-wrapper@0.6.0/node_modules/@firebase/webchannel-wrapper/dist/index.esm2017.js5:14:51 PM [vite-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.
- @firebase/firestore
✓ 46 modules transformed.
.svelte-kit/output/client/_app/assets/svelte-logo-87df40b8.svg                           1.85 KiB
.svelte-kit/output/client/_app/assets/fira-mono-cyrillic-400-normal-046b609f.woff2       9.08 KiB
.svelte-kit/output/client/_app/assets/fira-mono-greek-ext-400-normal-8659ae46.woff2      7.85 KiB
.svelte-kit/output/client/_app/assets/fira-mono-greek-400-normal-1f8b3a07.woff2          10.48 KiB
.svelte-kit/output/client/_app/assets/fira-mono-latin-ext-400-normal-b6331a25.woff2      11.84 KiB
.svelte-kit/output/client/_app/assets/fira-mono-cyrillic-ext-400-normal-b3140dd3.woff2   16.11 KiB
.svelte-kit/output/client/_app/assets/fira-mono-latin-400-normal-a2f9dbe8.woff2          16.44 KiB
.svelte-kit/output/client/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff             75.54 KiB
.svelte-kit/output/client/_app/manifest.json                                             2.43 KiB
.svelte-kit/output/client/_app/start-c9218e14.js                                         18.65 KiB / gzip: 6.85 KiB
.svelte-kit/output/client/_app/pages/__layout.svelte-dac43e49.js                         4.70 KiB / gzip: 1.84 KiB
.svelte-kit/output/client/_app/error.svelte-bde03538.js                                  1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/pages/about.svelte-83d43971.js                            2.38 KiB / gzip: 1.09 KiB
.svelte-kit/output/client/_app/pages/todos/index.svelte-11d9410f.js                      5.69 KiB / gzip: 2.35 KiB
.svelte-kit/output/client/_app/pages/index.svelte-edfc0728.js                            4.14 KiB / gzip: 1.71 KiB
.svelte-kit/output/client/_app/assets/start-61d1577b.css                                 0.16 KiB / gzip: 0.15 KiB
.svelte-kit/output/client/_app/assets/pages/about.svelte-bf4528fa.css                    0.11 KiB / gzip: 0.10 KiB
.svelte-kit/output/client/_app/assets/pages/todos/index.svelte-784042c1.css              3.70 KiB / gzip: 1.04 KiB
.svelte-kit/output/client/_app/assets/pages/__layout.svelte-1fda6867.css                 4.98 KiB / gzip: 1.55 KiB
.svelte-kit/output/client/_app/assets/pages/index.svelte-b6f83df6.css                    1.36 KiB / gzip: 0.48 KiB
.svelte-kit/output/client/_app/chunks/vendor-9ab8fc64.js                                 142.88 KiB / gzip: 40.04 KiB
vite v2.6.7 building SSR bundle for production...
transforming (275) node_modules/.pnpm/protobufjs@6.11.2/node_modules/protobufjs/src/writer_buffer.jsUse of eval is strongly discouraged, as it poses security risks and may cause issues with minification
5:14:54 PM [vite-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.
- @firebase/firestore
✓ 315 modules transformed.
.svelte-kit/output/server/app.js   1348.35 KiB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-vercel
 > .svelte-kit/output/server/app.js:12803:14: warning: Using direct eval with a bundler is not recommended and may cause problems (more info: https://esbuild.github.io/link/direct-eval)
    12803 │     var mod = eval("quire".replace(/^/, "re"))(moduleName);
          ╵               ~~~~

 > .svelte-kit/output/server/app.js:22:7: error: No matching export in "node_modules/.pnpm/tslib@2.3.1/node_modules/tslib/modules/index.js" for import "default"
    22 │ import require$$0$5, { __values, __read, __awaiter, __generator, __spreadArray, __rest } from "tslib";
       ╵        ~~~~~~~~~~~~

> Build failed with 1 error:
.svelte-kit/output/server/app.js:22:7: error: No matching export in "node_modules/.pnpm/tslib@2.3.1/node_modules/tslib/modules/index.js" for import "default"
Error: Build failed with 1 error:
.svelte-kit/output/server/app.js:22:7: error: No matching export in "node_modules/.pnpm/tslib@2.3.1/node_modules/tslib/modules/index.js" for import "default"
    at failureErrorWithLog (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1493:15)
    at /home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1151:28
    at runOnEndCallbacks (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1069:65)
    at buildResponseToResult (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1149:7)
    at /home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1258:14
    at /home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:629:9
    at handleIncomingPacket (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:596:7)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:307:12)
 ELIFECYCLE  Command failed with exit code 1.
 ~/reproduce/vite-firebase-error │ on master 

Reproduction

https://github.com/jakubblaha-ids/vite-firebase-error

Logs

~/reproduce/vite-firebase-error │ on master  pnpm build                                                                                                                                                     ✔ 

> vite-firebase-error@0.0.1 build /home/jakub/reproduce/vite-firebase-error
> svelte-kit build

vite v2.6.7 building for production...
transforming (45) node_modules/.pnpm/@firebase+webchannel-wrapper@0.6.0/node_modules/@firebase/webchannel-wrapper/dist/index.esm2017.js5:14:51 PM [vite-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.
- @firebase/firestore
✓ 46 modules transformed.
.svelte-kit/output/client/_app/assets/svelte-logo-87df40b8.svg                           1.85 KiB
.svelte-kit/output/client/_app/assets/fira-mono-cyrillic-400-normal-046b609f.woff2       9.08 KiB
.svelte-kit/output/client/_app/assets/fira-mono-greek-ext-400-normal-8659ae46.woff2      7.85 KiB
.svelte-kit/output/client/_app/assets/fira-mono-greek-400-normal-1f8b3a07.woff2          10.48 KiB
.svelte-kit/output/client/_app/assets/fira-mono-latin-ext-400-normal-b6331a25.woff2      11.84 KiB
.svelte-kit/output/client/_app/assets/fira-mono-cyrillic-ext-400-normal-b3140dd3.woff2   16.11 KiB
.svelte-kit/output/client/_app/assets/fira-mono-latin-400-normal-a2f9dbe8.woff2          16.44 KiB
.svelte-kit/output/client/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff             75.54 KiB
.svelte-kit/output/client/_app/manifest.json                                             2.43 KiB
.svelte-kit/output/client/_app/start-c9218e14.js                                         18.65 KiB / gzip: 6.85 KiB
.svelte-kit/output/client/_app/pages/__layout.svelte-dac43e49.js                         4.70 KiB / gzip: 1.84 KiB
.svelte-kit/output/client/_app/error.svelte-bde03538.js                                  1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/pages/about.svelte-83d43971.js                            2.38 KiB / gzip: 1.09 KiB
.svelte-kit/output/client/_app/pages/todos/index.svelte-11d9410f.js                      5.69 KiB / gzip: 2.35 KiB
.svelte-kit/output/client/_app/pages/index.svelte-edfc0728.js                            4.14 KiB / gzip: 1.71 KiB
.svelte-kit/output/client/_app/assets/start-61d1577b.css                                 0.16 KiB / gzip: 0.15 KiB
.svelte-kit/output/client/_app/assets/pages/about.svelte-bf4528fa.css                    0.11 KiB / gzip: 0.10 KiB
.svelte-kit/output/client/_app/assets/pages/todos/index.svelte-784042c1.css              3.70 KiB / gzip: 1.04 KiB
.svelte-kit/output/client/_app/assets/pages/__layout.svelte-1fda6867.css                 4.98 KiB / gzip: 1.55 KiB
.svelte-kit/output/client/_app/assets/pages/index.svelte-b6f83df6.css                    1.36 KiB / gzip: 0.48 KiB
.svelte-kit/output/client/_app/chunks/vendor-9ab8fc64.js                                 142.88 KiB / gzip: 40.04 KiB
vite v2.6.7 building SSR bundle for production...
transforming (275) node_modules/.pnpm/protobufjs@6.11.2/node_modules/protobufjs/src/writer_buffer.jsUse of eval is strongly discouraged, as it poses security risks and may cause issues with minification
5:14:54 PM [vite-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.
- @firebase/firestore
✓ 315 modules transformed.
.svelte-kit/output/server/app.js   1348.35 KiB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-vercel
 > .svelte-kit/output/server/app.js:12803:14: warning: Using direct eval with a bundler is not recommended and may cause problems (more info: https://esbuild.github.io/link/direct-eval)
    12803 │     var mod = eval("quire".replace(/^/, "re"))(moduleName);~~~~

 > .svelte-kit/output/server/app.js:22:7: error: No matching export in "node_modules/.pnpm/tslib@2.3.1/node_modules/tslib/modules/index.js" for import "default"
    22 │ import require$$0$5, { __values, __read, __awaiter, __generator, __spreadArray, __rest } from "tslib";~~~~~~~~~~~~

> Build failed with 1 error:
.svelte-kit/output/server/app.js:22:7: error: No matching export in "node_modules/.pnpm/tslib@2.3.1/node_modules/tslib/modules/index.js" for import "default"
Error: Build failed with 1 error:
.svelte-kit/output/server/app.js:22:7: error: No matching export in "node_modules/.pnpm/tslib@2.3.1/node_modules/tslib/modules/index.js" for import "default"
    at failureErrorWithLog (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1493:15)
    at /home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1151:28
    at runOnEndCallbacks (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1069:65)
    at buildResponseToResult (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1149:7)
    at /home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:1258:14
    at /home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:629:9
    at handleIncomingPacket (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/home/jakub/reproduce/vite-firebase-error/node_modules/.pnpm/esbuild@0.13.5/node_modules/esbuild/lib/main.js:596:7)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:307:12)
 ELIFECYCLE  Command failed with exit code 1.
 ~/reproduce/vite-firebase-error │ on master

System Info

System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 4.86 GB / 7.77 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.13.1 - ~/.nvm/versions/node/v14.13.1/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.13.1/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.13.1/bin/npm
  npmPackages:
    @sveltejs/adapter-vercel: ^1.0.0-next.31 => 1.0.0-next.31 
    @sveltejs/kit: next => 1.0.0-next.182 
    svelte: ^3.34.0 => 3.43.2

Severity

blocking all usage of SvelteKit

Additional Information

No response

@benmccann benmccann added the vite label Oct 13, 2021
@benmccann
Copy link
Member

There are bugs in Firebase (firebase/firebase-js-sdk#4846) and Vite (vitejs/vite#4425) causing Firebase not to work with SvelteKit. Please give a thumbs up on those issues. There's not much we can do in SvelteKit itself to fix this

@JakubBlaha
Copy link
Author

Is there anything I can do to skip the SSR or the part of the bundling that's causing the error?

@kenkunz
Copy link

kenkunz commented Oct 13, 2021

@JakubBlaha see firebase/firebase-js-sdk#5499 which appears to be related.

Please give a 👍 on that issue as well (and the PR that fixes it).

If this is the same root issue that you're seeing with the vercel adapter, you should be able to revert to firebase 9.0.0 until a fix is released.

@benmccann benmccann changed the title Build fails when importing firebase frestore Build fails when importing firebase firestore Oct 13, 2021
@benmccann
Copy link
Member

Is there anything I can do to skip the SSR or the part of the bundling that's causing the error?

Probably not until #2529 is merged

@kenkunz, thanks for sharing firebase/firebase-js-sdk#5499! I chimed in on the PR, which looks like a good fix for Firestore and suggested they do the same for all the other Firebase packages as well

I'm going to go ahead and close this since the issue is in Firebase and there's nothing we can do beyond offer guidance. Since there's already a PR pending with the fix and we've weighed in on it, I'm going to go ahead and close this

@winston0410
Copy link

I bumped into this issue today as well, but the package I have is broadcast-channel. Seems like the fix has been made for Firebase, but still I am getting this one. @benmccann can you advice me how to fix this, or should I just go upstream?

when importing like this:

import { BroadcastChannel, createLeaderElection } from 'broadcast-channel';

I got:

> Named export 'BroadcastChannel' not found. The requested module 'broadcast-channel' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'broadcast-channel';
const { BroadcastChannel, createLeaderElection } = pkg;

But the package.json for broadcast-channel has this:

  "license": "MIT",
  "main": "./dist/es5node/index.js",
  "module": "./dist/esnode/index.js",
  "name": "broadcast-channel",

So I don't understand why vite cannot pick up the module path there.

@benmccann
Copy link
Member

@winston0410 please file a new issue with a repository to reproduce. We can't track comments on closed issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants