-
Notifications
You must be signed in to change notification settings - Fork 886
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
Add a console warning when browser bundle is loaded in node. #1536
Conversation
packages/app/index.ts
Outdated
isNode && | ||
console.warn(` | ||
Warning: This is a browser-targeted Firebase bundle but it appears it is being run in a Node | ||
environment. This may be because you are using ES module resolution and the Node bundle is |
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.
It's not clear to me what ES module resolution means. It's probably better to just state please use the "main" field in package.json for node bundle.
We can also add the link to webpack doc - https://webpack.js.org/configuration/resolve/#resolvemainfields
and rollup doc - https://github.com/rollup/rollup-plugin-node-resolve
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.
Modified the text.
The solution you guys are proposing is not going to work. Also you give no ways of debugging this issue since Webpack is compiling normally with the 'node' target set. |
it says here: A node targeted Webpack build will load 'module' first, YET, you've added this warning to the index.esm.js entry ( which is the firebase entry for 'module' ) Also changing Webpack global config is NEVER going to work - as you'll cause way worse bugs from other packages with this approach. Also things were working fine for me before, and you guys have not provided a way to disable this huge warning message. |
Thank you for the feedback. And sorry you had a bad experience. To clarify how fields are used in firebase currently: Each firebase SDK (except storage) does something different for Node, so the browser version should really not be used for Node environment. and it could cause issues down the road if you are already using it, so I think the warning message is warranted. We have both cjs and esm build for browser because we want to support as many workflow as possible, for example, browserify only works with cjs natively. I'd like to have a I'm open to suggestions, but given the constraint of a single module field, I don't know what more we can do than giving a warning message when a bundle is used in the unintended environment. I'm not convinced that changing the global If you are really worried about it, you could do something like: resolve: {
alias: {
firebase$: path.resolve(__dirname, 'node_modules/firebase/dist/index.node.cjs.js')
}
} Anyway, thanks for voicing your concern. If you'd like to continue the discussion, please open an issue, so we can track it. |
Partially addresses issue #1415.
Open to suggestions on what the message should recommend to the user.
Tried a rollup node test project and browser webpack test project. Warning is seen in node, not seen in browser.