FirebaseExtended / FirebaseExtended/rxfire

The requested module is a CommonJS module, which may not support all module.exports as named exports.

Open
#52 9 comments 10 reactions 1 assignee Claimed by @davideast View on GitHub
Dominant language
TypeScript
Stars
149
Forks
50
PR merge metrics
No merged PRs in 30d

Description

I have trouble using `rxfire` with `SvelteKit` using `adapter-static`. When running in dev mode I don't have any issue but when building my app I go troubles...

First, I import the `auth` package like that : `import { authState } from "rxfire/auth";`.
Which gaves me:
```
import { authState } from "rxfire/auth";
^^^^^^^^^
SyntaxError: Named export 'authState' not found. The requested module 'rxfire/auth' 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 'rxfire/auth';
const { authState } = pkg;
```

So, I did `import * as rxfireauth from "rxfire/auth"; const { authState } = rxfireauth;` and...
I got this now:
```
(node:88773) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/scorsi/projects/calicut/front/node_modules/rxfire/auth/index.esm.js:1
import { onAuthStateChanged, onIdTokenChanged, getIdToken } from 'firebase/auth';
^^^^^^

SyntaxError: Cannot use import statement outside a module...
```

The version installed :
- firebase: `9.6.6`
- rxfire: `6.0.3`

This may be related to #48 but I don't technically use SSR at all :)

Temporary workaround: disabling page prerendering in `svelte.config.js` (but I lose all interests of using SvelteKit lol):
```
kit: {
adapter: adapter({fallback: "index.html"}),
prerender: {
enabled: false
},
},
```

I can create a repro project next week if needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.