@@ -27,6 +27,7 @@ import json from '@rollup/plugin-json';
27
27
import pkg from '../package.json' ;
28
28
import compatPkg from './package.json' ;
29
29
import appPkg from './app/package.json' ;
30
+ import { emitModulePackageFile } from '../../../scripts/build/rollup_emit_module_package_file' ;
30
31
31
32
const external = Object . keys ( pkg . dependencies || { } ) ;
32
33
const uglifyOptions = {
@@ -92,7 +93,25 @@ const typescriptPluginCDN = rollupTypescriptPlugin({
92
93
*/
93
94
const appBuilds = [
94
95
/**
95
- * App Browser Builds
96
+ * App ESM Build
97
+ * Uses "type:module" in package.json to signal this is ESM.
98
+ * Allows the extension to remain '.js' as some tools do not recognize
99
+ * '.mjs'.
100
+ */
101
+ {
102
+ input : `${ __dirname } /app/index.ts` ,
103
+ output : [
104
+ {
105
+ file : resolve ( __dirname , 'app' , appPkg . browser ) ,
106
+ format : 'es' ,
107
+ sourcemap : true
108
+ }
109
+ ] ,
110
+ plugins : [ ...plugins , typescriptPlugin , emitModulePackageFile ( ) ] ,
111
+ external : id => external . some ( dep => id === dep || id . startsWith ( `${ dep } /` ) )
112
+ } ,
113
+ /**
114
+ * App CJS/MJS Builds
96
115
*/
97
116
{
98
117
input : `${ __dirname } /app/index.ts` ,
@@ -106,11 +125,6 @@ const appBuilds = [
106
125
file : resolve ( __dirname , 'app' , appPkg . main . replace ( '.cjs.js' , '.mjs' ) ) ,
107
126
format : 'es' ,
108
127
sourcemap : true
109
- } ,
110
- {
111
- file : resolve ( __dirname , 'app' , appPkg . browser ) ,
112
- format : 'es' ,
113
- sourcemap : true
114
128
}
115
129
] ,
116
130
plugins : [ ...plugins , typescriptPlugin ] ,
@@ -137,6 +151,28 @@ const componentBuilds = compatPkg.components
137
151
. map ( component => {
138
152
const pkg = require ( `${ __dirname } /${ component } /package.json` ) ;
139
153
return [
154
+ /**
155
+ * Component ESM build
156
+ * Uses "type:module" in package.json to signal this is ESM.
157
+ * Allows the extension to remain '.js' as some tools do not recognize
158
+ * '.mjs'.
159
+ */
160
+ {
161
+ input : `${ __dirname } /${ component } /index.ts` ,
162
+ output : [
163
+ {
164
+ file : resolve ( __dirname , component , pkg . browser ) ,
165
+ format : 'es' ,
166
+ sourcemap : true
167
+ }
168
+ ] ,
169
+ plugins : [ ...plugins , typescriptPlugin , emitModulePackageFile ( ) ] ,
170
+ external : id =>
171
+ external . some ( dep => id === dep || id . startsWith ( `${ dep } /` ) )
172
+ } ,
173
+ /**
174
+ * Component CJS/MJS builds
175
+ */
140
176
{
141
177
input : `${ __dirname } /${ component } /index.ts` ,
142
178
output : [
@@ -164,6 +200,9 @@ const componentBuilds = compatPkg.components
164
200
external : id =>
165
201
external . some ( dep => id === dep || id . startsWith ( `${ dep } /` ) )
166
202
} ,
203
+ /**
204
+ * Component UMD build
205
+ */
167
206
{
168
207
input : `${ __dirname } /${ component } /index.ts` ,
169
208
output : createUmdOutputConfig ( `firebase-${ component } -compat.js` ) ,
0 commit comments