1- import babel from ' @rollup/plugin-babel' ;
2- import resolve from ' @rollup/plugin-node-resolve' ;
3- import commonjs from ' @rollup/plugin-commonjs' ;
4- import alias from ' @rollup/plugin-alias' ;
5- import tsconfigPaths from ' rollup-plugin-tsconfig-paths' ;
6- import peerDepsExternal from ' rollup-plugin-peer-deps-external' ;
7- import json from ' @rollup/plugin-json' ;
1+ import babel from " @rollup/plugin-babel" ;
2+ import resolve from " @rollup/plugin-node-resolve" ;
3+ import commonjs from " @rollup/plugin-commonjs" ;
4+ import alias from " @rollup/plugin-alias" ;
5+ import tsconfigPaths from " rollup-plugin-tsconfig-paths" ;
6+ import peerDepsExternal from " rollup-plugin-peer-deps-external" ;
7+ import json from " @rollup/plugin-json" ;
88
99const bundle = (
1010 name ,
@@ -16,31 +16,31 @@ const bundle = (
1616 ...( umdConfig || baseConfig ) ,
1717 plugins : [
1818 commonjs ( {
19- extensions : [ ' .js' ] ,
19+ extensions : [ " .js" ] ,
2020 } ) ,
2121 resolve ( {
22- extensions : [ ' .ts' , ' .js' , ' .json' ] ,
23- mainFields : [ ' browser' , ' module' , ' main' ] ,
22+ extensions : [ " .ts" , " .js" , " .json" ] ,
23+ mainFields : [ " browser" , " module" , " main" ] ,
2424 } ) ,
2525 babel ( {
26- extensions : [ ' .js' , ' .jsx' , ' .ts' , ' .tsx' ] ,
27- exclude : [ ' node_modules/**' , / \/ c o r e - j s \/ / ] ,
28- babelHelpers : ' runtime' ,
26+ extensions : [ " .js" , " .jsx" , " .ts" , " .tsx" ] ,
27+ exclude : [ " node_modules/**" , / \/ c o r e - j s \/ / ] ,
28+ babelHelpers : " runtime" ,
2929 presets : [
30- ' @babel/preset-react' ,
31- ' @babel/preset-typescript' ,
30+ " @babel/preset-react" ,
31+ " @babel/preset-typescript" ,
3232 [
33- ' @babel/preset-env' ,
33+ " @babel/preset-env" ,
3434 {
3535 shippedProposals : true ,
36- useBuiltIns : ' usage' ,
36+ useBuiltIns : " usage" ,
3737 corejs : 3 ,
3838 } ,
3939 ] ,
4040 ] ,
4141 plugins : [
4242 [
43- ' @babel/plugin-transform-runtime' ,
43+ " @babel/plugin-transform-runtime" ,
4444 {
4545 corejs : false ,
4646 helpers : true ,
@@ -52,22 +52,25 @@ const bundle = (
5252 } ) ,
5353 alias ( {
5454 entries : {
55- ' @cubejs-client/core' : ' ../cubejs-client-core/src/index.ts' ,
55+ " @cubejs-client/core" : " ../cubejs-client-core/src/index.ts" ,
5656 } ,
5757 } ) ,
5858 ] ,
5959 } ;
6060
61- return [
61+ // Will be built with typescript
62+ const skipEsModule = name === "cubejs-client-core" ;
63+
64+ const config = [
6265 // browser-friendly UMD build
6366 {
6467 ...baseUmdConfig ,
6568 output : [
6669 {
6770 file : `packages/${ name } /dist/${ name } .umd.js` ,
68- format : ' umd' ,
71+ format : " umd" ,
6972 name : globalName ,
70- exports : ' auto' ,
73+ exports : " auto" ,
7174 sourcemap : true ,
7275 } ,
7376 ] ,
@@ -79,31 +82,31 @@ const bundle = (
7982 json ( ) ,
8083 tsconfigPaths ( ) ,
8184 resolve ( {
82- extensions : [ ' .mjs' , ' .js' , ' .jsx' , ' .ts' , ' .tsx' , ' .json' ] ,
85+ extensions : [ " .mjs" , " .js" , " .jsx" , " .ts" , " .tsx" , " .json" ] ,
8386 browser : false ,
8487 preferBuiltins : true ,
8588 } ) ,
8689 commonjs ( ) ,
8790 peerDepsExternal ( ) ,
8891 babel ( {
89- extensions : [ ' .js' , ' .jsx' , ' .ts' , ' .tsx' ] ,
90- exclude : ' node_modules/**' ,
91- babelHelpers : ' runtime' ,
92+ extensions : [ " .js" , " .jsx" , " .ts" , " .tsx" ] ,
93+ exclude : " node_modules/**" ,
94+ babelHelpers : " runtime" ,
9295 presets : [
93- ' @babel/preset-react' ,
94- ' @babel/preset-typescript' ,
96+ " @babel/preset-react" ,
97+ " @babel/preset-typescript" ,
9598 [
96- ' @babel/preset-env' ,
99+ " @babel/preset-env" ,
97100 {
98101 shippedProposals : true ,
99- useBuiltIns : ' usage' ,
102+ useBuiltIns : " usage" ,
100103 corejs : 3 ,
101104 } ,
102105 ] ,
103106 ] ,
104107 plugins : [
105108 [
106- ' @babel/plugin-transform-runtime' ,
109+ " @babel/plugin-transform-runtime" ,
107110 {
108111 corejs : false ,
109112 helpers : true ,
@@ -116,81 +119,83 @@ const bundle = (
116119 ] ,
117120 output : [
118121 {
119- file : `packages/${ name } /dist/${ name } .js` ,
120- format : ' cjs' ,
122+ file : `packages/${ name } /dist/${ name } .cjs. js` ,
123+ format : " cjs" ,
121124 sourcemap : true ,
122125 } ,
123126 ] ,
124127 } ,
128+ ] ;
129+
130+ if ( ! skipEsModule ) {
125131 // ES module (for bundlers) build.
126- {
132+ config . push ( {
127133 ...baseConfig ,
128134 plugins : [
129135 tsconfigPaths ( ) ,
130136 resolve ( {
131- extensions : [ ' .mjs' , ' .js' , ' .jsx' , ' .ts' , ' .tsx' , ' .json' ] ,
137+ extensions : [ " .mjs" , " .js" , " .jsx" , " .ts" , " .tsx" , " .json" ] ,
132138 browser : true ,
133139 preferBuiltins : false ,
134140 } ) ,
135141 commonjs ( ) ,
136142 peerDepsExternal ( ) ,
137143 babel ( {
138- extensions : [ '.js' , '.jsx' , '.ts' , '.tsx' ] ,
139- exclude : 'node_modules/**' ,
140- presets : [
141- '@babel/preset-react' ,
142- '@babel/preset-typescript' ,
143- ] ,
144+ extensions : [ ".js" , ".jsx" , ".ts" , ".tsx" ] ,
145+ exclude : "node_modules/**" ,
146+ presets : [ "@babel/preset-react" , "@babel/preset-typescript" ] ,
144147 } ) ,
145148 ] ,
146149 output : [
147150 {
148151 file : `packages/${ name } /dist/${ name } .esm.js` ,
149- format : 'es' ,
152+ format : "es" ,
150153 sourcemap : true ,
151154 globals,
152155 } ,
153156 ] ,
154- } ,
155- ] ;
157+ } ) ;
158+ }
159+
160+ return config ;
156161} ;
157162
158163export default bundle (
159- ' cubejs-client-core' ,
160- ' cubejs' ,
164+ " cubejs-client-core" ,
165+ " cubejs" ,
161166 {
162- input : ' packages/cubejs-client-core/src/index.ts' ,
167+ input : " packages/cubejs-client-core/src/index.ts" ,
163168 } ,
164169 {
165- input : ' packages/cubejs-client-core/src/index.umd.ts' ,
170+ input : " packages/cubejs-client-core/src/index.umd.ts" ,
166171 }
167172)
168173 . concat (
169- bundle ( ' cubejs-client-ws-transport' , ' CubejsWebSocketTransport' , {
170- input : ' packages/cubejs-client-ws-transport/src/index.ts' ,
174+ bundle ( " cubejs-client-ws-transport" , " CubejsWebSocketTransport" , {
175+ input : " packages/cubejs-client-ws-transport/src/index.ts" ,
171176 } )
172177 )
173178 . concat (
174- bundle ( ' cubejs-client-react' , ' cubejsReact' , {
175- input : ' packages/cubejs-client-react/src/index.js' ,
176- external : [ ' react' , ' prop-types' ] ,
179+ bundle ( " cubejs-client-react" , " cubejsReact" , {
180+ input : " packages/cubejs-client-react/src/index.js" ,
181+ external : [ " react" , " prop-types" ] ,
177182 } )
178183 )
179184 . concat (
180- bundle ( ' cubejs-client-vue' , ' cubejsVue' , {
181- input : ' packages/cubejs-client-vue/src/index.js' ,
182- external : [ ' vue' ] ,
185+ bundle ( " cubejs-client-vue" , " cubejsVue" , {
186+ input : " packages/cubejs-client-vue/src/index.js" ,
187+ external : [ " vue" ] ,
183188 globals : {
184- vue : ' Vue' ,
189+ vue : " Vue" ,
185190 } ,
186191 } )
187192 )
188193 . concat (
189- bundle ( ' cubejs-client-vue3' , ' cubejsVue3' , {
190- input : ' packages/cubejs-client-vue3/src/index.js' ,
191- external : [ ' vue' ] ,
194+ bundle ( " cubejs-client-vue3" , " cubejsVue3" , {
195+ input : " packages/cubejs-client-vue3/src/index.js" ,
196+ external : [ " vue" ] ,
192197 globals : {
193- vue : ' Vue' ,
198+ vue : " Vue" ,
194199 } ,
195200 } )
196201 ) ;
0 commit comments