Firebase v9.0.1 with Sveltekit node adapter – build failure (original) (raw)

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

I am using Firebase (auth and firestore) in a Sveltekit project. It has been building and running successfully until I recently tried to upgrade. I was able to isolate the error to 9.0.1 (more specifically: firestore 3.0.1).

I created a minimal app to identify what dependencies/versions are required in order to reproduce the issue. This occurs when building any recent version of Sveltekit with the node adapter. Using an older version of Sveltekit or the node adapter does not resolve the problem. Only by reverting to Firebase 9.0.0 (firestore 3.0.0) was it resolved, which is why I believe the issue is with Firebase / Firestore.

Steps to reproduce:

  1. Create a skeleton Sveltekit app:
$ npm init svelte@next sveltekit-firebase  
> Skeleton project  
> No Typescript  
> No ESLint  
> No Prettier  
  1. Install additional dependencies (firebase and @sveltejs/adapter-node)
$ cd sveltekit-firebase  
$ npm i -P firebase@9.0.1  
$ npm i -D @sveltejs/adapter-node@next  
  1. Edit svelte.config.js and src/routes/index.svelte to import/use the two dependencies (see below)
  2. Build the project
  3. Note the build errors (see example error output below)
  4. Revert firebase to 9.0.0 and build again
$ npm i -P firebase@9.0.0  
$ npm run build  
  1. Note the build succeeds

Relevant Code:

./svelte.config.js

/** @type {import('@sveltejs/kit').Config} */ import nodeAdapter from "@sveltejs/adapter-node";

const config = { kit: { adapter: nodeAdapter(), // hydrate the

element in src/app.html target: "#svelte", }, };

export default config;

./src/routes/index.svelte

Welcome to SvelteKit

Visit kit.svelte.dev to read the documentation

Resulting Error Output

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

> Cannot read property 'prototype' of undefined
TypeError: Cannot read property 'prototype' of undefined
    at file:///Users/ken/Code/sandbox/sveltekit-firebase/.svelte-kit/output/server/app.js:12359:56
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async prerender (file:///Users/ken/Code/sandbox/sveltekit-firebase/node_modules/@sveltejs/kit/dist/chunks/index5.js:121:14)
    at async Object.prerender (file:///Users/ken/Code/sandbox/sveltekit-firebase/node_modules/@sveltejs/kit/dist/chunks/index5.js:352:4)
    at async adapt (file:///Users/ken/Code/sandbox/sveltekit-firebase/node_modules/@sveltejs/adapter-node/index.js:105:4)
    at async adapt (file:///Users/ken/Code/sandbox/sveltekit-firebase/node_modules/@sveltejs/kit/dist/chunks/index5.js:377:2)
    at async file:///Users/ken/Code/sandbox/sveltekit-firebase/node_modules/@sveltejs/kit/dist/cli.js:877:5