@@ -4,6 +4,7 @@ import prependFile from 'prepend-file';
44import constants from './util/constants.js' ;
55import common from './util/common.js' ;
66import _bundle from './util/bundle_wrapper.mjs' ;
7+ import fsExtra from 'fs-extra' ;
78
89var header = constants . licenseDist + '\n' ;
910var pathToPlotlyDist = constants . pathToPlotlyDist ;
@@ -27,6 +28,11 @@ if(!doesFileExist(constants.pathToCSSBuild)) {
2728 ] . join ( '\n' ) ) ;
2829}
2930
31+ function amdWrapper ( path ) {
32+ prependFile . sync ( path , "define(function (require, exports, module) {" , common . throwOnError )
33+ fsExtra . appendFile ( path , "})" , common . throwOnError )
34+ }
35+
3036// list of tasks to pass to run-series to not blow up
3137// memory consumption.
3238var tasks = [ ] ;
@@ -36,7 +42,7 @@ tasks.push(function(done) {
3642 _bundle ( pathToPlotlyIndex , pathToPlotlyDist , {
3743 } , function ( ) {
3844 prependFile . sync ( pathToPlotlyDist , header , common . throwOnError ) ;
39-
45+ amdWrapper ( pathToPlotlyDist )
4046 done ( ) ;
4147 } ) ;
4248} ) ;
@@ -47,7 +53,7 @@ tasks.push(function(done) {
4753 minify : true ,
4854 } , function ( ) {
4955 prependFile . sync ( pathToPlotlyDistMin , header , common . throwOnError ) ;
50-
56+ amdWrapper ( pathToPlotlyDistMin )
5157 done ( ) ;
5258 } ) ;
5359} ) ;
@@ -57,7 +63,7 @@ tasks.push(function(done) {
5763 _bundle ( pathToPlotlyStrict , pathToPlotlyStrictDist , {
5864 } , function ( ) {
5965 prependFile . sync ( pathToPlotlyStrictDist , header . replace ( 'plotly.js' , 'plotly.js (strict)' ) , common . throwOnError ) ;
60-
66+ amdWrapper ( pathToPlotlyStrictDist )
6167 done ( ) ;
6268 } ) ;
6369} ) ;
@@ -68,7 +74,7 @@ tasks.push(function(done) {
6874 minify : true ,
6975 } , function ( ) {
7076 prependFile . sync ( pathToPlotlyStrictDistMin , header . replace ( 'plotly.js' , 'plotly.js (strict - minified)' ) , common . throwOnError ) ;
71-
77+ amdWrapper ( pathToPlotlyStrictDistMin )
7278 done ( ) ;
7379 } ) ;
7480} ) ;
@@ -80,7 +86,7 @@ tasks.push(function(done) {
8086 standalone : 'PlotlyGeoAssets'
8187 } , function ( ) {
8288 prependFile . sync ( pathToPlotlyGeoAssetsDist , header , common . throwOnError ) ;
83-
89+ amdWrapper ( pathToPlotlyGeoAssetsDist )
8490 done ( ) ;
8591 } ) ;
8692} ) ;
@@ -91,7 +97,6 @@ tasks.push(function(done) {
9197 noCompressAttributes : true
9298 } , function ( ) {
9399 prependFile . sync ( pathToPlotlyDistWithMeta , header , common . throwOnError ) ;
94-
95100 done ( ) ;
96101 } ) ;
97102} ) ;
0 commit comments