Skip to content

add esm entry points for node #5167

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

Merged
merged 2 commits into from
Jul 21, 2021
Merged

add esm entry points for node #5167

merged 2 commits into from
Jul 21, 2021

Conversation

Feiyang1
Copy link
Member

Addresses #5140

@changeset-bot
Copy link

changeset-bot bot commented Jul 16, 2021

⚠️ No Changeset found

Latest commit: dc39a9c

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

@Feiyang1 Feiyang1 added the v9 label Jul 16, 2021
@Feiyang1 Feiyang1 added this to the v9 GA milestone Jul 16, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Jul 16, 2021

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 16, 2021

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (02586c9) Head (a87e7b7) Diff
    browser 284 kB 285 kB +240 B (+0.1%)
    esm2017 226 kB 227 kB +252 B (+0.1%)
    main 531 kB 531 kB +424 B (+0.1%)
    module 284 kB 285 kB +240 B (+0.1%)
    react-native 227 kB 227 kB +256 B (+0.1%)
  • @firebase/firestore-exp

    Type Base (02586c9) Head (a87e7b7) Diff
    browser 224 kB 224 kB +251 B (+0.1%)
    main 510 kB 511 kB +424 B (+0.1%)
    module 224 kB 224 kB +251 B (+0.1%)
    react-native 224 kB 224 kB +281 B (+0.1%)
  • @firebase/firestore-lite

    Type Base (02586c9) Head (a87e7b7) Diff
    browser 72.6 kB 72.7 kB +153 B (+0.2%)
    main 149 kB 149 kB +324 B (+0.2%)
    module 72.6 kB 72.7 kB +153 B (+0.2%)
    react-native 72.8 kB 72.9 kB +153 B (+0.2%)
  • @firebase/firestore/bundle

    Type Base (02586c9) Head (a87e7b7) Diff
    browser 290 kB 291 kB +286 B (+0.1%)
    esm2017 177 kB 177 kB +157 B (+0.1%)
    main 527 kB 527 kB +424 B (+0.1%)
    module 290 kB 291 kB +286 B (+0.1%)
    react-native 177 kB 177 kB +161 B (+0.1%)
  • @firebase/firestore/memory

    Type Base (02586c9) Head (a87e7b7) Diff
    browser 216 kB 217 kB +457 B (+0.2%)
    esm2017 172 kB 172 kB +157 B (+0.1%)
    main 325 kB 325 kB +290 B (+0.1%)
    module 216 kB 217 kB +457 B (+0.2%)
    react-native 172 kB 172 kB +161 B (+0.1%)
  • @firebase/firestore/memory-bundle

    Type Base (02586c9) Head (a87e7b7) Diff
    browser 224 kB 225 kB +185 B (+0.1%)
    esm2017 177 kB 177 kB +157 B (+0.1%)
    main 322 kB 322 kB +290 B (+0.1%)
    module 224 kB 225 kB +185 B (+0.1%)
    react-native 177 kB 177 kB +161 B (+0.1%)
  • firebase

    Type Base (02586c9) Head (a87e7b7) Diff
    firebase-firestore.js 336 kB 336 kB +465 B (+0.1%)
    firebase-firestore.memory.js 271 kB 271 kB +175 B (+0.1%)
    firebase.js 893 kB 894 kB +339 B (+0.0%)

Test Logs

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 16, 2021

Size Analysis Report

Affected Products

No changes between base commit (02586c9) and head commit (a87e7b7).

"node": "./analytics/dist/index.cjs.js",
"node": {
"require": "./analytics/dist/index.cjs.js",
"import": "./analytics/dist/index.esm.js"

Choose a reason for hiding this comment

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

The file extension should be .mjs, otherwise Node would fail to parse it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, good catch! I fixed it in a different way by declaring "type": "module" in the package.jsons, and changing the extension of cjs files from js to cjs, so they still work with require()s. This way, I only need to generate 2 files per subpath, an esm.js file and a cjs file instead of 3(esm.js, esm.mjs and cjs.js).

Copy link
Member Author

Choose a reason for hiding this comment

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

I tested it locally, and both import and require syntax work with this setup.

@Feiyang1 Feiyang1 merged commit 7028c11 into master Jul 21, 2021
@Feiyang1 Feiyang1 deleted the fei-esm-node branch July 21, 2021 18:51
@firebase firebase locked and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants