Skip to content

Commit

Permalink
Merge pull request #7122 from birkskyum/add-amdWrapper
Browse files Browse the repository at this point in the history
Add amd wrapper to fix esbuild
  • Loading branch information
archmoj authored Aug 21, 2024
2 parents 5d326d8 + 76fe186 commit d1a806a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tasks/bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import prependFile from 'prepend-file';
import constants from './util/constants.js';
import common from './util/common.js';
import _bundle from './util/bundle_wrapper.mjs';
import fsExtra from 'fs-extra';

var header = constants.licenseDist + '\n';
var pathToPlotlyDist = constants.pathToPlotlyDist;
Expand All @@ -27,6 +28,11 @@ if(!doesFileExist(constants.pathToCSSBuild)) {
].join('\n'));
}

function amdWrapper(path){
prependFile.sync(path, "define(function (require, exports, module) {", common.throwOnError)
fsExtra.appendFile(path, "})", common.throwOnError)
}

// list of tasks to pass to run-series to not blow up
// memory consumption.
var tasks = [];
Expand All @@ -36,7 +42,7 @@ tasks.push(function(done) {
_bundle(pathToPlotlyIndex, pathToPlotlyDist, {
}, function() {
prependFile.sync(pathToPlotlyDist, header, common.throwOnError);

amdWrapper(pathToPlotlyDist)
done();
});
});
Expand All @@ -47,7 +53,7 @@ tasks.push(function(done) {
minify: true,
}, function() {
prependFile.sync(pathToPlotlyDistMin, header, common.throwOnError);

amdWrapper(pathToPlotlyDistMin)
done();
});
});
Expand All @@ -57,7 +63,7 @@ tasks.push(function(done) {
_bundle(pathToPlotlyStrict, pathToPlotlyStrictDist, {
}, function() {
prependFile.sync(pathToPlotlyStrictDist, header.replace('plotly.js', 'plotly.js (strict)'), common.throwOnError);

amdWrapper(pathToPlotlyStrictDist)
done();
});
});
Expand All @@ -68,7 +74,7 @@ tasks.push(function(done) {
minify: true,
}, function() {
prependFile.sync(pathToPlotlyStrictDistMin, header.replace('plotly.js', 'plotly.js (strict - minified)'), common.throwOnError);

amdWrapper(pathToPlotlyStrictDistMin)
done();
});
});
Expand All @@ -80,7 +86,7 @@ tasks.push(function(done) {
standalone: 'PlotlyGeoAssets'
}, function() {
prependFile.sync(pathToPlotlyGeoAssetsDist, header, common.throwOnError);

amdWrapper(pathToPlotlyGeoAssetsDist)
done();
});
});
Expand All @@ -91,7 +97,6 @@ tasks.push(function(done) {
noCompressAttributes: true
}, function() {
prependFile.sync(pathToPlotlyDistWithMeta, header, common.throwOnError);

done();
});
});
Expand Down

0 comments on commit d1a806a

Please sign in to comment.