@@ -20,19 +20,17 @@ interface Args {
2020
2121const bundles = {
2222 plotly : {
23- // react-plotly.js@2.6.0 use: `import Plotly from 'plotly.js/dist/plotly';`
24- // We redirect this import to min version.
2523 input : "plotly.js-dist-min" ,
2624 file : {
2725 amd : "plotly.min.js" ,
2826 esm : "plotly.min.mjs"
2927 }
3028 } ,
3129 reactPlotly : {
32- input : "react-plotly.js" ,
30+ input : "react-plotly.js/factory " ,
3331 file : {
34- amd : "react-plotly .js" ,
35- esm : "react-plotly .mjs"
32+ amd : "react-plotly_factory .js" ,
33+ esm : "react-plotly_factory .mjs"
3634 }
3735 } ,
3836 sharedCharts : {
@@ -116,7 +114,9 @@ function sharedCode(bundle: BundleBuildConfig): RollupOptions {
116114 file : format ( { dir : bundle . esmDir , base : bundle . sharedCharts . file . esm } ) ,
117115 paths : {
118116 // Replace imports of react-plotly.js with relative path.
119- [ bundle . reactPlotly . input ] : `./${ bundle . reactPlotly . file . esm } `
117+ [ bundle . reactPlotly . input ] : `./${ bundle . reactPlotly . file . esm } ` ,
118+ // Replace imports of plotly.js with relative path.
119+ [ bundle . plotly . input ] : `./${ bundle . plotly . file . esm } `
120120 }
121121 } ;
122122
@@ -125,44 +125,38 @@ function sharedCode(bundle: BundleBuildConfig): RollupOptions {
125125 file : format ( { dir : bundle . amdDir , base : bundle . sharedCharts . file . amd } ) ,
126126 paths : {
127127 // Replace imports of react-plotly.js with relative path.
128- [ bundle . reactPlotly . input ] : `./${ bundle . reactPlotly . file . amd } `
128+ [ bundle . reactPlotly . input ] : `./${ bundle . reactPlotly . file . amd } ` ,
129+ // Replace imports of plotly.js with relative path.
130+ [ bundle . plotly . input ] : `./${ bundle . plotly . file . amd } `
129131 }
130132 } ;
131133
132134 return {
133135 input : bundle . sharedCharts . input ,
134136 plugins : stdPlugins ( bundle ) ,
135137 // Mark reactPlotly as external to not include react-plotly.js in bundle.
136- external : [ ...bundle . external , bundle . reactPlotly . input ] ,
138+ // Mark plotly as external to not include plotly.js in bundle.
139+ external : [ ...bundle . external , bundle . reactPlotly . input , bundle . plotly . input ] ,
137140 output : [ esmOutput , amdOutput ]
138141 } ;
139142}
140143
141- /** react-plotly.js bundle config */
144+ /** This entry create standalone react-plotly.js/factory bundle */
142145function reactPlotly ( bundle : BundleBuildConfig ) : RollupOptions {
143- const plotlyImport = "plotly.js/dist/plotly" ;
144146 const esmOutput : OutputOptions = {
145147 format : "es" ,
146- file : format ( { dir : bundle . esmDir , base : bundle . reactPlotly . file . esm } ) ,
147- paths : {
148- // Replace imports of plotly.js with relative path.
149- [ plotlyImport ] : `./${ bundle . plotly . file . esm } `
150- }
148+ file : format ( { dir : bundle . esmDir , base : bundle . reactPlotly . file . esm } )
151149 } ;
152150
153151 const amdOutput : OutputOptions = {
154152 format : "amd" ,
155- file : format ( { dir : bundle . amdDir , base : bundle . reactPlotly . file . amd } ) ,
156- paths : {
157- // Replace imports of plotly.js with relative path.
158- [ plotlyImport ] : `./${ bundle . plotly . file . amd } `
159- }
153+ file : format ( { dir : bundle . amdDir , base : bundle . reactPlotly . file . amd } )
160154 } ;
161155
162156 return {
163157 input : bundle . reactPlotly . input ,
164158 // Mark plotly as external to not include plotly.js in bundle.
165- external : [ ...bundle . external , plotlyImport ] ,
159+ external : [ ...bundle . external ] ,
166160 plugins : stdPlugins ( bundle ) ,
167161 output : [ esmOutput , amdOutput ]
168162 } ;
@@ -199,8 +193,8 @@ function plotly(bundle: BundleBuildConfig): RollupOptions {
199193 // Here we just copy the license file.
200194 copy ( {
201195 targets : [
202- { src : "node_modules/plotly.js/ dist/plotly. min.js. LICENSE.txt " , dest : bundle . amdDir } ,
203- { src : "node_modules/plotly.js/ dist/plotly. min.js. LICENSE.txt " , dest : bundle . esmDir }
196+ { src : "node_modules/plotly.js- dist- min/ LICENSE" , dest : bundle . amdDir } ,
197+ { src : "node_modules/plotly.js- dist- min/ LICENSE" , dest : bundle . esmDir }
204198 ] ,
205199 verbose : true
206200 } )
0 commit comments