Skip to content

Commit

Permalink
Simplify invalidateOnFileChange() in Transformers (#9379)
Browse files Browse the repository at this point in the history
Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
  • Loading branch information
grishy and mischnic authored Nov 13, 2023
1 parent c784885 commit c88116a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions packages/transformers/posthtml/src/PostHTMLTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,11 @@ export default (new Transformer({
});

if (res.messages) {
await Promise.all(
res.messages.map(({type, file: filePath}) => {
if (type === 'dependency') {
return asset.invalidateOnFileChange(filePath);
}
return Promise.resolve();
}),
);
for (let {type, file: filePath} of res.messages) {
if (type === 'dependency') {
asset.invalidateOnFileChange(filePath);
}
}
}

asset.setAST({
Expand Down
2 changes: 1 addition & 1 deletion packages/transformers/pug/src/PugTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default (new Transformer({
});

for (let filePath of render.dependencies) {
await asset.invalidateOnFileChange(filePath);
asset.invalidateOnFileChange(filePath);
}

asset.type = 'html';
Expand Down
2 changes: 1 addition & 1 deletion packages/transformers/stylus/src/StylusTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async function getDependencies(
// Recursively process resolved files as well to get nested deps
for (let resolved of found) {
if (!seen.has(resolved)) {
await asset.invalidateOnFileChange(resolved);
asset.invalidateOnFileChange(resolved);

let code = await asset.fs.readFile(resolved, 'utf8');
for (let [path, resolvedPath] of await getDependencies(
Expand Down

0 comments on commit c88116a

Please sign in to comment.