Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/improve-module-concat-bailout-mess…
…ages
- Loading branch information
Showing
131 changed files
with
2,868 additions
and
2,331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const webpack = require("webpack"); | ||
const path = require("path"); | ||
|
||
webpack({ | ||
context: __dirname, | ||
entry: "./createBenchmark/entry.js", | ||
output: { | ||
path: __dirname, | ||
filename: "benchmark-bundle.js" | ||
}, | ||
target: "node", | ||
node: { | ||
__dirname: false | ||
}, | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.IgnorePlugin(/^(fsevents|uglify-js)$/), | ||
new webpack.NormalModuleReplacementPlugin(/^.\/loadLoader$/, path.resolve(__dirname, "./createBenchmark/loadLoader")) | ||
] | ||
}, function(err, stats) { | ||
console.log(stats.toString()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const webpack = require("webpack"); | ||
const MemoryFs = require("memory-fs"); | ||
const path = require("path"); | ||
|
||
const testCase = process.argv[2]; | ||
|
||
const config = { | ||
context: __dirname, | ||
entry: `./${testCase}`, | ||
output: { | ||
path: path.resolve(__dirname, "output-" + testCase) | ||
}, | ||
devtool: process.argv[3] | ||
}; | ||
|
||
const compiler = webpack(config); | ||
compiler.run((err, stats) => { | ||
if(err) { | ||
console.error(err); | ||
} else { | ||
console.log(stats.toString({ | ||
errorDetails: true | ||
})); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (loader, callback) => { | ||
callback(new Error("Loaders are not supported")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
let avgJs = ` | ||
const str = "we" + "do" + "some" + "ops"; | ||
for(const x of str.split("")) { | ||
if(x.charCodeAt(0) > 40) { | ||
console.log("omg"); | ||
} else { | ||
console.log(Math.random() * 2 + 3 * 2); | ||
} | ||
} | ||
// Some comment | ||
switch(a.b.c.d.f.e.g.h.i) { | ||
case true: | ||
break; | ||
case "magic": | ||
throw new Error("Error!"); | ||
case 9: | ||
(function() { | ||
// extra scope | ||
var x = 123; | ||
var y = 456; | ||
var z = x + z * x / y; | ||
x && y && (z = x ? y : x); | ||
}()) | ||
} | ||
function a() {} | ||
function b() {} | ||
function c() {} | ||
function d() {} | ||
function e() {} | ||
function f() {} | ||
` | ||
|
||
for(var i = 0; i < 2; i++) { | ||
avgJs += `(function() {${avgJs}}());`; | ||
} | ||
|
||
const fs = require("fs"); | ||
const root = __dirname; | ||
|
||
createTree(fs, 100, `${root}/modules-100`); | ||
createTree(fs, 500, `${root}/modules-500`); | ||
createTree(fs, 1000, `${root}/modules-1000`); | ||
createTree(fs, 3000, `${root}/modules-3000`); | ||
createTree(fs, 5000, `${root}/modules-5000`); | ||
|
||
function createTree(fs, count, folder) { | ||
fs.mkdirSync(folder); | ||
let remaining = count - 1; | ||
|
||
function make(prefix, count, depth) { | ||
if(count === 0) { | ||
fs.writeFileSync(`${folder}/${prefix}.js`, `export default 1;\n${avgJs}`); | ||
} else { | ||
const list = []; | ||
for(let i = 0; i < count; i++) { | ||
if(remaining-- <= 0) break; | ||
if(depth <= 4 && i >= 3 && i <= 4) { | ||
list.push(`const module${i} = import("./${prefix}-${i}");\ncounter += module${i};`); | ||
} else { | ||
list.push(`import module${i} from "./${prefix}-${i}";\ncounter += module${i};`); | ||
} | ||
make(`${prefix}-${i}`, depth > 4 || count > 30 ? 0 : count + depth + i ** 2, depth + 1); | ||
} | ||
fs.writeFileSync(`${folder}/${prefix}.js`, `let counter = 0;\n${list.join("\n")};\nexport default counter;\n${avgJs}`) | ||
} | ||
} | ||
make("index", 2, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
var logLevel = "info"; | ||
|
||
function dummy() {} | ||
|
||
function shouldLog(level) { | ||
var shouldLog = (logLevel === "info" && level === "info") || | ||
(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") || | ||
(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error"); | ||
return shouldLog; | ||
} | ||
|
||
function logGroup(logFn) { | ||
return function(level, msg) { | ||
if(shouldLog(level)) { | ||
logFn(msg); | ||
} | ||
}; | ||
} | ||
|
||
module.exports = function(level, msg) { | ||
if(logLevel === "info" && level === "info") | ||
return console.log(msg); | ||
if(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") | ||
return console.warn(msg); | ||
if(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error") | ||
return console.error(msg); | ||
if(shouldLog(level)) { | ||
if(level === "info") { | ||
console.log(msg); | ||
} else if(level === "warning") { | ||
console.warn(msg); | ||
} else if(level === "error") { | ||
console.error(msg); | ||
} | ||
} | ||
}; | ||
|
||
var group = console.group || dummy; | ||
var groupCollapsed = console.groupCollapsed || dummy; | ||
var groupEnd = console.groupEnd || dummy; | ||
|
||
module.exports.group = logGroup(group); | ||
|
||
module.exports.groupCollapsed = logGroup(groupCollapsed); | ||
|
||
module.exports.groupEnd = logGroup(groupEnd); | ||
|
||
module.exports.setLogLevel = function(level) { | ||
logLevel = level; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.