Merge branch 'master' of https://github.com/webpack/webpack into jest

# Conflicts:
#	test/Chunk.unittest.js
#	test/NullDependency.unittest.js
#	test/SourceMapDevToolModuleOptionsPlugin.unittest.js
#	yarn.lock
This commit is contained in:
Bazyli Brzóska 2018-04-27 09:50:48 +02:00
commit 11ad57c045
6 changed files with 521 additions and 477 deletions

26
declarations.d.ts vendored
View File

@ -9,25 +9,23 @@ declare namespace NodeJS {
}
// There are no typings for chrome-trace-event
declare module 'chrome-trace-event' {
declare module "chrome-trace-event" {
interface Event {
name: string
id?: number
cat: string[]
args?: Object
name: string;
id?: number;
cat: string[];
args?: Object;
}
export class Tracer {
constructor(options: {
noStream: boolean
})
pipe(stream: NodeJS.WritableStream) : void
instantEvent(event: Event) : void
counter: number
constructor(options: { noStream: boolean });
pipe(stream: NodeJS.WritableStream): void;
instantEvent(event: Event): void;
counter: number;
trace: {
begin(event: Event) : void
end(event: Event) : void
}
begin(event: Event): void;
end(event: Event): void;
};
}
}

View File

@ -100,7 +100,9 @@ class Stats {
const optionOrLocalFallback = (v, def) =>
typeof v !== "undefined"
? v
: typeof options.all !== "undefined" ? options.all : def;
: typeof options.all !== "undefined"
? options.all
: def;
const testAgainstGivenOption = item => {
if (typeof item === "string") {
@ -266,7 +268,9 @@ class Stats {
text += `chunk ${e.chunk.name || e.chunk.id}${
e.chunk.hasRuntime()
? " [entry]"
: e.chunk.canBeInitial() ? " [initial]" : ""
: e.chunk.canBeInitial()
? " [initial]"
: ""
}\n`;
}
if (e.file) {

View File

@ -235,7 +235,9 @@ class WebpackOptionsApply extends OptionsApply {
"MappingURL=[url]\n*/"
: legacy
? "\n/*\n//@ source" + "MappingURL=[url]\n*/"
: modern ? "\n//# source" + "MappingURL=[url]" : null;
: modern
? "\n//# source" + "MappingURL=[url]"
: null;
let Plugin = evalWrapped
? EvalSourceMapDevToolPlugin
: SourceMapDevToolPlugin;
@ -259,7 +261,9 @@ class WebpackOptionsApply extends OptionsApply {
? "\n//@ sourceURL=[url]\n//# sourceURL=[url]"
: legacy
? "\n//@ sourceURL=[url]"
: modern ? "\n//# sourceURL=[url]" : null;
: modern
? "\n//# sourceURL=[url]"
: null;
new EvalDevToolModulePlugin({
sourceUrlComment: comment,
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,

View File

@ -291,11 +291,15 @@ module.exports = class SplitChunksPlugin {
minSize:
cacheGroupSource.minSize !== undefined
? cacheGroupSource.minSize
: cacheGroupSource.enforce ? 0 : this.options.minSize,
: cacheGroupSource.enforce
? 0
: this.options.minSize,
minChunks:
cacheGroupSource.minChunks !== undefined
? cacheGroupSource.minChunks
: cacheGroupSource.enforce ? 1 : this.options.minChunks,
: cacheGroupSource.enforce
? 1
: this.options.minChunks,
maxAsyncRequests:
cacheGroupSource.maxAsyncRequests !== undefined
? cacheGroupSource.maxAsyncRequests

View File

@ -3,10 +3,47 @@
const NullDependency = require("../lib/dependencies/NullDependency");
describe("NullDependency", () => {
let env;
beforeEach(() => (env = {}));
it("is a function", () => {
expect(NullDependency).toBeTypeOf("function");
});
describe("when created", () => {
beforeEach(() => (env.nullDependency = new NullDependency()));
it("has a null type", () => {
const nullDependency = new NullDependency();
expect(nullDependency.type).toBe("null");
expect(env.nullDependency.type).toBe("null");
});
it("has update hash function", () => {
expect(env.nullDependency.updateHash).toBeTypeOf("function");
});
it("does not update hash", () => {
const hash = {
update: jest.fn()
};
env.nullDependency.updateHash(hash);
expect(hash.update).not.toHaveBeenCalled();
});
});
describe("Template", () => {
it("is a function", () => {
expect(NullDependency.Template).toBeTypeOf("function");
});
describe("when created", () => {
beforeEach(() => {
env.nullDependencyTemplate = new NullDependency.Template();
});
it("has apply function", () => {
expect(env.nullDependencyTemplate.apply).toBeTypeOf("function");
});
});
});
});

907
yarn.lock

File diff suppressed because it is too large Load Diff