Skip to content

Commit 11ad57c

Browse files
committed
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
2 parents 9b8fc16 + ec83e8e commit 11ad57c

File tree

6 files changed

+521
-477
lines changed

6 files changed

+521
-477
lines changed

declarations.d.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@ declare namespace NodeJS {
99
}
1010

1111
// There are no typings for chrome-trace-event
12-
declare module 'chrome-trace-event' {
12+
declare module "chrome-trace-event" {
1313
interface Event {
14-
name: string
15-
id?: number
16-
cat: string[]
17-
args?: Object
14+
name: string;
15+
id?: number;
16+
cat: string[];
17+
args?: Object;
1818
}
1919

2020
export class Tracer {
21-
constructor(options: {
22-
noStream: boolean
23-
})
24-
pipe(stream: NodeJS.WritableStream) : void
25-
instantEvent(event: Event) : void
26-
counter: number
21+
constructor(options: { noStream: boolean });
22+
pipe(stream: NodeJS.WritableStream): void;
23+
instantEvent(event: Event): void;
24+
counter: number;
2725
trace: {
28-
begin(event: Event) : void
29-
end(event: Event) : void
30-
}
26+
begin(event: Event): void;
27+
end(event: Event): void;
28+
};
3129
}
3230
}
3331

lib/Stats.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ class Stats {
100100
const optionOrLocalFallback = (v, def) =>
101101
typeof v !== "undefined"
102102
? v
103-
: typeof options.all !== "undefined" ? options.all : def;
103+
: typeof options.all !== "undefined"
104+
? options.all
105+
: def;
104106

105107
const testAgainstGivenOption = item => {
106108
if (typeof item === "string") {
@@ -266,7 +268,9 @@ class Stats {
266268
text += `chunk ${e.chunk.name || e.chunk.id}${
267269
e.chunk.hasRuntime()
268270
? " [entry]"
269-
: e.chunk.canBeInitial() ? " [initial]" : ""
271+
: e.chunk.canBeInitial()
272+
? " [initial]"
273+
: ""
270274
}\n`;
271275
}
272276
if (e.file) {

lib/WebpackOptionsApply.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ class WebpackOptionsApply extends OptionsApply {
235235
"MappingURL=[url]\n*/"
236236
: legacy
237237
? "\n/*\n//@ source" + "MappingURL=[url]\n*/"
238-
: modern ? "\n//# source" + "MappingURL=[url]" : null;
238+
: modern
239+
? "\n//# source" + "MappingURL=[url]"
240+
: null;
239241
let Plugin = evalWrapped
240242
? EvalSourceMapDevToolPlugin
241243
: SourceMapDevToolPlugin;
@@ -259,7 +261,9 @@ class WebpackOptionsApply extends OptionsApply {
259261
? "\n//@ sourceURL=[url]\n//# sourceURL=[url]"
260262
: legacy
261263
? "\n//@ sourceURL=[url]"
262-
: modern ? "\n//# sourceURL=[url]" : null;
264+
: modern
265+
? "\n//# sourceURL=[url]"
266+
: null;
263267
new EvalDevToolModulePlugin({
264268
sourceUrlComment: comment,
265269
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,

lib/optimize/SplitChunksPlugin.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,15 @@ module.exports = class SplitChunksPlugin {
291291
minSize:
292292
cacheGroupSource.minSize !== undefined
293293
? cacheGroupSource.minSize
294-
: cacheGroupSource.enforce ? 0 : this.options.minSize,
294+
: cacheGroupSource.enforce
295+
? 0
296+
: this.options.minSize,
295297
minChunks:
296298
cacheGroupSource.minChunks !== undefined
297299
? cacheGroupSource.minChunks
298-
: cacheGroupSource.enforce ? 1 : this.options.minChunks,
300+
: cacheGroupSource.enforce
301+
? 1
302+
: this.options.minChunks,
299303
maxAsyncRequests:
300304
cacheGroupSource.maxAsyncRequests !== undefined
301305
? cacheGroupSource.maxAsyncRequests

test/NullDependency.unittest.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,47 @@
33
const NullDependency = require("../lib/dependencies/NullDependency");
44

55
describe("NullDependency", () => {
6+
let env;
7+
8+
beforeEach(() => (env = {}));
9+
10+
it("is a function", () => {
11+
expect(NullDependency).toBeTypeOf("function");
12+
});
13+
614
describe("when created", () => {
15+
beforeEach(() => (env.nullDependency = new NullDependency()));
16+
717
it("has a null type", () => {
8-
const nullDependency = new NullDependency();
9-
expect(nullDependency.type).toBe("null");
18+
expect(env.nullDependency.type).toBe("null");
19+
});
20+
21+
it("has update hash function", () => {
22+
expect(env.nullDependency.updateHash).toBeTypeOf("function");
23+
});
24+
25+
it("does not update hash", () => {
26+
const hash = {
27+
update: jest.fn()
28+
};
29+
env.nullDependency.updateHash(hash);
30+
expect(hash.update).not.toHaveBeenCalled();
31+
});
32+
});
33+
34+
describe("Template", () => {
35+
it("is a function", () => {
36+
expect(NullDependency.Template).toBeTypeOf("function");
37+
});
38+
39+
describe("when created", () => {
40+
beforeEach(() => {
41+
env.nullDependencyTemplate = new NullDependency.Template();
42+
});
43+
44+
it("has apply function", () => {
45+
expect(env.nullDependencyTemplate.apply).toBeTypeOf("function");
46+
});
1047
});
1148
});
1249
});

0 commit comments

Comments
 (0)