-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should run next invalidation when watching is invalid
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/rspack-test-tools/tests/compilerCases/invalidation-multi-times.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,47 @@ | ||
const path = require('path'); | ||
|
||
const mockFn = jest.fn(() => {}); | ||
|
||
class MyPlugin { | ||
apply(compiler) { | ||
compiler.hooks.watchRun.tap("MyPlugin", mockFn) | ||
} | ||
} | ||
|
||
/** @type {import('../../dist').TCompilerCaseConfig} */ | ||
module.exports = { | ||
description: "should be invalidated correctly", | ||
options(context) { | ||
return { | ||
context: context.getSource(), | ||
entry: "./abc", | ||
plugins: [new MyPlugin()] | ||
}; | ||
}, | ||
async build(_, compiler) { | ||
try { | ||
await new Promise((resolve, reject) => { | ||
let firstRun = true; | ||
compiler.watch({}, (err) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
if (firstRun) { | ||
firstRun = false; | ||
compiler.watching.lazyCompilationInvalidate(path.resolve(__dirname, "../fixtures/a.js")); | ||
compiler.watching.lazyCompilationInvalidate(path.resolve(__dirname, "../fixtures/b.js")); | ||
setTimeout(() => { | ||
resolve() | ||
}, 2000) | ||
} | ||
}); | ||
}); | ||
} catch(err) { | ||
throw err | ||
} | ||
|
||
}, | ||
async check() { | ||
expect(mockFn).toHaveBeenCalledTimes(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