This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option for custom compare function (#79)
* chore(na): change default cache directory * chore(na): remove error changes * feat: add option for custom compare function It's not always reliable to use `mtime`, so allowing for a `compare` function to be passed makes it possible for custom logic to be used. (ie. hashing) * test(na): add a simple test for the compare function * chore(na): updated info on read me for compare fn * test(na): changed return value on compare test function * test(na): second compiler call to create cache in the first place
- Loading branch information
Showing
4 changed files
with
35 additions
and
1 deletion.
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
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 @@ | ||
const { webpack } = require('./helpers'); | ||
|
||
const mockCacheLoaderCompareFn = jest.fn(); | ||
const mockWebpackConfig = { | ||
loader: { | ||
options: { | ||
compare: () => { | ||
mockCacheLoaderCompareFn(); | ||
return true; | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('compare option', () => { | ||
it('should call compare function', async () => { | ||
const testId = './basic/index.js'; | ||
await webpack(testId, mockWebpackConfig); | ||
await webpack(testId, mockWebpackConfig); | ||
expect(mockCacheLoaderCompareFn).toHaveBeenCalled(); | ||
}); | ||
}); |