-
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add module_executor module update test
- Loading branch information
1 parent
8b0f43f
commit f782685
Showing
7 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...s/tests/hotCases/loader/import-module-executor-module-update/__snapshots__/web/0.snap.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,12 @@ | ||
# Case import-module-executor-module-update: Step 0 | ||
|
||
## Changed Files | ||
|
||
|
||
## Asset Files | ||
- Bundle: bundle.js | ||
|
||
## Manifest | ||
|
||
|
||
## Update |
51 changes: 51 additions & 0 deletions
51
...s/tests/hotCases/loader/import-module-executor-module-update/__snapshots__/web/1.snap.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,51 @@ | ||
# Case import-module-executor-module-update: Step 1 | ||
|
||
## Changed Files | ||
- import_module_sub.js | ||
|
||
## Asset Files | ||
- Bundle: bundle.js | ||
- Manifest: main.LAST_HASH.hot-update.json, size: 28 | ||
- Update: main.LAST_HASH.hot-update.js, size: 258 | ||
|
||
## Manifest | ||
|
||
### main.LAST_HASH.hot-update.json | ||
|
||
```json | ||
{"c":["main"],"r":[],"m":[]} | ||
``` | ||
|
||
|
||
## Update | ||
|
||
|
||
### main.LAST_HASH.hot-update.js | ||
|
||
#### Changed Modules | ||
- ./loader.js!./a.js | ||
|
||
#### Changed Runtime Modules | ||
- webpack/runtime/get_full_hash | ||
|
||
#### Changed Content | ||
```js | ||
self["webpackHotUpdate"]('main', { | ||
"./loader.js!./a.js": (function (module) { | ||
module.exports = 3; | ||
|
||
|
||
}), | ||
|
||
},function(__webpack_require__) { | ||
// webpack/runtime/get_full_hash | ||
(() => { | ||
__webpack_require__.h = function () { | ||
return "CURRENT_HASH"; | ||
}; | ||
|
||
})(); | ||
|
||
} | ||
); | ||
``` |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/hotCases/loader/import-module-executor-module-update/a.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 = 1; |
3 changes: 3 additions & 0 deletions
3
...st-tools/tests/hotCases/loader/import-module-executor-module-update/import_module_root.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,3 @@ | ||
const loader = require("./import_module_sub.js"); | ||
|
||
module.exports = loader; |
3 changes: 3 additions & 0 deletions
3
...est-tools/tests/hotCases/loader/import-module-executor-module-update/import_module_sub.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,3 @@ | ||
module.exports = 2; | ||
--- | ||
module.exports = 3; |
11 changes: 11 additions & 0 deletions
11
...ges/rspack-test-tools/tests/hotCases/loader/import-module-executor-module-update/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("module and its loader-referencing module should update in right order", done => { | ||
expect(require("./loader.js!./a")).toBe(2); | ||
NEXT( | ||
require("../../update")(done, true, () => { | ||
expect(require("./loader.js!./a")).toBe(3); | ||
done(); | ||
}) | ||
); | ||
}); | ||
|
||
module.hot.accept("./loader.js!./a"); |
4 changes: 4 additions & 0 deletions
4
...es/rspack-test-tools/tests/hotCases/loader/import-module-executor-module-update/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,4 @@ | ||
module.exports = async function (content) { | ||
let res = await this.importModule("./import_module_root.js"); | ||
return content.replace("1", res); | ||
}; |