Skip to content

Commit d1a806a

Browse files
authored
Merge pull request #7122 from birkskyum/add-amdWrapper
Add amd wrapper to fix esbuild
2 parents 5d326d8 + 76fe186 commit d1a806a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tasks/bundle.mjs

+11-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import prependFile from 'prepend-file';
44
import constants from './util/constants.js';
55
import common from './util/common.js';
66
import _bundle from './util/bundle_wrapper.mjs';
7+
import fsExtra from 'fs-extra';
78

89
var header = constants.licenseDist + '\n';
910
var 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.
3238
var 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

Comments
 (0)