2017-07-12 03:40:08 +08:00
|
|
|
function getSourceMap(filename) {
|
|
|
|
var fs = require("fs");
|
|
|
|
var source = fs.readFileSync(__dirname + "/" + filename + ".map", "utf-8");
|
|
|
|
var map = JSON.parse(source);
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
it("should include test.js in SourceMap", function() {
|
2018-11-21 18:26:40 +08:00
|
|
|
var allSources = new Set();
|
2017-07-12 03:40:08 +08:00
|
|
|
var map = getSourceMap("bundle0.js");
|
2018-11-21 18:26:40 +08:00
|
|
|
for(var source of map.sources) allSources.add(source);
|
2017-07-12 03:40:08 +08:00
|
|
|
map = getSourceMap("chunk-a.js");
|
2018-11-21 18:26:40 +08:00
|
|
|
for(var source of map.sources) allSources.add(source);
|
2017-07-12 03:40:08 +08:00
|
|
|
map = getSourceMap("chunk-b.js");
|
2018-11-21 18:26:40 +08:00
|
|
|
for(var source of map.sources) allSources.add(source);
|
|
|
|
expect(allSources).toContain("module");
|
|
|
|
allSources.delete("module");
|
|
|
|
expect(allSources).toContain("fallback");
|
|
|
|
for(const source of allSources) {
|
|
|
|
expect(source).toMatch(/^fallback\**$/);
|
|
|
|
}
|
2017-07-12 03:40:08 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
require.ensure(["./test.js"], function(require) {}, "chunk-a");
|
|
|
|
require.ensure(["./test.js", "./test.js?1"], function(require) {}, "chunk-b");
|