diff --git a/packages/malloy/src/lang/parse-malloy.ts b/packages/malloy/src/lang/parse-malloy.ts index 9e22ee86c..22ee46692 100644 --- a/packages/malloy/src/lang/parse-malloy.ts +++ b/packages/malloy/src/lang/parse-malloy.ts @@ -781,6 +781,10 @@ export abstract class MalloyTranslation { } const newModels: {url: string; modelDef: ModelDef}[] = []; for (const [url, child] of this.childTranslators) { + const pretranslated = this.root.pretranslatedModels.get(url); + if (pretranslated !== undefined) { + continue; + } const result = child.translate(); if (result.modelDef) { newModels.push({url, modelDef: result.modelDef}); diff --git a/packages/malloy/src/lang/test/imports.spec.ts b/packages/malloy/src/lang/test/imports.spec.ts index 90874d679..208eac451 100644 --- a/packages/malloy/src/lang/test/imports.spec.ts +++ b/packages/malloy/src/lang/test/imports.spec.ts @@ -136,17 +136,23 @@ source: botProjQSrc is botProjQ urls: {'internal://test/langtests/grandChild': '// empty file'}, }); expect(docParse).toTranslate(); - const sources = docParse.translate().fromSources; + const translated = docParse.translate(); + const sources = translated.fromSources; expect(sources).toEqual([ 'internal://test/langtests/root.malloy', 'internal://test/langtests/child', 'internal://test/langtests/grandChild', ]); - expect(docParse.translate().modelDef?.dependencies).toMatchObject({ + expect(translated.modelDef?.dependencies).toMatchObject({ 'internal://test/langtests/child': { 'internal://test/langtests/grandChild': {}, }, }); + const newDependencies = docParse.newlyTranslatedDependencies(); + expect(newDependencies).toMatchObject([ + {url: 'internal://test/langtests/child', modelDef: {}}, + {url: 'internal://test/langtests/grandChild', modelDef: {}}, + ]); const child = docParse.translatorForDependency( 'internal://test/langtests/child' ); diff --git a/packages/malloy/src/lang/test/pretranslate.spec.ts b/packages/malloy/src/lang/test/pretranslate.spec.ts index 85bee6568..20ee74512 100644 --- a/packages/malloy/src/lang/test/pretranslate.spec.ts +++ b/packages/malloy/src/lang/test/pretranslate.spec.ts @@ -51,6 +51,8 @@ describe('pretranslated models', () => { }, }, }); + const newDependencies = docParse.newlyTranslatedDependencies(); + expect(newDependencies).toMatchObject([]); expect(translated.fromSources).toEqual([ 'internal://test/langtests/root.malloy', 'internal://test/langtests/child',