Skip to content

Commit

Permalink
test: add module_executor module update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykingxyz committed Dec 5, 2024
1 parent 8b0f43f commit f782685
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 0 deletions.
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
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";
};

})();

}
);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const loader = require("./import_module_sub.js");

module.exports = loader;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = 2;
---
module.exports = 3;
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");
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);
};

0 comments on commit f782685

Please sign in to comment.