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

Rollup JS files with rollup-typescript-plugin #8503

Open
wants to merge 1 commit into
base: v11
Choose a base branch
from

Conversation

dlarocque
Copy link
Contributor

The rollup-typescript-plugin does not transpile JS files using the TS compiler by default. This means that external dependencies that provide JS bundles will not be transpiled to the target ES version specified in the TypeScript config used by the plugin.
In other words, if one of our dependencies has a bundle that uses newer JS features that aren't supported in all browsers, it will be included in our bundle without being translated into an older JS version that we promise our bundles are compatible with.

This resulted in one of our dependencies (https://github.com/jakearchibald/idb) being included in the CDN bundles without being transpiled to ES5 (the target ES version). Since this dependencies bundle uses ES2018 syntax (object spread operator { ...x }), this upgraded our CDN bundles' minimum ES version requirement to ES2018 which isn't compatible with older browser versions. To see the ES2018 syntax in one of the CDN bundles, see https://www.gstatic.com/firebasejs/10.13.1/firebase-app.js and search for ...oldTraps.

After enabling allowJs in the typescript plugin CDN config, this ES2018 code now gets transpiled into ES5 code.

I verified the bundle is now es5 compliant by using ESLint Playground.

@dlarocque dlarocque requested a review from a team as a code owner September 16, 2024 18:47
Copy link

changeset-bot bot commented Sep 16, 2024

⚠️ No Changeset found

Latest commit: dc115a2

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 16, 2024

Size Report 1

Affected Products

  • firebase

    17 size changes

    TypeBase (a377fb2)Merge (0ccfec9)Diff
    firebase-analytics.js29.7 kB41.9 kB+12.2 kB (+41.1%)
    firebase-app-check.js25.0 kB33.0 kB+8.00 kB (+31.9%)
    firebase-app.js103 kB125 kB+22.2 kB (+21.6%)
    firebase-auth-cordova.js177 kB179 kB+1.85 kB (+1.0%)
    firebase-auth-web-extension.js117 kB154 kB+36.9 kB (+31.6%)
    firebase-auth.js151 kB199 kB+48.0 kB (+31.9%)
    firebase-database.js186 kB210 kB+23.5 kB (+12.6%)
    firebase-firestore-lite.js119 kB143 kB+24.0 kB (+20.3%)
    firebase-firestore.js440 kB527 kB+86.4 kB (+19.6%)
    firebase-functions.js12.0 kB16.3 kB+4.34 kB (+36.2%)
    firebase-installations.js15.1 kB22.6 kB+7.48 kB (+49.4%)
    firebase-messaging-sw.js30.2 kB41.3 kB+11.1 kB (+36.9%)
    firebase-messaging.js28.7 kB40.0 kB+11.3 kB (+39.3%)
    firebase-performance.js35.0 kB44.5 kB+9.46 kB (+27.0%)
    firebase-remote-config.js29.6 kB41.6 kB+12.0 kB (+40.7%)
    firebase-storage.js46.2 kB52.5 kB+6.26 kB (+13.5%)
    firebase-vertexai-preview.js19.6 kB25.1 kB+5.47 kB (+28.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/gAIwE0fwMR.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 16, 2024

The rollup-typescript-plugin does not transpile JS files using the TS
compiler by default. This means that external dependencies that provide
JS bundles will not be transpiled to the target ES version specified in
the TypeScript config used by the plugin.

This resulted in one of our dependencies (https://github.com/jakearchibald/idb)
being included in the CDN bundles without being transpiled to
ES5 (the target ES version). Since this dependencies bundle uses
ES2018 syntax (object spread operator `{ ...x }`), this upgraded our CDN
bundles' minimum ES version requirement to ES2018 which isn't compatible with older browser versions.
To see the ES2018 syntax in one of the CDN bundles, see
https://www.gstatic.com/firebasejs/10.13.1/firebase-app.js and search for `...oldTraps`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants