Skip to content

Add CJS browser entry points for all packages #6981

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 6 commits into from
Jan 31, 2023
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
19 changes: 19 additions & 0 deletions .changeset/ninety-taxis-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@firebase/auth': patch
'@firebase/auth-compat': patch
'@firebase/database': patch
'@firebase/database-compat': patch
'firebase': patch
'@firebase/firestore': patch
'@firebase/firestore-compat': patch
'@firebase/functions': patch
'@firebase/functions-compat': patch
'@firebase/messaging': patch
'@firebase/messaging-compat': patch
'@firebase/rules-unit-testing': patch
'@firebase/storage': patch
'@firebase/template': patch
'@firebase/util': patch
---

Added browser CJS entry points (expected by Jest when using JSDOM mode).
6 changes: 5 additions & 1 deletion packages/auth-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
"require": "./dist/index.node.cjs.js"
},
"esm5": "./dist/index.esm.js",
"default": "./dist/index.esm2017.js"
"default": "./dist/index.esm2017.js",
"browser": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm2017.js"
}
},
"./package.json": "./package.json"
},
Expand Down
13 changes: 13 additions & 0 deletions packages/auth-compat/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ const browserBuilds = [
treeshake: {
moduleSideEffects: false
}
},
{
input: 'index.ts',
output: {
file: 'dist/index.cjs.js',
format: 'cjs',
sourcemap: true
},
plugins: es2017BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
treeshake: {
moduleSideEffects: false
}
}
];

Expand Down
12 changes: 10 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
"default": "./dist/index.webworker.esm5.js"
},
"esm5": "./dist/esm5/index.js",
"default": "./dist/esm2017/index.js"
"default": "./dist/esm2017/index.js",
"browser": {
"require": "./dist/browser-cjs/index.js",
"import": "./dist/esm2017/index.js"
}
},
"./cordova": {
"types": "./dist/cordova/index.cordova.d.ts",
Expand All @@ -57,7 +61,11 @@
"default": "./dist/cordova/internal.js"
},
"esm5": "./dist/esm5/internal.js",
"default": "./dist/esm2017/internal.js"
"default": "./dist/esm2017/internal.js",
"browser": {
"require": "./dist/browser-cjs/internal.js",
"import": "./dist/esm2017/internal.js"
}
},
"./package.json": "./package.json"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/auth/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ const browserBuilds = [
replace(generateBuildTargetReplaceConfig('esm', 2017))
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
{
input: {
index: 'index.ts',
internal: 'internal/index.ts'
},
output: [{ dir: 'dist/browser-cjs', format: 'cjs', sourcemap: true }],
plugins: [
...es2017BuildPlugins,
replace(generateBuildTargetReplaceConfig('cjs', 2017))
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

Expand Down
8 changes: 6 additions & 2 deletions packages/database-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
"require": "./dist/index.js"
},
"esm5": "./dist/index.esm5.js",
"default": "./dist/index.esm2017.js"
"default": "./dist/index.esm2017.js",
"browser": {
"require": "./dist/index.js",
"import": "./dist/index.esm2017.js"
}
},
"./standalone": {
"types": "./dist/database-compat/src/index.standalone.d.ts",
Expand Down Expand Up @@ -64,4 +68,4 @@
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
}
}
}
6 changes: 5 additions & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
},
"esm5": "./dist/index.esm5.js",
"standalone": "./dist/index.standalone.js",
"default": "./dist/index.esm2017.js"
"default": "./dist/index.esm2017.js",
"browser": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm2017.js"
}
},
"./package.json": "./package.json"
},
Expand Down
19 changes: 19 additions & 0 deletions packages/database/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ const browserBuilds = [
},
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
onwarn: onWarn
},
{
input: 'src/index.ts',
output: [
{
file: 'dist/index.cjs.js',
format: 'cjs',
sourcemap: true
}
],
plugins: [
...es2017BuildPlugins,
replace(generateBuildTargetReplaceConfig('cjs', 2017))
],
treeshake: {
moduleSideEffects: false
},
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
onwarn: onWarn
}
];

Expand Down
Loading