-
-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: file dependencies lost when incremental compiling failed in css …
…module
- Loading branch information
1 parent
d5c5508
commit d53c14e
Showing
16 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/0/dep.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 @@ | ||
color: blue; |
2 changes: 2 additions & 0 deletions
2
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/0/entry.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,2 @@ | ||
background: red; | ||
$dep$ |
11 changes: 11 additions & 0 deletions
11
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/0/index.js
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,11 @@ | ||
it("should have correct value", () => { | ||
if (WATCH_STEP === "0") { | ||
expect(require("./entry.txt").myClass).toBeTruthy(); | ||
} else if (WATCH_STEP === "1") { | ||
expect(() => { | ||
require("./entry.txt") | ||
}).toThrow(); | ||
} else if (WATCH_STEP === "2") { | ||
expect(require("./entry.txt").myClass).toBeTruthy(); | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/1/dep.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 @@ | ||
fail |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/1/errors.js
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 @@ | ||
module.exports = [/Failed/, /Module build failed/]; |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/2/dep.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 @@ | ||
color: blueviolet; |
13 changes: 13 additions & 0 deletions
13
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/loader.js
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,13 @@ | ||
const fs = require("fs"); | ||
|
||
module.exports = function (source) { | ||
const depPath = this.resource.replace("entry.txt", "dep.txt"); | ||
this.addDependency(depPath); | ||
const depContent = fs.readFileSync(depPath, 'utf-8'); | ||
if (depContent === "fail") { | ||
throw new Error("Failed"); | ||
} | ||
return `.my-class { | ||
${source.replace("$dep$", depContent)} | ||
}`; | ||
}; |
37 changes: 37 additions & 0 deletions
37
.../rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed-css/rspack.config.js
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,37 @@ | ||
const path = require("path"); | ||
const rspack = require('@rspack/core'); | ||
|
||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
module: { | ||
rules: [{ | ||
test: /.txt$/, | ||
type: 'javascript/auto', | ||
use: [ | ||
{ | ||
loader: rspack.CssExtractRspackPlugin.loader, | ||
}, | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
namedExport: true | ||
} | ||
} | ||
}, | ||
{ | ||
loader: path.resolve(__dirname, './loader.js') | ||
} | ||
] | ||
}] | ||
}, | ||
plugins: [ | ||
new rspack.CssExtractRspackPlugin(), | ||
], | ||
experiments: { | ||
css: false | ||
}, | ||
resolve: { | ||
extensions: ["...", ".txt"] | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/0/dep.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 @@ | ||
dep0 |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/0/entry.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 @@ | ||
entry for $dep$ |
11 changes: 11 additions & 0 deletions
11
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/0/index.js
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,11 @@ | ||
it("should have correct value", () => { | ||
if (WATCH_STEP === "0") { | ||
expect(require("./entry.txt")).toBe("entry for dep0"); | ||
} else if (WATCH_STEP === "1") { | ||
expect(() => { | ||
require("./entry.txt") | ||
}).toThrow(); | ||
} else if (WATCH_STEP === "2") { | ||
expect(require("./entry.txt")).toBe("entry for dep2"); | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/1/dep.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 @@ | ||
fail |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/1/errors.js
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 @@ | ||
module.exports = [[/Failed/]]; |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/2/dep.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 @@ | ||
dep2 |
11 changes: 11 additions & 0 deletions
11
packages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/loader.js
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,11 @@ | ||
const fs = require("fs"); | ||
|
||
module.exports = function (source) { | ||
const depPath = this.resource.replace("entry.txt", "dep.txt"); | ||
this.addDependency(depPath); | ||
const depContent = fs.readFileSync(depPath, 'utf-8'); | ||
if (depContent === "fail") { | ||
throw new Error("Failed"); | ||
} | ||
return `module.exports = "${source.replace("$dep$", depContent)}"`; | ||
}; |
14 changes: 14 additions & 0 deletions
14
...ages/rspack-test-tools/tests/watchCases/build-failed/watch-loader-failed/rspack.config.js
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 @@ | ||
const path = require("path"); | ||
|
||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
module: { | ||
rules: [{ | ||
test: /.txt$/, | ||
loader: path.resolve(__dirname, './loader.js') | ||
}] | ||
}, | ||
resolve: { | ||
extensions: ["...", ".txt"] | ||
} | ||
}; |