@@ -4,6 +4,7 @@ import prependFile from 'prepend-file';
4
4
import constants from './util/constants.js' ;
5
5
import common from './util/common.js' ;
6
6
import _bundle from './util/bundle_wrapper.mjs' ;
7
+ import fsExtra from 'fs-extra' ;
7
8
8
9
var header = constants . licenseDist + '\n' ;
9
10
var pathToPlotlyDist = constants . pathToPlotlyDist ;
@@ -27,6 +28,11 @@ if(!doesFileExist(constants.pathToCSSBuild)) {
27
28
] . join ( '\n' ) ) ;
28
29
}
29
30
31
+ function amdWrapper ( path ) {
32
+ prependFile . sync ( path , "define(function (require, exports, module) {" , common . throwOnError )
33
+ fsExtra . appendFile ( path , "})" , common . throwOnError )
34
+ }
35
+
30
36
// list of tasks to pass to run-series to not blow up
31
37
// memory consumption.
32
38
var tasks = [ ] ;
@@ -36,7 +42,7 @@ tasks.push(function(done) {
36
42
_bundle ( pathToPlotlyIndex , pathToPlotlyDist , {
37
43
} , function ( ) {
38
44
prependFile . sync ( pathToPlotlyDist , header , common . throwOnError ) ;
39
-
45
+ amdWrapper ( pathToPlotlyDist )
40
46
done ( ) ;
41
47
} ) ;
42
48
} ) ;
@@ -47,7 +53,7 @@ tasks.push(function(done) {
47
53
minify : true ,
48
54
} , function ( ) {
49
55
prependFile . sync ( pathToPlotlyDistMin , header , common . throwOnError ) ;
50
-
56
+ amdWrapper ( pathToPlotlyDistMin )
51
57
done ( ) ;
52
58
} ) ;
53
59
} ) ;
@@ -57,7 +63,7 @@ tasks.push(function(done) {
57
63
_bundle ( pathToPlotlyStrict , pathToPlotlyStrictDist , {
58
64
} , function ( ) {
59
65
prependFile . sync ( pathToPlotlyStrictDist , header . replace ( 'plotly.js' , 'plotly.js (strict)' ) , common . throwOnError ) ;
60
-
66
+ amdWrapper ( pathToPlotlyStrictDist )
61
67
done ( ) ;
62
68
} ) ;
63
69
} ) ;
@@ -68,7 +74,7 @@ tasks.push(function(done) {
68
74
minify : true ,
69
75
} , function ( ) {
70
76
prependFile . sync ( pathToPlotlyStrictDistMin , header . replace ( 'plotly.js' , 'plotly.js (strict - minified)' ) , common . throwOnError ) ;
71
-
77
+ amdWrapper ( pathToPlotlyStrictDistMin )
72
78
done ( ) ;
73
79
} ) ;
74
80
} ) ;
@@ -80,7 +86,7 @@ tasks.push(function(done) {
80
86
standalone : 'PlotlyGeoAssets'
81
87
} , function ( ) {
82
88
prependFile . sync ( pathToPlotlyGeoAssetsDist , header , common . throwOnError ) ;
83
-
89
+ amdWrapper ( pathToPlotlyGeoAssetsDist )
84
90
done ( ) ;
85
91
} ) ;
86
92
} ) ;
@@ -91,7 +97,6 @@ tasks.push(function(done) {
91
97
noCompressAttributes : true
92
98
} , function ( ) {
93
99
prependFile . sync ( pathToPlotlyDistWithMeta , header , common . throwOnError ) ;
94
-
95
100
done ( ) ;
96
101
} ) ;
97
102
} ) ;
0 commit comments