File tree 3 files changed +42
-5
lines changed
packages/webchannel-wrapper
3 files changed +42
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @firebase/webchannel-wrapper ' : patch
3
+ ---
4
+
5
+ Make webchannel-wrapper exports Node-ESM-friendly.
Original file line number Diff line number Diff line change @@ -26,6 +26,22 @@ const commonjs = require('@rollup/plugin-commonjs');
26
26
const rollupSourcemaps = require ( 'rollup-plugin-sourcemaps' ) ;
27
27
const typescriptPlugin = require ( 'rollup-plugin-typescript2' ) ;
28
28
const typescript = require ( 'typescript' ) ;
29
+ const pkg = require ( './package.json' ) ;
30
+
31
+ // Copied from "../../scripts/build/rollup_emit_module_package_file" which is ESM
32
+ // and would require converting this file to MJS to use
33
+ function emitModulePackageFile ( ) {
34
+ return {
35
+ generateBundle ( ) {
36
+ this . emitFile ( {
37
+ fileName : 'package.json' ,
38
+ source : `{"type":"module"}` ,
39
+ type : 'asset'
40
+ } ) ;
41
+ } ,
42
+ name : 'emit-module-package-file'
43
+ } ;
44
+ }
29
45
30
46
// The optimization level for the JS compiler.
31
47
// Valid levels: WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS.
@@ -114,13 +130,29 @@ function createRollupTask({
114
130
} )
115
131
) ;
116
132
}
133
+ if ( format === 'es' ) {
134
+ plugins . push ( emitModulePackageFile ( ) ) ;
135
+ }
117
136
const inputOptions = {
118
137
input : inputPath ,
119
138
plugins
120
139
} ;
121
140
141
+ let outputFilename ;
142
+ if ( format === 'es' ) {
143
+ if ( compileToES5 ) {
144
+ // ESM5
145
+ outputFilename = pkg . esm5 ;
146
+ } else {
147
+ // ESM2017
148
+ outputFilename = pkg . module ;
149
+ }
150
+ } else {
151
+ // CJS
152
+ outputFilename = pkg . main ;
153
+ }
122
154
const outputOptions = {
123
- file : `dist/index ${ outputExtension ? '.' : '' } ${ outputExtension } .js` ,
155
+ file : outputFilename ,
124
156
format,
125
157
sourcemap : true ,
126
158
// Prevents warning when compiling CJS that there are named and default exports together.
Original file line number Diff line number Diff line change 4
4
"description" : " A wrapper of the webchannel packages from closure-library for use outside of a closure compiled application" ,
5
5
"author" :
" Firebase <[email protected] > (https://firebase.google.com/)" ,
6
6
"main" : " dist/index.js" ,
7
- "module" : " dist/index.esm2017.js" ,
8
- "esm5" : " dist/index.esm.js" ,
7
+ "module" : " dist/esm/ index.esm2017.js" ,
8
+ "esm5" : " dist/esm/ index.esm.js" ,
9
9
"exports" : {
10
10
"." : {
11
11
"types" : " ./src/index.d.ts" ,
12
12
"require" : " ./dist/index.js" ,
13
- "esm5" : " ./dist/index.esm.js" ,
14
- "default" : " ./dist/index.esm2017.js"
13
+ "esm5" : " ./dist/esm/ index.esm.js" ,
14
+ "default" : " ./dist/esm/ index.esm2017.js"
15
15
},
16
16
"./package.json" : " ./package.json"
17
17
},
You can’t perform that action at this time.
0 commit comments