Skip to content

Commit

Permalink
fix: add cacheable false to prevent webpack from caching (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: RamZallan <[email protected]>
  • Loading branch information
ricokahler and RamZallan committed May 19, 2021
1 parent 9f6ff22 commit eea75b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('_prevalLoader', () => {
describe('loader', () => {
it('throws if async is not available', () => {
expect(() => {
loader.call({ async: () => null });
loader.call({ async: () => null, cacheable: () => {} });
}).toThrowErrorMatchingInlineSnapshot(`"Async was not supported."`);
});

Expand All @@ -147,7 +147,7 @@ describe('loader', () => {
};

loader.call(
{ async: () => callback },
{ async: () => callback, cacheable: () => {} },
`
import preval from 'next-plugin-preval';
Expand All @@ -167,7 +167,7 @@ describe('loader', () => {
};

loader.call(
{ async: () => callback, resource: 'test-resource' },
{ async: () => callback, resource: 'test-resource', cacheable: () => {} },
`
import preval from 'next-plugin-preval';
Expand Down
2 changes: 2 additions & 0 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export async function _prevalLoader(
const loader: webpack.loader.Loader = function (content) {
const callback = this.async();

this.cacheable(false);

if (!callback) {
throw new PrevalError('Async was not supported.');
}
Expand Down

0 comments on commit eea75b7

Please sign in to comment.