Merge tag 'v4.29.5' into next

4.29.5
This commit is contained in:
Tobias Koppers 2019-02-19 08:58:46 +01:00
commit d34d69e62b
26 changed files with 658 additions and 636 deletions

View File

@ -1,8 +1,8 @@
# Ignore test fixtures
test
test/*.*
!test/*.js
!test/**/webpack.config.js
# Ignore example fixtures
examples
examples/*.*
!examples/**/webpack.config.js

2
declarations.d.ts vendored
View File

@ -192,7 +192,7 @@ declare module "@webassemblyjs/ast" {
export function global(globalType: string, nodes: Node[]): Global;
export function identifier(indentifier: string): Identifier;
export function funcParam(valType: string, id: Identifier): FuncParam;
export function instruction(inst: string, args: Node[]): Instruction;
export function instruction(inst: string, args?: Node[]): Instruction;
export function callInstruction(funcIndex: Index): CallInstruction;
export function objectInstruction(
kind: string,

View File

@ -180,9 +180,12 @@ const rewriteImportedGlobals = state => bin => {
globalType.mutability = "var";
const init = createDefaultInitForGlobal(globalType);
const init = [
createDefaultInitForGlobal(globalType),
t.instruction("end")
];
newGlobals.push(t.global(globalType, [init]));
newGlobals.push(t.global(globalType, init));
path.remove();
}
@ -199,7 +202,10 @@ const rewriteImportedGlobals = state => bin => {
const initialGlobalidx = init.args[0];
node.init = [createDefaultInitForGlobal(node.globalType)];
node.init = [
createDefaultInitForGlobal(node.globalType),
t.instruction("end")
];
additionalInitCode.push(
/**
@ -325,6 +331,8 @@ const addInitFunction = ({
funcBody.push(instr);
}
funcBody.push(t.instruction("end"));
const funcResults = [];
// Code section

View File

@ -5,10 +5,10 @@
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
"license": "MIT",
"dependencies": {
"@webassemblyjs/ast": "1.7.11",
"@webassemblyjs/helper-module-context": "1.7.11",
"@webassemblyjs/wasm-edit": "1.7.11",
"@webassemblyjs/wasm-parser": "1.7.11",
"@webassemblyjs/ast": "1.8.3",
"@webassemblyjs/helper-module-context": "1.8.3",
"@webassemblyjs/wasm-edit": "1.8.3",
"@webassemblyjs/wasm-parser": "1.8.3",
"acorn": "^6.0.5",
"acorn-dynamic-import": "^4.0.0",
"ajv": "^6.1.0",

View File

@ -279,9 +279,9 @@ describe("BenchmarkTestCases", function() {
describe(`${testName} create benchmarks`, function() {
baselines.forEach(baseline => {
let baselineStats = null;
it(
`should benchmark ${baseline.name} (${baseline.rev})`,
function(done) {
it(`should benchmark ${baseline.name} (${
baseline.rev
})`, function(done) {
const outputDirectory = path.join(
__dirname,
"js",
@ -305,13 +305,9 @@ describe("BenchmarkTestCases", function() {
else baselineStats = stats;
done();
});
},
180000
);
}, 180000);
it(
`should benchmark ${baseline.name} (${baseline.rev})`,
done => {
it(`should benchmark ${baseline.name} (${baseline.rev})`, done => {
const outputDirectory = path.join(
__dirname,
"js",
@ -333,9 +329,7 @@ describe("BenchmarkTestCases", function() {
else baselineStats = stats;
done();
});
},
180000
);
}, 180000);
if (baseline.name !== "HEAD") {
it(`HEAD should not be slower than ${baseline.name} (${

View File

@ -571,9 +571,9 @@ describe("Compiler", () => {
output: {
path: "/",
filename: "bundle.js"
},
}
});
compiler.hooks.failed.tap('CompilerTest', failedSpy);
compiler.hooks.failed.tap("CompilerTest", failedSpy);
compiler.outputFileSystem = new MemoryFs();
compiler.run((err, stats) => {
expect(err).toBeTruthy();

View File

@ -256,7 +256,9 @@ describe("ConfigTestCases", () => {
const bundlePath = testConfig.findBundle(i, optionsArr[i]);
if (bundlePath) {
filesCount++;
results.push(_require(outputDirectory, optionsArr[i], bundlePath));
results.push(
_require(outputDirectory, optionsArr[i], bundlePath)
);
}
}
// give a free pass to compilation that generated an error
@ -269,12 +271,16 @@ describe("ConfigTestCases", () => {
"Should have found at least one bundle file per webpack config"
)
);
Promise.all(results).then(() => {
Promise.all(results)
.then(() => {
if (getNumberOfTests() < filesCount)
return done(new Error("No tests exported by test case"));
return done(
new Error("No tests exported by test case")
);
if (testConfig.afterExecute) testConfig.afterExecute();
done();
}).catch(done);
})
.catch(done);
});
})
);

View File

@ -100,10 +100,7 @@ describe("HotModuleReplacementPlugin", () => {
it("should correct working when entry is Object and key is a number", done => {
const outputPath = path.join(__dirname, "js", "HotModuleReplacementPlugin");
const entryFile = path.join(
outputPath,
"entry.js"
);
const entryFile = path.join(outputPath, "entry.js");
const statsFile3 = path.join(
outputPath,
"HotModuleReplacementPlugin.test.stats3.txt"
@ -112,10 +109,7 @@ describe("HotModuleReplacementPlugin", () => {
outputPath,
"HotModuleReplacementPlugin.test.stats4.txt"
);
const recordsFile = path.join(
outputPath,
"records.json"
);
const recordsFile = path.join(outputPath, "records.json");
try {
mkdirp.sync(outputPath);
} catch (e) {
@ -156,7 +150,10 @@ describe("HotModuleReplacementPlugin", () => {
if (err) throw err;
fs.writeFileSync(statsFile3, stats.toString());
const result = JSON.parse(
fs.readFileSync(path.join(outputPath, `${hash}.hot-update.json`), "utf-8")
fs.readFileSync(
path.join(outputPath, `${hash}.hot-update.json`),
"utf-8"
)
)["c"];
expect(result).toEqual([chunkName]);
done();

View File

@ -48,7 +48,10 @@ const describeCases = config => {
const fakeUpdateLoaderOptions = {
updateIndex: 0
};
const configPath = path.join(testDirectory, "webpack.config.js");
const configPath = path.join(
testDirectory,
"webpack.config.js"
);
let options = {};
if (fs.existsSync(configPath)) options = require(configPath);
if (!options.mode) options.mode = "development";
@ -113,13 +116,15 @@ const describeCases = config => {
}
const window = {
fetch: (url) => {
fetch: url => {
return Promise.resolve({
ok: true,
json() {
return Promise.resolve(require(path.resolve(outputDirectory, url)));
return Promise.resolve(
require(path.resolve(outputDirectory, url))
);
}
})
});
},
importScripts: url => {
_require("./" + url);

View File

@ -6,21 +6,24 @@ const MemoryFs = require("memory-fs");
describe("MultiStats", () => {
it("should create JSON of children stats", done => {
const compiler = webpack([{
const compiler = webpack([
{
context: __dirname,
entry: "./fixtures/a"
},{
},
{
context: __dirname,
entry: "./fixtures/b"
}]);
}
]);
compiler.outputFileSystem = new MemoryFs();
compiler.run((err, stats) => {
if (err) return done(err);
try {
const statsObject = stats.toJson();
expect(
statsObject
).toEqual(expect.objectContaining({children: expect.any(Array)}));
expect(statsObject).toEqual(
expect.objectContaining({ children: expect.any(Array) })
);
expect(statsObject.children).toHaveLength(2);
done();
} catch (e) {

View File

@ -129,7 +129,10 @@ describe("StatsTestCases", () => {
);
}
const testPath = path.join(base, testName);
const testPathPattern = testPath.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
const testPathPattern = testPath.replace(
/[-[\]\\/{}()*+?.^$|]/g,
"\\$&"
);
actual = actual
.replace(/\r\n?/g, "\n")
.replace(/[\t ]*Version:.+\n/g, "")

View File

@ -12,23 +12,25 @@ const check = (expected, actual) => {
value = JSON.stringify(value);
}
return expected[key].test(value);
})
}
});
};
const explain = object => {
if (object instanceof RegExp) {
object = { message: object };
}
return Object.keys(object).map(key => {
return Object.keys(object)
.map(key => {
let value = object[key];
if (typeof value === "object" && !(value instanceof RegExp)) {
value = JSON.stringify(value);
}
let msg = `${key} = ${value}`
let msg = `${key} = ${value}`;
if (msg.length > 100) msg = msg.slice(0, 97) + "...";
return msg;
}).join("; ");
}
})
.join("; ");
};
module.exports = function checkArrayExpectation(
testDirectory,
@ -56,9 +58,9 @@ module.exports = function checkArrayExpectation(
return (
done(
new Error(
`More ${kind}s while compiling than expected:\n\n${array.map(explain).join(
"\n\n"
)}. Check expected ${kind}s: ${expectedFilename}`
`More ${kind}s while compiling than expected:\n\n${array
.map(explain)
.join("\n\n")}. Check expected ${kind}s: ${expectedFilename}`
)
),
true
@ -67,9 +69,9 @@ module.exports = function checkArrayExpectation(
return (
done(
new Error(
`Less ${kind}s while compiling than expected:\n\n${array.map(explain).join(
"\n\n"
)}. Check expected ${kind}s: ${expectedFilename}`
`Less ${kind}s while compiling than expected:\n\n${array
.map(explain)
.join("\n\n")}. Check expected ${kind}s: ${expectedFilename}`
)
),
true
@ -82,9 +84,9 @@ module.exports = function checkArrayExpectation(
return (
done(
new Error(
`${upperCaseKind} ${i}: ${explain(array[i])} doesn't match ${explain(expected[
i
][j])}`
`${upperCaseKind} ${i}: ${explain(
array[i]
)} doesn't match ${explain(expected[i][j])}`
)
),
true
@ -95,9 +97,9 @@ module.exports = function checkArrayExpectation(
return (
done(
new Error(
`${upperCaseKind} ${i}: ${explain(array[i])} doesn't match ${explain(expected[
i
])}`
`${upperCaseKind} ${i}: ${explain(
array[i]
)} doesn't match ${explain(expected[i])}`
)
),
true
@ -106,7 +108,11 @@ module.exports = function checkArrayExpectation(
} else if (array.length > 0) {
return (
done(
new Error(`${upperCaseKind}s while compiling:\n\n${array.map(explain).join("\n\n")}`)
new Error(
`${upperCaseKind}s while compiling:\n\n${array
.map(explain)
.join("\n\n")}`
)
),
true
);

View File

@ -80,9 +80,7 @@ module.exports = {
.sort((a, b) => a[0] - b[0])
.map(
([i, m]) =>
`${i}: ${m.readableIdentifier(
compilation.requestShortener
)}`
`${i}: ${m.readableIdentifier(compilation.requestShortener)}`
)
.join(", ");
const indicies2 = Array.from(compilation.modules)
@ -91,9 +89,7 @@ module.exports = {
.sort((a, b) => a[0] - b[0])
.map(
([i, m]) =>
`${i}: ${m.readableIdentifier(
compilation.requestShortener
)}`
`${i}: ${m.readableIdentifier(compilation.requestShortener)}`
)
.join(", ");
expect(indicies).toEqual(

View File

@ -8,9 +8,7 @@ module.exports = {
plugins: [
function() {
this.hooks.compilation.tap("Test", compilation => {
compilation.hooks.dependencyReference.tap(
"Test",
(ref, dep) => {
compilation.hooks.dependencyReference.tap("Test", (ref, dep) => {
const module = compilation.moduleGraph.getParentModule(dep);
if (
module.identifier().endsWith("module.js") &&
@ -19,7 +17,9 @@ module.exports = {
Array.isArray(ref.importedNames) &&
ref.importedNames.includes("unused")
) {
const newExports = ref.importedNames.filter(item => item !== "unused");
const newExports = ref.importedNames.filter(
item => item !== "unused"
);
return new DependencyReference(
() => ref.module,
newExports.length > 0 ? newExports : false,
@ -28,8 +28,7 @@ module.exports = {
);
}
return ref;
}
);
});
});
}
]

View File

@ -8,9 +8,7 @@ module.exports = {
plugins: [
function() {
this.hooks.compilation.tap("Test", compilation => {
compilation.hooks.dependencyReference.tap(
"Test",
(ref, dep) => {
compilation.hooks.dependencyReference.tap("Test", (ref, dep) => {
const module = compilation.moduleGraph.getParentModule(dep);
if (
module.identifier().endsWith("module.js") &&
@ -19,7 +17,9 @@ module.exports = {
Array.isArray(ref.importedNames) &&
ref.importedNames.includes("unused")
) {
const newExports = ref.importedNames.filter(item => item !== "unused");
const newExports = ref.importedNames.filter(
item => item !== "unused"
);
return new DependencyReference(
() => ref.module,
newExports.length > 0 ? newExports : false,
@ -28,8 +28,7 @@ module.exports = {
);
}
return ref;
}
);
});
});
}
]

View File

@ -1,4 +1,4 @@
const Compiler = require('../../../../lib/Compiler');
const Compiler = require("../../../../lib/Compiler");
module.exports = {
optimization: {
@ -7,12 +7,12 @@ module.exports = {
{
apply(compiler) {
expect(compiler).toBeInstanceOf(Compiler);
},
}
},
function(compiler) {
expect(compiler).toBe(this);
expect(compiler).toBeInstanceOf(Compiler);
}
],
},
]
}
};

View File

@ -11,13 +11,10 @@ module.exports = {
{
apply: compiler => {
compiler.hooks.compilation.tap("CustomPlugin", compilation => {
compilation.hooks.optimize.tap(
"CustomPlugin",
() => {
compilation.hooks.optimize.tap("CustomPlugin", () => {
const reportProgress = webpack.ProgressPlugin.getReporter(compiler);
reportProgress(0, "custom category", "custom message");
}
);
});
});
}
}

View File

@ -1,3 +1,3 @@
module.exports = {
mode: 'development',
mode: "development"
};

View File

@ -8,7 +8,7 @@ module.exports = {
"./module": {
id: 1,
buildMeta: {
exportsType: "namespace",
exportsType: "namespace"
},
exports: ["default"]
}

View File

@ -43,13 +43,8 @@ describe("util/identifier", () => {
"c:\\some\\\\dir\\to\\\\somewhere|some/other/dir!../more/dir",
"./to/somewhere|some/other/dir!../more/dir"
],
[
"/dir",
"/dir/to/somewhere??ref-123",
"./to/somewhere??ref-123"
]
["/dir", "/dir/to/somewhere??ref-123", "./to/somewhere??ref-123"]
].forEach(([context, pathConstruct, expected]) => {
expect(identifierUtil.makePathsRelative(context, pathConstruct)).toBe(
expected
);

View File

@ -53,21 +53,26 @@ if (process.env.ALTERNATIVE_SORT) {
// Setup debugging info for tests
if (process.env.DEBUG_INFO) {
const addDebugInfo = (it) => {
const addDebugInfo = it => {
return (name, fn, timeout) => {
if (fn.length === 0) {
it(name, () => {
it(
name,
() => {
process.stdout.write(`START1 ${name}\n`);
try {
const promise = fn();
if (promise && promise.then) {
return promise.then(r => {
return promise.then(
r => {
process.stdout.write(`DONE OK ${name}\n`);
return r;
}, e => {
},
e => {
process.stdout.write(`DONE FAIL ${name}\n`);
throw e;
});
}
);
} else {
process.stdout.write(`DONE OK ${name}\n`);
}
@ -75,9 +80,13 @@ if(process.env.DEBUG_INFO) {
process.stdout.write(`DONE FAIL ${name}\n`);
throw e;
}
}, timeout);
},
timeout
);
} else {
it(name, done => {
it(
name,
done => {
process.stdout.write(`START2 ${name}\n`);
return fn(err => {
if (err) {
@ -86,11 +95,13 @@ if(process.env.DEBUG_INFO) {
process.stdout.write(`DONE OK ${name}\n`);
}
return done(err);
})
}, timeout)
}
});
},
timeout
);
}
};
};
const env = jasmine.getEnv();
env.it = addDebugInfo(env.it);
}
@ -101,4 +112,3 @@ if(process.env.DEBUG_INFO) {
require("wast-loader");
process.removeAllListeners("uncaughtException");
process.removeAllListeners("unhandledRejection");

View File

@ -3,6 +3,6 @@ module.exports = {
entry: "./index",
stats: {
modules: true,
reasons: true,
reasons: true
}
};

View File

@ -122,5 +122,5 @@ module.exports = [
}
},
stats
},
}
];

View File

@ -8,12 +8,9 @@ const valueFile = path.resolve(
module.exports = {
plugins: [
new webpack.DefinePlugin({
TEST_VALUE: webpack.DefinePlugin.runtimeValue(
() => {
TEST_VALUE: webpack.DefinePlugin.runtimeValue(() => {
return JSON.stringify(fs.readFileSync(valueFile, "utf-8").trim());
},
[valueFile]
),
}, [valueFile]),
TEST_VALUE2: webpack.DefinePlugin.runtimeValue(() => {
return JSON.stringify(fs.readFileSync(valueFile, "utf-8").trim());
}, []),

735
yarn.lock

File diff suppressed because it is too large Load Diff