From 1d80dc5bebfc597a5f9412a00e4a81a88272d7cc Mon Sep 17 00:00:00 2001 From: Feiyang1 Date: Mon, 23 Aug 2021 00:09:21 -0700 Subject: [PATCH] firebase packaging update --- packages/firebase/analytics/package.json | 7 +- packages/firebase/app-check/package.json | 7 +- packages/firebase/app/package.json | 7 +- packages/firebase/auth/cordova/package.json | 7 +- packages/firebase/auth/package.json | 7 +- .../firebase/auth/react-native/package.json | 7 +- .../firebase/compat/analytics/package.json | 7 +- .../firebase/compat/app-check/package.json | 7 +- packages/firebase/compat/app/package.json | 7 +- packages/firebase/compat/auth/package.json | 7 +- .../firebase/compat/database/package.json | 7 +- .../firebase/compat/firestore/package.json | 7 +- .../firebase/compat/functions/package.json | 7 +- .../firebase/compat/messaging/package.json | 7 +- packages/firebase/compat/package.json | 5 +- .../firebase/compat/performance/package.json | 7 +- .../compat/remote-config/package.json | 7 +- packages/firebase/compat/rollup.config.js | 10 ++ packages/firebase/compat/storage/package.json | 7 +- packages/firebase/database/package.json | 7 +- packages/firebase/firestore/lite/package.json | 7 +- packages/firebase/firestore/package.json | 7 +- packages/firebase/functions/package.json | 7 +- packages/firebase/gulpfile.js | 10 +- packages/firebase/messaging/package.json | 7 +- packages/firebase/messaging/sw/package.json | 7 +- packages/firebase/package.json | 112 +++++++++--------- packages/firebase/performance/package.json | 7 +- packages/firebase/remote-config/package.json | 7 +- packages/firebase/rollup.config.js | 19 ++- packages/firebase/storage/package.json | 7 +- 31 files changed, 160 insertions(+), 178 deletions(-) diff --git a/packages/firebase/analytics/package.json b/packages/firebase/analytics/package.json index 550bb265552..bcfe70fc0d2 100644 --- a/packages/firebase/analytics/package.json +++ b/packages/firebase/analytics/package.json @@ -1,8 +1,7 @@ { "name": "firebase/analytics", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/analytics/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/analytics/index.d.ts" } diff --git a/packages/firebase/app-check/package.json b/packages/firebase/app-check/package.json index 1c81301e5a3..b9a0a2ac09d 100644 --- a/packages/firebase/app-check/package.json +++ b/packages/firebase/app-check/package.json @@ -1,8 +1,7 @@ { "name": "firebase/app-check", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/app-check/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/app-check/index.d.ts" } diff --git a/packages/firebase/app/package.json b/packages/firebase/app/package.json index dc00f289841..8ef6c1b65f8 100644 --- a/packages/firebase/app/package.json +++ b/packages/firebase/app/package.json @@ -1,8 +1,7 @@ { "name": "firebase/app", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/app/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/app/index.d.ts" } diff --git a/packages/firebase/auth/cordova/package.json b/packages/firebase/auth/cordova/package.json index 686bc4300c4..07f80b5e21d 100644 --- a/packages/firebase/auth/cordova/package.json +++ b/packages/firebase/auth/cordova/package.json @@ -1,8 +1,7 @@ { "name": "firebase/auth/cordova", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/auth/cordova/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/auth/cordova/index.d.ts" } diff --git a/packages/firebase/auth/package.json b/packages/firebase/auth/package.json index 83c7fe70e3e..0494c105c0c 100644 --- a/packages/firebase/auth/package.json +++ b/packages/firebase/auth/package.json @@ -1,8 +1,7 @@ { "name": "firebase/auth", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/auth/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/auth/index.d.ts" } diff --git a/packages/firebase/auth/react-native/package.json b/packages/firebase/auth/react-native/package.json index 95b4084a37e..a7b7dd06927 100644 --- a/packages/firebase/auth/react-native/package.json +++ b/packages/firebase/auth/react-native/package.json @@ -1,8 +1,7 @@ { "name": "firebase/auth/react-native", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/auth/react-native/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/auth/react-native/index.d.ts" } diff --git a/packages/firebase/compat/analytics/package.json b/packages/firebase/compat/analytics/package.json index 07373b84631..b706bfd1fc8 100644 --- a/packages/firebase/compat/analytics/package.json +++ b/packages/firebase/compat/analytics/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/analytics", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/analytics/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/analytics/index.d.ts" } diff --git a/packages/firebase/compat/app-check/package.json b/packages/firebase/compat/app-check/package.json index 7904521fc99..86df945618e 100644 --- a/packages/firebase/compat/app-check/package.json +++ b/packages/firebase/compat/app-check/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/app-check", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/app-check/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/app-check/index.d.ts" } diff --git a/packages/firebase/compat/app/package.json b/packages/firebase/compat/app/package.json index e55dac364fe..b278dbff3cc 100644 --- a/packages/firebase/compat/app/package.json +++ b/packages/firebase/compat/app/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/app", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "../index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "../index.d.ts" } diff --git a/packages/firebase/compat/auth/package.json b/packages/firebase/compat/auth/package.json index 50416407386..159972bf0d8 100644 --- a/packages/firebase/compat/auth/package.json +++ b/packages/firebase/compat/auth/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/auth", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/auth/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/auth/index.d.ts" } diff --git a/packages/firebase/compat/database/package.json b/packages/firebase/compat/database/package.json index 9dacd0d324c..0416f7df69a 100644 --- a/packages/firebase/compat/database/package.json +++ b/packages/firebase/compat/database/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/database", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/database/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/database/index.d.ts" } diff --git a/packages/firebase/compat/firestore/package.json b/packages/firebase/compat/firestore/package.json index 754ca99b6b6..18e99843db0 100644 --- a/packages/firebase/compat/firestore/package.json +++ b/packages/firebase/compat/firestore/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/firestore", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/firestore/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/firestore/index.d.ts" } diff --git a/packages/firebase/compat/functions/package.json b/packages/firebase/compat/functions/package.json index b312f2a25b6..07db9c7e610 100644 --- a/packages/firebase/compat/functions/package.json +++ b/packages/firebase/compat/functions/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/functions", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/functions/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/functions/index.d.ts" } diff --git a/packages/firebase/compat/messaging/package.json b/packages/firebase/compat/messaging/package.json index e5c27be90c4..73012e00e38 100644 --- a/packages/firebase/compat/messaging/package.json +++ b/packages/firebase/compat/messaging/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/messaging", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/messaging/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/messaging/index.d.ts" } diff --git a/packages/firebase/compat/package.json b/packages/firebase/compat/package.json index beb8da3a722..506355d8228 100644 --- a/packages/firebase/compat/package.json +++ b/packages/firebase/compat/package.json @@ -2,7 +2,7 @@ "name": "firebase/compat", "main": "dist/index.node.cjs", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", + "module": "dist/index.mjs", "react-native": "dist/index.rn.cjs.js", "typings": "index.d.ts", "components": [ @@ -17,6 +17,5 @@ "firestore", "storage", "database" - ], - "type": "module" + ] } diff --git a/packages/firebase/compat/performance/package.json b/packages/firebase/compat/performance/package.json index 351172acf38..257467d57e8 100644 --- a/packages/firebase/compat/performance/package.json +++ b/packages/firebase/compat/performance/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/performance", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/performance/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/performance/index.d.ts" } diff --git a/packages/firebase/compat/remote-config/package.json b/packages/firebase/compat/remote-config/package.json index 7ea8984ff67..e002a4b5470 100644 --- a/packages/firebase/compat/remote-config/package.json +++ b/packages/firebase/compat/remote-config/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/remote-config", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/remote-config/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/remote-config/index.d.ts" } diff --git a/packages/firebase/compat/rollup.config.js b/packages/firebase/compat/rollup.config.js index 8d79a937e04..c181cb50f82 100644 --- a/packages/firebase/compat/rollup.config.js +++ b/packages/firebase/compat/rollup.config.js @@ -102,6 +102,11 @@ const appBuilds = [ file: resolve(__dirname, 'app', appPkg.module), format: 'es', sourcemap: true + }, + { + file: resolve(__dirname, 'app', appPkg.browser), + format: 'es', + sourcemap: true } ], plugins: [...plugins, typescriptPlugin], @@ -140,6 +145,11 @@ const componentBuilds = compatPkg.components file: resolve(__dirname, component, pkg.module), format: 'es', sourcemap: true + }, + { + file: resolve(__dirname, component, pkg.browser), + format: 'es', + sourcemap: true } ], plugins: [...plugins, typescriptPlugin], diff --git a/packages/firebase/compat/storage/package.json b/packages/firebase/compat/storage/package.json index 0868deb2b98..4c2fb502e9d 100644 --- a/packages/firebase/compat/storage/package.json +++ b/packages/firebase/compat/storage/package.json @@ -1,8 +1,7 @@ { "name": "firebase/compat/storage", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/compat/storage/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/compat/storage/index.d.ts" } diff --git a/packages/firebase/database/package.json b/packages/firebase/database/package.json index 9b3cab9a936..9c332d35149 100644 --- a/packages/firebase/database/package.json +++ b/packages/firebase/database/package.json @@ -1,8 +1,7 @@ { "name": "firebase/database", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/database/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/database/index.d.ts" } diff --git a/packages/firebase/firestore/lite/package.json b/packages/firebase/firestore/lite/package.json index e1c35ac46f4..bd35527030d 100644 --- a/packages/firebase/firestore/lite/package.json +++ b/packages/firebase/firestore/lite/package.json @@ -1,8 +1,7 @@ { "name": "firebase/firestore/lite", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/firestore/lite/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/firestore/lite/index.d.ts" } diff --git a/packages/firebase/firestore/package.json b/packages/firebase/firestore/package.json index fb322ca585f..b7e10c3858a 100644 --- a/packages/firebase/firestore/package.json +++ b/packages/firebase/firestore/package.json @@ -1,8 +1,7 @@ { "name": "firebase/firestore", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/firestore/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/firestore/index.d.ts" } diff --git a/packages/firebase/functions/package.json b/packages/firebase/functions/package.json index 1b913d52a71..410b6de33bb 100644 --- a/packages/firebase/functions/package.json +++ b/packages/firebase/functions/package.json @@ -1,8 +1,7 @@ { "name": "firebase/functions", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/functions/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/functions/index.d.ts" } diff --git a/packages/firebase/gulpfile.js b/packages/firebase/gulpfile.js index a2ceb544e81..0590d9bc9fb 100644 --- a/packages/firebase/gulpfile.js +++ b/packages/firebase/gulpfile.js @@ -16,21 +16,23 @@ */ var gulp = require('gulp'); -var concat = require('gulp-concat'); var sourcemaps = require('gulp-sourcemaps'); +const replace = require('gulp-replace'); -const OUTPUT_FILE = 'firebase.js'; const pkgJson = require('./package.json'); const files = pkgJson.components.map(component => { const componentName = component.replace('/', '-'); return `firebase-${componentName}.js`; }); +const FIREBASE_APP_URL = `https://www.gstatic.com/firebasejs/${pkgJson.version}/firebase-app.js`; -gulp.task('firebase-js', function () { +gulp.task('cdn-type-module-path', function () { return gulp .src(files) .pipe(sourcemaps.init({ loadMaps: true })) - .pipe(concat(OUTPUT_FILE)) + // gulp-replace doesn't work with gulp-sourcemaps, so no change is made to the existing sourcemap. + // Therefore the sourcemap become slightly inaccurate + .pipe(replace('@firebase/app', FIREBASE_APP_URL)) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('.')); }); diff --git a/packages/firebase/messaging/package.json b/packages/firebase/messaging/package.json index e206ec9be75..c2bdf639a9e 100644 --- a/packages/firebase/messaging/package.json +++ b/packages/firebase/messaging/package.json @@ -1,8 +1,7 @@ { "name": "firebase/messaging", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/messaging/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/messaging/index.d.ts" } diff --git a/packages/firebase/messaging/sw/package.json b/packages/firebase/messaging/sw/package.json index 6824d4346aa..df859452d6a 100644 --- a/packages/firebase/messaging/sw/package.json +++ b/packages/firebase/messaging/sw/package.json @@ -1,8 +1,7 @@ { "name": "firebase/messaging/sw", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/messaging/sw/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/messaging/sw/index.d.ts" } diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 27833677549..7864a6ebb2d 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -25,183 +25,183 @@ "exports": { "./analytics": { "node": { - "require": "./analytics/dist/index.cjs", - "import": "./analytics/dist/index.esm.js" + "require": "./analytics/dist/index.cjs.js", + "import": "./analytics/dist/index.mjs" }, "default": "./analytics/dist/index.esm.js" }, "./app": { "node": { - "require": "./app/dist/index.cjs", - "import": "./app/dist/index.esm.js" + "require": "./app/dist/index.cjs.js", + "import": "./app/dist/index.mjs" }, "default": "./app/dist/index.esm.js" }, "./app-check": { "node": { - "require": "./app-check/dist/index.cjs", - "import": "./app-check/dist/index.esm.js" + "require": "./app-check/dist/index.cjs.js", + "import": "./app-check/dist/index.mjs" }, "default": "./app-check/dist/index.esm.js" }, "./auth": { "node": { - "require": "./auth/dist/index.cjs", - "import": "./auth/dist/index.esm.js" + "require": "./auth/dist/index.cjs.js", + "import": "./auth/dist/index.mjs" }, "default": "./auth/dist/index.esm.js" }, "./auth/cordova": { "node": { - "require": "./auth/cordova/dist/index.cjs", - "import": "./auth/cordova/dist/index.esm.js" + "require": "./auth/cordova/dist/index.cjs.js", + "import": "./auth/cordova/dist/index.mjs" }, "default": "./auth/cordova/dist/index.esm.js" }, "./auth/react-native": { "node": { - "require": "./auth/react-native/dist/index.cjs", - "import": "./auth/react-native/dist/index.esm.js" + "require": "./auth/react-native/dist/index.cjs.js", + "import": "./auth/react-native/dist/index.mjs" }, "default": "./auth/react-native/dist/index.esm.js" }, "./database": { "node": { - "require": "./database/dist/index.cjs", - "import": "./database/dist/index.esm.js" + "require": "./database/dist/index.cjs.js", + "import": "./database/dist/index.mjs" }, "default": "./database/dist/index.esm.js" }, "./firestore": { "node": { - "require": "./firestore/dist/index.cjs", - "import": "./firestore/dist/index.esm.js" + "require": "./firestore/dist/index.cjs.js", + "import": "./firestore/dist/index.mjs" }, "default": "./firestore/dist/index.esm.js" }, "./firestore/lite": { "node": { - "require": "./firestore/lite/dist/index.cjs", - "import": "./firestore/lite/dist/index.esm.js" + "require": "./firestore/lite/dist/index.cjs.js", + "import": "./firestore/lite/dist/index.mjs" }, "default": "./firestore/lite/dist/index.esm.js" }, "./functions": { "node": { - "require": "./functions/dist/index.cjs", - "import": "./functions/dist/index.esm.js" + "require": "./functions/dist/index.cjs.js", + "import": "./functions/dist/index.mjs" }, "default": "./functions/dist/index.esm.js" }, "./messaging": { "node": { - "require": "./messaging/dist/index.cjs", - "import": "./messaging/dist/index.esm.js" + "require": "./messaging/dist/index.cjs.js", + "import": "./messaging/dist/index.mjs" }, "default": "./messaging/dist/index.esm.js" }, "./messaging/sw": { "node": { - "require": "./messaging/sw/dist/index.cjs", - "import": "./messaging/sw/dist/index.esm.js" + "require": "./messaging/sw/dist/index.cjs.js", + "import": "./messaging/sw/dist/index.mjs" }, "default": "./messaging/sw/dist/index.esm.js" }, "./performance": { "node": { - "require": "./performance/dist/index.cjs", - "import": "./performance/dist/index.esm.js" + "require": "./performance/dist/index.cjs.js", + "import": "./performance/dist/index.mjs" }, "default": "./performance/dist/index.esm.js" }, "./remote-config": { "node": { - "require": "./remote-config/dist/index.cjs", - "import": "./remote-config/dist/index.esm.js" + "require": "./remote-config/dist/index.cjs.js", + "import": "./remote-config/dist/index.mjs" }, "default": "./remote-config/dist/index.esm.js" }, "./storage": { "node": { - "require": "./storage/dist/index.cjs", - "import": "./storage/dist/index.esm.js" + "require": "./storage/dist/index.cjs.js", + "import": "./storage/dist/index.mjs" }, "default": "./storage/dist/index.esm.js" }, "./compat/analytics": { "node": { - "require": "./compat/analytics/dist/index.cjs", - "import": "./compat/analytics/dist/index.esm.js" + "require": "./compat/analytics/dist/index.cjs.js", + "import": "./compat/analytics/dist/index.mjs" }, "default": "./compat/analytics/dist/index.esm.js" }, "./compat/app": { "node": { - "require": "./compat/app/dist/index.cjs", - "import": "./compat/app/dist/index.esm.js" + "require": "./compat/app/dist/index.cjs.js", + "import": "./compat/app/dist/index.mjs" }, "default": "./compat/app/dist/index.esm.js" }, "./compat/app-check": { "node": { - "require": "./compat/app-check/dist/index.cjs", - "import": "./compat/app-check/dist/index.esm.js" + "require": "./compat/app-check/dist/index.cjs.js", + "import": "./compat/app-check/dist/index.mjs" }, "default": "./compat/app-check/dist/index.esm.js" }, "./compat/auth": { "node": { - "require": "./compat/auth/dist/index.cjs", - "import": "./compat/auth/dist/index.esm.js" + "require": "./compat/auth/dist/index.cjs.js", + "import": "./compat/auth/dist/index.mjs" }, "default": "./compat/auth/dist/index.esm.js" }, "./compat/database": { "node": { - "require": "./compat/database/dist/index.cjs", - "import": "./compat/database/dist/index.esm.js" + "require": "./compat/database/dist/index.cjs.js", + "import": "./compat/database/dist/index.mjs" }, "default": "./compat/database/dist/index.esm.js" }, "./compat/firestore": { "node": { - "require": "./compat/firestore/dist/index.cjs", - "import": "./compat/firestore/dist/index.esm.js" + "require": "./compat/firestore/dist/index.cjs.js", + "import": "./compat/firestore/dist/index.mjs" }, "default": "./compat/firestore/dist/index.esm.js" }, "./compat/functions": { "node": { - "require": "./compat/functions/dist/index.cjs", - "import": "./compat/functions/dist/index.esm.js" + "require": "./compat/functions/dist/index.cjs.js", + "import": "./compat/functions/dist/index.mjs" }, "default": "./compat/functions/dist/index.esm.js" }, "./compat/messaging": { "node": { - "require": "./compat/messaging/dist/index.cjs", - "import": "./compat/messaging/dist/index.esm.js" + "require": "./compat/messaging/dist/index.cjs.js", + "import": "./compat/messaging/dist/index.mjs" }, "default": "./compat/messaging/dist/index.esm.js" }, "./compat/performance": { "node": { - "require": "./compat/performance/dist/index.cjs", - "import": "./compat/performance/dist/index.esm.js" + "require": "./compat/performance/dist/index.cjs.js", + "import": "./compat/performance/dist/index.mjs" }, "default": "./compat/performance/dist/index.esm.js" }, "./compat/remote-config": { "node": { - "require": "./compat/remote-config/dist/index.cjs", - "import": "./compat/remote-config/dist/index.esm.js" + "require": "./compat/remote-config/dist/index.cjs.js", + "import": "./compat/remote-config/dist/index.mjs" }, "default": "./compat/remote-config/dist/index.esm.js" }, "./compat/storage": { "node": { - "require": "./compat/storage/dist/index.cjs", - "import": "./compat/storage/dist/index.esm.js" + "require": "./compat/storage/dist/index.cjs.js", + "import": "./compat/storage/dist/index.mjs" }, "default": "./compat/storage/dist/index.esm.js" } @@ -211,7 +211,7 @@ "url": "https://github.com/firebase/firebase-js-sdk.git" }, "scripts": { - "build": "rollup -c && yarn build:compat", + "build": "rollup -c && gulp cdn-type-module-path && yarn build:compat", "build:compat": "rollup -c compat/rollup.config.js", "dev": "rollup -c -w", "test": "echo 'No test suite for firebase wrapper'", @@ -253,10 +253,9 @@ "rollup-plugin-terser": "7.0.2", "rollup-plugin-typescript2": "0.30.0", "rollup-plugin-uglify": "6.0.4", - "@rollup/plugin-alias": "3.1.2", "gulp": "4.0.2", "gulp-sourcemaps": "3.0.0", - "gulp-concat": "2.6.1", + "gulp-replace": "1.1.3", "typescript": "4.2.2" }, "components": [ @@ -275,6 +274,5 @@ "messaging", "messaging/sw", "database" - ], - "type": "module" + ] } diff --git a/packages/firebase/performance/package.json b/packages/firebase/performance/package.json index c20ae856de6..de3d9c555eb 100644 --- a/packages/firebase/performance/package.json +++ b/packages/firebase/performance/package.json @@ -1,8 +1,7 @@ { "name": "firebase/performance", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/performance/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/performance/index.d.ts" } diff --git a/packages/firebase/remote-config/package.json b/packages/firebase/remote-config/package.json index 9d33a5d720d..43b0dd4b3ac 100644 --- a/packages/firebase/remote-config/package.json +++ b/packages/firebase/remote-config/package.json @@ -1,8 +1,7 @@ { "name": "firebase/remote-config", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/remote-config/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/remote-config/index.d.ts" } diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index b6bb30082fa..de926c8b3f2 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -24,7 +24,6 @@ import resolveModule from '@rollup/plugin-node-resolve'; import rollupTypescriptPlugin from 'rollup-plugin-typescript2'; import sourcemaps from 'rollup-plugin-sourcemaps'; import typescript from 'typescript'; -import alias from '@rollup/plugin-alias'; const external = Object.keys(pkg.dependencies || {}); const plugins = [sourcemaps(), resolveModule(), json(), commonjs()]; @@ -53,7 +52,8 @@ const appBuilds = [ input: 'app/index.ts', output: [ { file: resolve('app', appPkg.main), format: 'cjs', sourcemap: true }, - { file: resolve('app', appPkg.module), format: 'es', sourcemap: true } + { file: resolve('app', appPkg.module), format: 'es', sourcemap: true }, + { file: resolve('app', appPkg.browser), format: 'es', sourcemap: true } ], plugins: [...plugins, typescriptPlugin], external: id => external.some(dep => id === dep || id.startsWith(`${dep}/`)) @@ -78,6 +78,11 @@ const componentBuilds = pkg.components file: resolve(component, pkg.module), format: 'es', sourcemap: true + }, + { + file: resolve(component, pkg.browser), + format: 'es', + sourcemap: true } ], plugins: [...plugins, typescriptPlugin], @@ -90,7 +95,6 @@ const componentBuilds = pkg.components /** * CDN script builds */ -const FIREBASE_APP_URL = `https://www.gstatic.com/firebasejs/${pkg.version}/firebase-app.js`; const cdnBuilds = [ { input: 'app/index.cdn.ts', @@ -117,14 +121,9 @@ const cdnBuilds = [ }, plugins: [ ...plugins, - typescriptPluginCDN, - alias({ - entries: { - '@firebase/app': FIREBASE_APP_URL - } - }) + typescriptPluginCDN ], - external: [FIREBASE_APP_URL] + external: ['@firebase/app'] }; }) ]; diff --git a/packages/firebase/storage/package.json b/packages/firebase/storage/package.json index 564d5d96060..0f0affa9d46 100644 --- a/packages/firebase/storage/package.json +++ b/packages/firebase/storage/package.json @@ -1,8 +1,7 @@ { "name": "firebase/storage", - "main": "dist/index.cjs", + "main": "dist/index.cjs.js", "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "typings": "dist/storage/index.d.ts", - "type": "module" + "module": "dist/index.mjs", + "typings": "dist/storage/index.d.ts" }