Skip to content

Commit

Permalink
fix: avoid writing unchanged virtual modules to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Aug 7, 2020
1 parent be9429b commit ab30570
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,19 @@ export default function(source: string): void | string {
path.dirname(this.resourcePath),
dep.virtualPath
);
const virtualModules = getVirtualModules(this._compiler);
virtualModules.writeModule(virtualPath, dep.code);

// We don't want to hit the disk, but instead check if the viritual file was already written.
const existingContent =
this.fs._readFileStorage &&
this.fs._readFileStorage.data.get(virtualPath);

if (!existingContent || existingContent[1] !== dep.code) {
getVirtualModules(this._compiler).writeModule(
virtualPath,
dep.code
);
}

dependencies.push(loadStr(dep.virtualPath));
}
}
Expand Down

0 comments on commit ab30570

Please sign in to comment.