-
Notifications
You must be signed in to change notification settings - Fork 900
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
Fix Firestore exports for Node #5532
Changes from all commits
78a2bbe
a8107d8
67400fc
7a48599
d2b37a2
5ab9103
f8348bf
5e57f25
c5e701f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@firebase/firestore': minor | ||
--- | ||
|
||
Fix exports field to also point to Node ESM builds. This change requires Node.js version 10+. |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,7 +2,7 @@ | |||
"name": "@firebase/firestore", | ||||
"version": "3.1.0", | ||||
"engines": { | ||||
"node": "^8.13.0 || >=10.10.0" | ||||
"node": ">=10.10.0" | ||||
}, | ||||
"description": "The Cloud Firestore component of the Firebase JS SDK.", | ||||
"author": "Firebase <[email protected]> (https://firebase.google.com/)", | ||||
|
@@ -49,16 +49,22 @@ | |||
}, | ||||
"exports": { | ||||
".": { | ||||
"node": "./dist/index.node.cjs.js", | ||||
"node": { | ||||
"require": "./dist/index.node.cjs.js", | ||||
"import": "./dist/index.node.mjs" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the build rule for creating this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It gets the name from whatever is in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So here is the build config
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Did you test it in Nodejs - running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested it with svelte-kit's SSR(?) build step using
I think it's not able to deal with a dependency (grpc-js) still being in cjs format, and svelte-kit uses esbuild so something in the build step is fixing whatever the problem is, unless you import from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added the workaround in Option 2 here: https://www.stefanjudis.com/snippets/how-to-import-json-files-in-es-modules-node-js/#option-2%3A-leverage-the-commonjs-%60require%60-function-to-load-json-files It required some changes to tsconfig.json to avoid some TS compiler complaints but it compiles correctly and works in both a Node and a Sveltekit test project. It also works in both projects if I don't change tsconfig and I just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd use |
||||
}, | ||||
"default": "./dist/index.esm2017.js" | ||||
}, | ||||
"./lite": { | ||||
"node": "./dist/lite/index.node.cjs.js", | ||||
"node": { | ||||
"require": "./dist/lite/index.node.cjs.js", | ||||
"import": "./dist/lite/index.node.mjs" | ||||
}, | ||||
"default": "./dist/lite/index.browser.esm2017.js" | ||||
} | ||||
}, | ||||
"main": "dist/index.node.cjs.js", | ||||
"main-esm": "dist/index.node.cjs.esm2017.js", | ||||
"main-esm": "dist/index.node.mjs", | ||||
"react-native": "dist/index.rn.js", | ||||
"browser": "dist/index.esm2017.js", | ||||
"module": "dist/index.esm2017.js", | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing Node 8 from this line.