Skip to content

Commit

Permalink
Add CJS browser entry points for all packages (#6981)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Jan 31, 2023
1 parent 27b5e7d commit 0bab0b7
Show file tree
Hide file tree
Showing 28 changed files with 393 additions and 56 deletions.
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

0 comments on commit 0bab0b7

Please sign in to comment.