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

Add exports field with subpaths to firebase-exp/package.json #4767

Merged
merged 9 commits into from
Apr 13, 2021

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Apr 9, 2021

Background for exports: https://nodejs.org/api/packages.html#packages_conditional_exports
It's also recognized by webpack and other bundlers so we can't assume it's only consumed by Node applications. Requested here.

Only adding exports to the main package.json for now. We will do the other packages later if there's a need.

@changeset-bot
Copy link

changeset-bot bot commented Apr 9, 2021

⚠️ No Changeset found

Latest commit: 181f7dc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines 59 to 66
"exports": {
"main": "./dist/index.cjs.js",
"esm5": "./dist/index.esm.js",
"browser": "./dist/index.esm2017.js",
"module": "./dist/index.esm2017.js",
"node": "./dist/index.cjs.js",
"default": "./dist/index.esm2017.js"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does bundler read these fields? I thought we are only using exports to specify submodules, so we only need to define it for packages that has submodules, e.g. only firebase-exp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, webpack seems to look at a lot of possible fields https://webpack.js.org/guides/package-exports and we don't distinguish between browser/module/react-native/etc in the minimal firebase-exp entry points so if you had an app that cared about the difference it would only find them in the individual @firebase packages entry points.

Comment on lines 8 to 9
"browser": "dist/index.esm2017.js",
"module": "dist/index.esm2017.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we don't want to change compat packages, but I guess it's fine since it's going to be a major release

"browser": "./dist/index.esm2017.js",
"module": "./dist/index.esm2017.js",
"node": "./dist/index.cjs.js",
"default": "./dist/index.esm2017.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assign a browser build to default? IIUC, default is used by Nodejs if nothing else matches, so should it be a node build? or should we just leave it since there is a node field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The node examples always put a browser bundle in the default field. I think they assume any Node app will pick up what's in the Node field.

// Set esm2017 as default.
// Delete esm2017 field.
// Add esm5 field.
packageJson.module = expPackageJson.esm2017.replace('../', '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just update the package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I forgot it sources this from a specialized exp-only package.json. Yes, will fix.

@hsubox76 hsubox76 changed the title Update exp packages to default to esm2017 and have exports field Add exports field with subpaths to firebase-exp/package.json Apr 13, 2021
@google-oss-bot
Copy link
Contributor

Binary Size Report

Affected SDKs

No changes between base commit (3a18640) and head commit (a894d56).

Test Logs

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

Successfully merging this pull request may close these issues.

3 participants