mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
Fix circular dependencies
This commit is contained in:
parent
bbc4e55bda
commit
739ef6a8ec
1 changed files with 8 additions and 5 deletions
|
@ -77,6 +77,7 @@ export class ModuleMetaData implements ts.IScriptSnapshot {
|
|||
public deps?: ModuleFileName[];
|
||||
public readonly exports = {};
|
||||
public factory?: AmdFactory;
|
||||
public gatheringDeps = false;
|
||||
public hasRun = false;
|
||||
public scriptVersion = "";
|
||||
|
||||
|
@ -250,10 +251,6 @@ export class DenoCompiler implements ts.LanguageServiceHost {
|
|||
}
|
||||
const dependencyMetaData = this._getModuleMetaData(dep);
|
||||
assert(dependencyMetaData != null, `Missing dependency "${dep}".`);
|
||||
assert(
|
||||
dependencyMetaData!.hasRun === true,
|
||||
`Module "${dep}" was not run.`
|
||||
);
|
||||
// TypeScript does not track assert, therefore using not null operator
|
||||
return dependencyMetaData!.exports;
|
||||
});
|
||||
|
@ -436,6 +433,9 @@ export class DenoCompiler implements ts.LanguageServiceHost {
|
|||
): void => {
|
||||
this._log("compiler.localDefine", moduleMetaData.fileName);
|
||||
moduleMetaData.factory = factory;
|
||||
// when there are circular dependencies, we need to skip recursing the
|
||||
// dependencies
|
||||
moduleMetaData.gatheringDeps = true;
|
||||
// we will recursively resolve the dependencies for any modules
|
||||
moduleMetaData.deps = deps.map(dep => {
|
||||
if (
|
||||
|
@ -449,9 +449,12 @@ export class DenoCompiler implements ts.LanguageServiceHost {
|
|||
dep,
|
||||
moduleMetaData.fileName
|
||||
);
|
||||
if (!dependencyMetaData.gatheringDeps) {
|
||||
this._gatherDependencies(dependencyMetaData);
|
||||
}
|
||||
return dependencyMetaData.fileName;
|
||||
});
|
||||
moduleMetaData.gatheringDeps = false;
|
||||
if (!this._runQueue.includes(moduleMetaData)) {
|
||||
this._runQueue.push(moduleMetaData);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue