Skip to content

Commit 0bab0b7

Browse files
authored
Add CJS browser entry points for all packages (#6981)
1 parent 27b5e7d commit 0bab0b7

28 files changed

+393
-56
lines changed

.changeset/ninety-taxis-study.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@firebase/auth': patch
3+
'@firebase/auth-compat': patch
4+
'@firebase/database': patch
5+
'@firebase/database-compat': patch
6+
'firebase': patch
7+
'@firebase/firestore': patch
8+
'@firebase/firestore-compat': patch
9+
'@firebase/functions': patch
10+
'@firebase/functions-compat': patch
11+
'@firebase/messaging': patch
12+
'@firebase/messaging-compat': patch
13+
'@firebase/rules-unit-testing': patch
14+
'@firebase/storage': patch
15+
'@firebase/template': patch
16+
'@firebase/util': patch
17+
---
18+
19+
Added browser CJS entry points (expected by Jest when using JSDOM mode).

packages/auth-compat/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
"require": "./dist/index.node.cjs.js"
1717
},
1818
"esm5": "./dist/index.esm.js",
19-
"default": "./dist/index.esm2017.js"
19+
"default": "./dist/index.esm2017.js",
20+
"browser": {
21+
"require": "./dist/index.cjs.js",
22+
"import": "./dist/index.esm2017.js"
23+
}
2024
},
2125
"./package.json": "./package.json"
2226
},

packages/auth-compat/rollup.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ const browserBuilds = [
7373
treeshake: {
7474
moduleSideEffects: false
7575
}
76+
},
77+
{
78+
input: 'index.ts',
79+
output: {
80+
file: 'dist/index.cjs.js',
81+
format: 'cjs',
82+
sourcemap: true
83+
},
84+
plugins: es2017BuildPlugins,
85+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
86+
treeshake: {
87+
moduleSideEffects: false
88+
}
7689
}
7790
];
7891

packages/auth/package.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
"default": "./dist/index.webworker.esm5.js"
3232
},
3333
"esm5": "./dist/esm5/index.js",
34-
"default": "./dist/esm2017/index.js"
34+
"default": "./dist/esm2017/index.js",
35+
"browser": {
36+
"require": "./dist/browser-cjs/index.js",
37+
"import": "./dist/esm2017/index.js"
38+
}
3539
},
3640
"./cordova": {
3741
"types": "./dist/cordova/index.cordova.d.ts",
@@ -57,7 +61,11 @@
5761
"default": "./dist/cordova/internal.js"
5862
},
5963
"esm5": "./dist/esm5/internal.js",
60-
"default": "./dist/esm2017/internal.js"
64+
"default": "./dist/esm2017/internal.js",
65+
"browser": {
66+
"require": "./dist/browser-cjs/internal.js",
67+
"import": "./dist/esm2017/internal.js"
68+
}
6169
},
6270
"./package.json": "./package.json"
6371
},

packages/auth/rollup.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ const browserBuilds = [
9797
replace(generateBuildTargetReplaceConfig('esm', 2017))
9898
],
9999
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
100+
},
101+
{
102+
input: {
103+
index: 'index.ts',
104+
internal: 'internal/index.ts'
105+
},
106+
output: [{ dir: 'dist/browser-cjs', format: 'cjs', sourcemap: true }],
107+
plugins: [
108+
...es2017BuildPlugins,
109+
replace(generateBuildTargetReplaceConfig('cjs', 2017))
110+
],
111+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
100112
}
101113
];
102114

packages/database-compat/package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
"require": "./dist/index.js"
2323
},
2424
"esm5": "./dist/index.esm5.js",
25-
"default": "./dist/index.esm2017.js"
25+
"default": "./dist/index.esm2017.js",
26+
"browser": {
27+
"require": "./dist/index.js",
28+
"import": "./dist/index.esm2017.js"
29+
}
2630
},
2731
"./standalone": {
2832
"types": "./dist/database-compat/src/index.standalone.d.ts",
@@ -64,4 +68,4 @@
6468
"bugs": {
6569
"url": "https://github.com/firebase/firebase-js-sdk/issues"
6670
}
67-
}
71+
}

packages/database/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
},
1818
"esm5": "./dist/index.esm5.js",
1919
"standalone": "./dist/index.standalone.js",
20-
"default": "./dist/index.esm2017.js"
20+
"default": "./dist/index.esm2017.js",
21+
"browser": {
22+
"require": "./dist/index.cjs.js",
23+
"import": "./dist/index.esm2017.js"
24+
}
2125
},
2226
"./package.json": "./package.json"
2327
},

packages/database/rollup.config.js

+19
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,25 @@ const browserBuilds = [
9494
},
9595
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
9696
onwarn: onWarn
97+
},
98+
{
99+
input: 'src/index.ts',
100+
output: [
101+
{
102+
file: 'dist/index.cjs.js',
103+
format: 'cjs',
104+
sourcemap: true
105+
}
106+
],
107+
plugins: [
108+
...es2017BuildPlugins,
109+
replace(generateBuildTargetReplaceConfig('cjs', 2017))
110+
],
111+
treeshake: {
112+
moduleSideEffects: false
113+
},
114+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
115+
onwarn: onWarn
97116
}
98117
];
99118

0 commit comments

Comments
 (0)