Fix caching and add bundle compile lock
MODIFY
packages/@romejs/core/master/Cache.ts
packages/@romejs/core/master/Cache.ts
@@ -114,7 +114,7 @@ export default class Cache {
// If we have a loaded memory entry, make sure it's valid compared to the default entry (file changes etc)
let loaded = this.loadedEntries.get(path);
if (loaded !== undefined && areEntriesEqual(loaded, emptyEntry)) {
- return emptyEntry;
+ return loaded;
}
if (this.disabled) {

MODIFY
packages/@romejs/core/master/bundler/BundleRequest.ts
packages/@romejs/core/master/bundler/BundleRequest.ts
@@ -183,6 +183,8 @@ export default class BundleRequest {
assetPath,
};
+ const lock = await this.bundler.compileLocker.getLock(source);
+
const res: WorkerCompileResult = await this.bundler.request.requestWorkerCompile(
path,
'compileForBundle',
@@ -192,6 +194,8 @@ export default class BundleRequest {
{},
);
+ lock.release();
+
if (!res.cached) {
this.cached = false;
}

MODIFY
packages/@romejs/core/master/bundler/Bundler.ts
packages/@romejs/core/master/bundler/Bundler.ts
@@ -28,6 +28,7 @@ import {Dict} from '@romejs/typescript-helpers';
import {readFile} from '@romejs/fs';
import {flipPathPatterns} from '@romejs/path-match';
import {markup} from '@romejs/string-markup';
+import Locker from '@romejs/core/common/utils/Locker';
export type BundlerEntryResoluton = {
manifestDef: undefined | ManifestDefinition;
@@ -43,9 +44,11 @@ export default class Bundler {
this.entries = [];
+ this.compileLocker = new Locker();
this.graph = new DependencyGraph(req, config.resolver);
}
+ compileLocker: Locker<string>;
graph: DependencyGraph;
master: Master;
request: MasterRequest;

Fix caching and add bundle compile lock