-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13276 from webpack/bugfix/emit-caching
emit assets even when they were cleaned from fs in the meantime
- Loading branch information
Showing
20 changed files
with
156 additions
and
13 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,5 @@ | ||
it("should not emit files", () => { | ||
expect(STATS_JSON.assets.map(a => a.name)).not.toContainEqual( | ||
expect.stringMatching(/\.txt$/) | ||
); | ||
}); |
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,19 @@ | ||
import { stat } from "fs"; | ||
import { promisify } from "util"; | ||
|
||
it("should return a valid url when cached", async () => { | ||
const url = new URL("file.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should return a valid url when modified", async () => { | ||
const url = new URL("other.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should not emit undefined files", () => { | ||
expect(STATS_JSON.assets.map(a => a.name)).not.toContain(undefined); | ||
expect(STATS_JSON.assets.map(a => a.name)).not.toContain("undefined"); | ||
}); |
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 @@ | ||
Hello World |
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,14 @@ | ||
import { stat } from "fs"; | ||
import { promisify } from "util"; | ||
|
||
it("should return a valid url when cached", async () => { | ||
const url = new URL("file.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should return a valid url when modified", async () => { | ||
const url = new URL("other.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(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 @@ | ||
Hello World 2 |
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 @@ | ||
Hello World |
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 @@ | ||
Hello World 3 |
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,5 @@ | ||
it("should not emit files", () => { | ||
expect(STATS_JSON.assets.map(a => a.name)).not.toContainEqual( | ||
expect.stringMatching(/\.txt$/) | ||
); | ||
}); |
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 @@ | ||
import { stat } from "fs"; | ||
import { promisify } from "util"; | ||
|
||
it("should return a valid url when cached", async () => { | ||
const url = new URL("file.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should return a valid url when modified", async () => { | ||
const url = new URL("other.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should not rewrite files and only compare them", () => { | ||
for (const asset of STATS_JSON.assets) { | ||
if (asset.name.endsWith(".txt")) { | ||
expect(asset).toHaveProperty("emitted", 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,5 @@ | ||
module.exports = { | ||
output: { | ||
clean: 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 @@ | ||
Hello World |
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,14 @@ | ||
import { stat } from "fs"; | ||
import { promisify } from "util"; | ||
|
||
it("should return a valid url when cached", async () => { | ||
const url = new URL("file.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should return a valid url when modified", async () => { | ||
const url = new URL("other.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(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 @@ | ||
Hello World 2 |
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 @@ | ||
Hello World |
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 @@ | ||
Hello World 3 |
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,5 @@ | ||
it("should not emit files", () => { | ||
expect(STATS_JSON.assets.map(a => a.name)).not.toContainEqual( | ||
expect.stringMatching(/\.txt$/) | ||
); | ||
}); |
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 @@ | ||
import { stat } from "fs"; | ||
import { promisify } from "util"; | ||
|
||
it("should return a valid url when cached", async () => { | ||
const url = new URL("file.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should return a valid url when modified", async () => { | ||
const url = new URL("other.txt", import.meta.url); | ||
expect(url.pathname).toMatch(/\.txt$/); | ||
expect((await promisify(stat)(url)).isFile()).toBe(true); | ||
}); | ||
|
||
it("should not rewrite files and only compare them", () => { | ||
for (const asset of STATS_JSON.assets) { | ||
if (asset.name.endsWith(".txt")) { | ||
expect(asset).toHaveProperty("cached", 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,5 @@ | ||
module.exports = { | ||
output: { | ||
clean: false | ||
} | ||
}; |