Skip to content

Commit

Permalink
Set detectGlobals to false when bundling sinon
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Dec 18, 2019
1 parent 11391f1 commit e8cb75c
Showing 1 changed file with 37 additions and 19 deletions.
56 changes: 37 additions & 19 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,47 @@ makeBundle(
// Add inline source maps to the default bundle
debug: true,
// Create a UMD wrapper and install the "sinon" global:
standalone: "sinon"
standalone: "sinon",
// Do not detect and insert globals:
detectGlobals: false
},
function(bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon.js", script);
}
);

makeBundle("./lib/sinon.js", {}, function(bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon-no-sourcemaps.js", script);
});

makeBundle("./lib/sinon-esm.js", {}, function(bundle) {
var intro = "let sinon;";
var outro =
"\nexport default sinon;\n" +
Object.keys(sinon)
.map(function(key) {
return "const _" + key + " = sinon." + key + ";\nexport { _" + key + " as " + key + " };";
})
.join("\n");

var script = preamble + intro + bundle + outro;
fs.writeFileSync("pkg/sinon-esm.js", script);
});
makeBundle(
"./lib/sinon.js",
{
// Create a UMD wrapper and install the "sinon" global:
standalone: "sinon",
// Do not detect and insert globals:
detectGlobals: false
},
function(bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon-no-sourcemaps.js", script);
}
);

makeBundle(
"./lib/sinon-esm.js",
{
// Do not detect and insert globals:
detectGlobals: false
},
function(bundle) {
var intro = "let sinon;";
var outro =
"\nexport default sinon;\n" +
Object.keys(sinon)
.map(function(key) {
return "const _" + key + " = sinon." + key + ";\nexport { _" + key + " as " + key + " };";
})
.join("\n");

var script = preamble + intro + bundle + outro;
fs.writeFileSync("pkg/sinon-esm.js", script);
}
);

0 comments on commit e8cb75c

Please sign in to comment.