Skip to content

Commit a5768b0

Browse files
authored
Point browser field to esm build (#3932)
* point browser field to esm build * address comments * Create funny-ties-ring.md * fix build error in component * change from namespace export to default export * update changeset * fix firebase imports in rxfire * fix import for rules-unit-testing * fix testing * compile firebase pkgs to cjs so they can be stubbed in tests
1 parent eded218 commit a5768b0

45 files changed

Lines changed: 294 additions & 197 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/funny-ties-ring.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
"@firebase/app": patch
3+
"@firebase/auth": patch
4+
"@firebase/component": patch
5+
"@firebase/database": patch
6+
"firebase": major
7+
"@firebase/firestore": patch
8+
"@firebase/functions": patch
9+
"@firebase/performance": patch
10+
"@firebase/remote-config": patch
11+
"rxfire": patch
12+
"@firebase/util": patch
13+
---
14+
15+
Point browser field to esm build. Now you need to use default import instead of namespace import to import firebase.
16+
17+
Before this change
18+
```
19+
import * as firebase from 'firebase/app';
20+
```
21+
22+
After this change
23+
```
24+
import firebase from 'firebase/app';
25+
```

config/webpack.test.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,30 @@ module.exports = {
7474
]
7575
}
7676
}
77+
},
78+
{
79+
test: /\.js$/,
80+
include: function (modulePath) {
81+
const match = /node_modules\/@firebase.*/.test(modulePath);
82+
if (match) {
83+
console.log('modulePath', modulePath, match);
84+
}
85+
return match;
86+
},
87+
use: {
88+
loader: 'babel-loader',
89+
options: {
90+
plugins: ['@babel/plugin-transform-modules-commonjs']
91+
}
92+
}
7793
}
7894
]
7995
},
8096
resolve: {
8197
modules: ['node_modules', path.resolve(__dirname, '../../node_modules')],
82-
mainFields: ['browser', 'main', 'module'],
83-
extensions: ['.js', '.ts']
98+
mainFields: ['browser', 'module', 'main'],
99+
extensions: ['.js', '.ts'],
100+
symlinks: false
84101
},
85102
plugins: [
86103
new webpack.NormalModuleReplacementPlugin(

integration/firebase/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
},
99
"devDependencies": {
1010
"firebase": "7.24.0",
11-
"@babel/core": "7.11.6",
12-
"@babel/preset-env": "7.11.5",
1311
"@types/chai": "4.2.13",
1412
"@types/mocha": "7.0.2",
1513
"chai": "4.2.0",

integration/firebase/test/namespace.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firebase from 'firebase';
18+
import firebase from 'firebase';
1919
import * as namespaceDefinition from './namespaceDefinition.json';
2020
import validateNamespace from './validator';
2121

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
"@typescript-eslint/eslint-plugin-tslint": "4.4.1",
8888
"@typescript-eslint/parser": "4.4.1",
8989
"babel-loader": "8.1.0",
90+
"@babel/core": "7.11.6",
91+
"@babel/preset-env": "7.11.5",
92+
"@babel/plugin-transform-modules-commonjs": "7.12.1",
9093
"chai": "4.2.0",
9194
"chai-as-promised": "7.1.1",
9295
"chalk": "4.1.0",

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
66
"main": "dist/index.node.cjs.js",
7-
"browser": "dist/index.cjs.js",
7+
"browser": "dist/index.esm.js",
88
"module": "dist/index.esm.js",
99
"react-native": "dist/index.rn.cjs.js",
1010
"esm2017": "dist/index.esm2017.js",

packages/app/rollup.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ const es5BuildPlugins = [
3737
const es5Builds = [
3838
{
3939
input: 'index.ts',
40-
output: [
41-
{ file: pkg.browser, format: 'cjs', sourcemap: true },
42-
{ file: pkg.module, format: 'es', sourcemap: true }
43-
],
40+
output: [{ file: pkg.module, format: 'es', sourcemap: true }],
4441
plugins: es5BuildPlugins,
4542
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
4643
},

packages/auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@firebase/auth",
33
"version": "0.15.0",
44
"main": "dist/auth.js",
5-
"browser": "dist/auth.js",
5+
"browser": "dist/auth.esm.js",
66
"module": "dist/auth.esm.js",
77
"description": "Javascript library for Firebase Auth SDK",
88
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",

packages/component/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Firebase Component Platform",
55
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
66
"main": "dist/index.cjs.js",
7-
"browser": "dist/index.cjs.js",
7+
"browser": "dist/index.esm.js",
88
"module": "dist/index.esm.js",
99
"esm2017": "dist/index.esm2017.js",
1010
"files": ["dist"],

packages/component/rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2018 Google Inc.
3+
* Copyright 2018 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ const es5Builds = [
3939
{
4040
input: 'index.ts',
4141
output: [
42-
{ file: pkg.browser, format: 'cjs', sourcemap: true },
42+
{ file: pkg.main, format: 'cjs', sourcemap: true },
4343
{ file: pkg.module, format: 'es', sourcemap: true }
4444
],
4545
plugins: es5BuildPlugins,

0 commit comments

Comments
 (0)