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

Put firebase/* entry point ESM files in their own subdirs with "type: module" package.json #6826

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eighty-ants-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'firebase': patch
---

Modify entry point ESM bundles to conform to Node ESM specs.
6 changes: 3 additions & 3 deletions packages/firebase/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/analytics",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/analytics/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/app-check/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/app-check",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/app-check/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/app",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/app/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/auth/cordova/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/auth/cordova",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/auth/cordova/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/auth",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/auth/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/auth/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/auth/react-native",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/auth/react-native/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/analytics",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/analytics/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/app-check/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/app-check",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/app-check/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/app",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "../index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/auth",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/auth/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/database/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/database",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/database/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/firestore",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/firestore/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/functions/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/functions",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/functions/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/installations/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/installations",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/installations/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/messaging",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/messaging/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "firebase/compat",
"main": "dist/index.node.cjs",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"react-native": "dist/index.rn.cjs.js",
"typings": "index.d.ts",
"components": [
Expand All @@ -19,4 +19,4 @@
"storage",
"database"
]
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/performance/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/performance",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/performance/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/compat/remote-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/remote-config",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/remote-config/index.d.ts"
}
}
51 changes: 45 additions & 6 deletions packages/firebase/compat/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import json from '@rollup/plugin-json';
import pkg from '../package.json';
import compatPkg from './package.json';
import appPkg from './app/package.json';
import { emitModulePackageFile } from '../../../scripts/build/rollup_emit_module_package_file';

const external = Object.keys(pkg.dependencies || {});
const uglifyOptions = {
Expand Down Expand Up @@ -92,7 +93,25 @@ const typescriptPluginCDN = rollupTypescriptPlugin({
*/
const appBuilds = [
/**
* App Browser Builds
* App ESM Build
* Uses "type:module" in package.json to signal this is ESM.
* Allows the extension to remain '.js' as some tools do not recognize
* '.mjs'.
*/
{
input: `${__dirname}/app/index.ts`,
output: [
{
file: resolve(__dirname, 'app', appPkg.browser),
format: 'es',
sourcemap: true
}
],
plugins: [...plugins, typescriptPlugin, emitModulePackageFile()],
external: id => external.some(dep => id === dep || id.startsWith(`${dep}/`))
},
/**
* App CJS/MJS Builds
*/
{
input: `${__dirname}/app/index.ts`,
Expand All @@ -106,11 +125,6 @@ const appBuilds = [
file: resolve(__dirname, 'app', appPkg.main.replace('.cjs.js', '.mjs')),
format: 'es',
sourcemap: true
},
{
file: resolve(__dirname, 'app', appPkg.browser),
format: 'es',
sourcemap: true
}
],
plugins: [...plugins, typescriptPlugin],
Expand All @@ -137,6 +151,28 @@ const componentBuilds = compatPkg.components
.map(component => {
const pkg = require(`${__dirname}/${component}/package.json`);
return [
/**
* Component ESM build
* Uses "type:module" in package.json to signal this is ESM.
* Allows the extension to remain '.js' as some tools do not recognize
* '.mjs'.
*/
{
input: `${__dirname}/${component}/index.ts`,
output: [
{
file: resolve(__dirname, component, pkg.browser),
format: 'es',
sourcemap: true
}
],
plugins: [...plugins, typescriptPlugin, emitModulePackageFile()],
external: id =>
external.some(dep => id === dep || id.startsWith(`${dep}/`))
},
/**
* Component CJS/MJS builds
*/
{
input: `${__dirname}/${component}/index.ts`,
output: [
Expand Down Expand Up @@ -164,6 +200,9 @@ const componentBuilds = compatPkg.components
external: id =>
external.some(dep => id === dep || id.startsWith(`${dep}/`))
},
/**
* Component UMD build
*/
{
input: `${__dirname}/${component}/index.ts`,
output: createUmdOutputConfig(`firebase-${component}-compat.js`),
Expand Down
6 changes: 3 additions & 3 deletions packages/firebase/compat/storage/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/compat/storage",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/compat/storage/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/database/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/database",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/database/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/firestore/lite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/firestore/lite",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/firestore/lite/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/firestore",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/firestore/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/functions/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/functions",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/functions/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/installations/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/installations",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/installations/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions packages/firebase/messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase/messaging",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"browser": "dist/esm/index.esm.js",
"module": "dist/esm/index.esm.js",
"typings": "dist/messaging/index.d.ts"
}
}
Loading