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

Point browser field to esm build #3932

Merged
merged 13 commits into from
Oct 20, 2020
Merged

Point browser field to esm build #3932

merged 13 commits into from
Oct 20, 2020

Conversation

Feiyang1
Copy link
Member

@Feiyang1 Feiyang1 commented Oct 13, 2020

Rationale

  • Make Firebase work nicely with Angular10.
    Angular10 complains loudly if the browser field points to cjs build. And it's hard for developer to change build configuration which is encapsulated by ngcc
    See FR: Make Firebase SDK compatible with Angular 10 #3315

  • Address the incompatibility issue between our typings and esm builds
    Our typings are modeled after the cjs module format, using export = firebase, so we ask developers to use namespace import to import firebase, like so: import * as firebase from ‘firebase/app’, but it’s not compatible with our esm builds which only have a default export.

    If you manually configure the bundler to use our esm build (e.g. using the module field or the esm2017 field), you will get an error. For example, you will get the following error with webpack:
    "export 'initializeApp' (imported as 'firebase') was not found in 'firebase/app'

    This change allows developers to use any of our builds without resorting to hacks.

packages/component/rollup.config.js Show resolved Hide resolved
packages/rxfire/package.json Outdated Show resolved Hide resolved
@hsubox76
Copy link
Contributor

hsubox76 commented Oct 13, 2020

I think you have to change this line:

{ file: pkg.browser, format: 'cjs', sourcemap: true },

to point to pkg.main or else you make a weird corrupted esm file which is causing the CI build to fail.

There could possibly be a similar issue in some of the other rollup config files.

@Feiyang1
Copy link
Member Author

I think you have to change this line:

{ file: pkg.browser, format: 'cjs', sourcemap: true },

to point to pkg.main or else you make a weird corrupted esm file which is causing the CI build to fail.
There could possibly be a similar issue in some of the other rollup config files.

Good catch. Updated

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2020

🦋 Changeset detected

Latest commit: 1cf00d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@firebase/app Patch
@firebase/auth Patch
@firebase/component Patch
@firebase/database Patch
firebase Major
@firebase/firestore Patch
@firebase/functions Patch
@firebase/performance Patch
@firebase/remote-config Patch
rxfire Major
@firebase/util Patch
@firebase/analytics Patch
@firebase/installations Patch
@firebase/messaging Patch
@firebase/storage Patch
@firebase/rules-unit-testing Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2020

Changeset File Check ⚠️

Warning: This PR modifies files in the following packages but they have not been included in the changeset file:

  • @firebase/rules-unit-testing
  • @firebase/template

Make sure this was intentional.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 13, 2020

Size Analysis Report

Affected Products

No changes between base commit (b6a9bf0) and head commit (ae82d9a).

Test Logs

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 14, 2020

Binary Size Report

Affected SDKs

  • @firebase/app

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 11.1 kB 11.0 kB -97 B (-0.9%)
  • @firebase/auth

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 179 kB 179 kB -10 B (-0.0%)
  • @firebase/component

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 5.30 kB 5.18 kB -115 B (-2.2%)
  • @firebase/database

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 270 kB 269 kB -1.60 kB (-0.6%)
  • @firebase/firestore

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 249 kB 247 kB -2.59 kB (-1.0%)
  • @firebase/firestore/memory

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 186 kB 184 kB -1.96 kB (-1.1%)
  • @firebase/functions

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 10.1 kB 9.87 kB -268 B (-2.6%)
  • @firebase/performance

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 27.8 kB 27.6 kB -269 B (-1.0%)
  • @firebase/remote-config

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 22.8 kB 22.4 kB -421 B (-1.8%)
  • @firebase/rules-unit-testing

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    main 7.86 kB 8.00 kB +137 B (+1.7%)
  • @firebase/util

    Type Base (b6a9bf0) Head (ae82d9a) Diff
    browser 21.2 kB 20.1 kB -1.10 kB (-5.2%)

Test Logs

Copy link
Contributor

@hsubox76 hsubox76 left a comment

Choose a reason for hiding this comment

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

Approved pending CI tests.

@Feiyang1 Feiyang1 merged commit a5768b0 into master Oct 20, 2020
@Feiyang1 Feiyang1 deleted the fei-browser-esm branch October 20, 2020 16:39
import { _FirebaseApp } from '@firebase/app-types/private';
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
import * as request from 'request';
import { base64 } from '@firebase/util';
import { setLogLevel, LogLevel } from '@firebase/logger';
import { Component, ComponentType } from '@firebase/component';

export { database, firestore } from 'firebase';
const { firestore, database } = firebase;
export { firestore, database };
Copy link
Member Author

Choose a reason for hiding this comment

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

@samtstern @yuchenshi
Meant to ask you before merging the PR - How does developer use these two exports? Do they use the typings from them?
They won't get typings after this change because firestore and database are not namespaces anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe they're used to provide access to Firestore / RTDB classes like this:
https://github.com/firebase/firebase-js-sdk/blob/master/packages/rules-unit-testing/test/database.test.ts#L313

If those tests still pass I think we're fine? To be honest I don't quite understand namespaces.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that will continue to work. We are good. Thanks for confirming.

@google-oss-bot google-oss-bot mentioned this pull request Oct 22, 2020
@firebase firebase locked and limited conversation to collaborators Nov 20, 2020
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.

4 participants