@@ -20,19 +20,17 @@ interface Args {
20
20
21
21
const bundles = {
22
22
plotly : {
23
- // [email protected] use: `import Plotly from 'plotly.js/dist/plotly';`
24
- // We redirect this import to min version.
25
23
input : "plotly.js-dist-min" ,
26
24
file : {
27
25
amd : "plotly.min.js" ,
28
26
esm : "plotly.min.mjs"
29
27
}
30
28
} ,
31
29
reactPlotly : {
32
- input : "react-plotly.js" ,
30
+ input : "react-plotly.js/factory " ,
33
31
file : {
34
- amd : "react-plotly .js" ,
35
- esm : "react-plotly .mjs"
32
+ amd : "react-plotly_factory .js" ,
33
+ esm : "react-plotly_factory .mjs"
36
34
}
37
35
} ,
38
36
sharedCharts : {
@@ -116,7 +114,9 @@ function sharedCode(bundle: BundleBuildConfig): RollupOptions {
116
114
file : format ( { dir : bundle . esmDir , base : bundle . sharedCharts . file . esm } ) ,
117
115
paths : {
118
116
// 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 } `
120
120
}
121
121
} ;
122
122
@@ -125,44 +125,38 @@ function sharedCode(bundle: BundleBuildConfig): RollupOptions {
125
125
file : format ( { dir : bundle . amdDir , base : bundle . sharedCharts . file . amd } ) ,
126
126
paths : {
127
127
// 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 } `
129
131
}
130
132
} ;
131
133
132
134
return {
133
135
input : bundle . sharedCharts . input ,
134
136
plugins : stdPlugins ( bundle ) ,
135
137
// 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 ] ,
137
140
output : [ esmOutput , amdOutput ]
138
141
} ;
139
142
}
140
143
141
- /** react-plotly.js bundle config */
144
+ /** This entry create standalone react-plotly.js/factory bundle */
142
145
function reactPlotly ( bundle : BundleBuildConfig ) : RollupOptions {
143
- const plotlyImport = "plotly.js/dist/plotly" ;
144
146
const esmOutput : OutputOptions = {
145
147
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 } )
151
149
} ;
152
150
153
151
const amdOutput : OutputOptions = {
154
152
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 } )
160
154
} ;
161
155
162
156
return {
163
157
input : bundle . reactPlotly . input ,
164
158
// Mark plotly as external to not include plotly.js in bundle.
165
- external : [ ...bundle . external , plotlyImport ] ,
159
+ external : [ ...bundle . external ] ,
166
160
plugins : stdPlugins ( bundle ) ,
167
161
output : [ esmOutput , amdOutput ]
168
162
} ;
@@ -199,8 +193,8 @@ function plotly(bundle: BundleBuildConfig): RollupOptions {
199
193
// Here we just copy the license file.
200
194
copy ( {
201
195
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 }
204
198
] ,
205
199
verbose : true
206
200
} )
0 commit comments