From 0d89a648ec24ec30339b6ea785f5623977d660b9 Mon Sep 17 00:00:00 2001 From: machty Date: Tue, 2 Jul 2024 13:55:10 -0400 Subject: [PATCH 1/4] get a few composite tests pasing --- packages/core/__tests__/cli/build.test.ts | 96 +++++++++---------- .../test-utils/src/composite-project.ts | 27 +++++- 2 files changed, 74 insertions(+), 49 deletions(-) diff --git a/packages/core/__tests__/cli/build.test.ts b/packages/core/__tests__/cli/build.test.ts index 7532fbbf1..cca0de57b 100644 --- a/packages/core/__tests__/cli/build.test.ts +++ b/packages/core/__tests__/cli/build.test.ts @@ -138,7 +138,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); }); - describe.skip('composite projects', () => { + describe('composite projects', () => { // The basic structure here is designed to give minimal coverage over all // interesting combinations of project invalidation: // @@ -218,11 +218,11 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('passes a valid composite project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let result = await projects.main.buildDeclaration({ reject: false }); - expect(checkResult.exitCode).toBe(0); - expect(checkResult.stdout).toEqual(''); - // expect(checkResult.stderr).toEqual(''); + expect(result.exitCode).toBe(0); + expect(result.stdout).toEqual(''); + expect(result.stderr).toEqual(''); expect(existsSync(projects.children.a.filePath(INDEX_D_TS))).toBe(true); expect(existsSync(projects.children.b.filePath(INDEX_D_TS))).toBe(true); @@ -230,11 +230,11 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('passes a valid composite subproject with a reference', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let result = await projects.children.a.buildDeclaration({ reject: false }); - expect(checkResult.exitCode).toBe(0); - expect(checkResult.stdout).toEqual(''); - expect(checkResult.stderr).toEqual(''); + expect(result.exitCode).toBe(0); + expect(result.stdout).toEqual(''); + expect(result.stderr).toEqual(''); expect(existsSync(projects.children.a.filePath(INDEX_D_TS))).toBe(true); expect(existsSync(projects.children.b.filePath(INDEX_D_TS))).toBe(false); @@ -242,11 +242,11 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('passes a valid composite subproject with no references', async () => { - let checkResult = await projects.children.b.build({ reject: false }); + let result = await projects.children.b.buildDeclaration({ reject: false }); - expect(checkResult.exitCode).toBe(0); - expect(checkResult.stdout).toEqual(''); - expect(checkResult.stderr).toEqual(''); + expect(result.exitCode).toBe(0); + expect(result.stdout).toEqual(''); + expect(result.stderr).toEqual(''); expect(existsSync(projects.children.a.filePath(INDEX_D_TS))).toBe(false); expect(existsSync(projects.children.b.filePath(INDEX_D_TS))).toBe(true); @@ -303,7 +303,7 @@ describe('CLI: single-pass build mode typechecking', () => { projects.main.write(INPUT_SFC, rootCode); - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); expect(stripAnsi(checkResult.stderr)).toMatchInlineSnapshot(` @@ -342,7 +342,7 @@ describe('CLI: single-pass build mode typechecking', () => { projects.main.write(INPUT_SFC, rootCode); - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); expect(stripAnsi(checkResult.stderr)).toMatchInlineSnapshot(` @@ -390,7 +390,7 @@ describe('CLI: single-pass build mode typechecking', () => { projects.main.write(INPUT_SFC, rootCode); - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); expect(stripAnsi(checkResult.stderr)).toMatchInlineSnapshot(` @@ -456,7 +456,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -474,7 +474,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the subproject', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let checkResult = await projects.children.a.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -505,7 +505,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -526,7 +526,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the subproject', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let checkResult = await projects.children.a.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -561,7 +561,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -579,7 +579,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the subproject', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let checkResult = await projects.children.a.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -615,7 +615,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(0); expect(checkResult.stdout).toEqual(''); @@ -627,7 +627,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the subproject', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let checkResult = await projects.children.a.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(0); expect(checkResult.stdout).toEqual(''); @@ -688,7 +688,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -706,7 +706,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the subproject', async () => { - let checkResult = await projects.children.b.build({ reject: false }); + let checkResult = await projects.children.b.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -736,7 +736,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -757,7 +757,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the subproject', async () => { - let checkResult = await projects.children.b.build({ reject: false }); + let checkResult = await projects.children.b.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -791,7 +791,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -809,7 +809,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('build from the subproject', async () => { - let checkResult = await projects.children.b.build({ reject: false }); + let checkResult = await projects.children.b.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -875,7 +875,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -893,7 +893,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the intermediate project', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let checkResult = await projects.children.a.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -911,7 +911,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the transitively referenced project', async () => { - let checkResult = await projects.children.c.build({ reject: false }); + let checkResult = await projects.children.c.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -941,7 +941,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -962,7 +962,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the intermediate project', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let checkResult = await projects.children.a.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -983,7 +983,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the transitively referenced project', async () => { - let checkResult = await projects.children.c.build({ reject: false }); + let checkResult = await projects.children.c.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -1017,7 +1017,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the main project', async () => { - let checkResult = await projects.main.build({ reject: false }); + let checkResult = await projects.main.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(2); expect(checkResult.stdout).toEqual(''); @@ -1035,7 +1035,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the intermediate project', async () => { - let checkResult = await projects.children.a.build({ reject: false }); + let checkResult = await projects.children.a.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -1053,7 +1053,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); test('built from the transitively referenced project', async () => { - let checkResult = await projects.children.c.build({ reject: false }); + let checkResult = await projects.children.c.buildDeclaration({ reject: false }); expect(checkResult.exitCode).toBe(1); expect(checkResult.stdout).toEqual(''); @@ -1151,7 +1151,7 @@ describe.skip('CLI: --build --clean', () => { projects.children.b.write(INPUT_SFC, bCode); projects.children.c.write(INPUT_SFC, cCode); - let buildResult = await projects.main.build(); + let buildResult = await projects.main.buildDeclaration(); expect(buildResult.exitCode).toBe(0); expect(buildResult.stdout).toEqual(''); expect(buildResult.stderr).toEqual(''); @@ -1159,7 +1159,7 @@ describe.skip('CLI: --build --clean', () => { expect(existsSync(projects.children.b.filePath(INDEX_D_TS))).toBe(true); expect(existsSync(projects.children.c.filePath(INDEX_D_TS))).toBe(true); - let buildCleanResult = await projects.main.build({ flags: ['--clean'] }); + let buildCleanResult = await projects.main.buildDeclaration({ flags: ['--clean'] }); expect(buildCleanResult.exitCode).toBe(0); expect(buildCleanResult.stdout).toEqual(''); expect(buildCleanResult.stderr).toEqual(''); @@ -1251,7 +1251,7 @@ describe.skip('CLI: --build --force', () => { projects.children.b.write(INPUT_SFC, bCode); projects.children.c.write(INPUT_SFC, cCode); - let buildResult = await projects.main.build(); + let buildResult = await projects.main.buildDeclaration(); expect(buildResult.exitCode).toBe(0); expect(buildResult.stdout).toEqual(''); expect(buildResult.stderr).toEqual(''); @@ -1260,7 +1260,7 @@ describe.skip('CLI: --build --force', () => { let firstBStat = statSync(projects.children.b.filePath(INDEX_D_TS)); let firstCStat = statSync(projects.children.c.filePath(INDEX_D_TS)); - let buildCleanResult = await projects.main.build({ flags: ['--force'] }); + let buildCleanResult = await projects.main.buildDeclaration({ flags: ['--force'] }); expect(buildCleanResult.exitCode).toBe(0); expect(buildCleanResult.stdout).toEqual(''); expect(buildCleanResult.stderr).toEqual(''); @@ -1504,7 +1504,7 @@ describe.skip('CLI: --build --dry', () => { }); test('when no build has occurred', async () => { - let buildResult = await projects.root.build({ flags: ['--dry'] }); + let buildResult = await projects.root.buildDeclaration({ flags: ['--dry'] }); expect(buildResult.exitCode).toBe(0); expect(stripAnsi(buildResult.stdout)).toMatch( `A non-dry build would build project '${projects.main.filePath('tsconfig.json')}'`, @@ -1523,11 +1523,11 @@ describe.skip('CLI: --build --dry', () => { describe('when the project has been built', () => { beforeEach(async () => { - await projects.root.build(); + await projects.root.buildDeclaration(); }); test('and there are no changes', async () => { - let buildResult = await projects.root.build({ flags: ['--dry'] }); + let buildResult = await projects.root.buildDeclaration({ flags: ['--dry'] }); expect(buildResult.exitCode).toBe(0); expect(stripAnsi(buildResult.stdout)).toMatch( `Project '${projects.main.filePath('tsconfig.json')}' is up to date`, @@ -1566,7 +1566,7 @@ describe.skip('CLI: --build --dry', () => { `; projects.main.write(INPUT_SFC, rootCode); - let buildResult = await projects.root.build({ flags: ['--dry'] }); + let buildResult = await projects.root.buildDeclaration({ flags: ['--dry'] }); expect(buildResult.exitCode).toBe(0); expect(stripAnsi(buildResult.stdout)).toMatch( `A non-dry build would build project '${projects.main.filePath('tsconfig.json')}'`, @@ -1591,7 +1591,7 @@ describe.skip('CLI: --build --dry', () => { `; projects.children.a.write(INPUT_SFC, aCode); - let buildResult = await projects.root.build({ flags: ['--dry'] }); + let buildResult = await projects.root.buildDeclaration({ flags: ['--dry'] }); expect(buildResult.exitCode).toBe(0); expect(stripAnsi(buildResult.stdout)).toMatch( `A non-dry build would build project '${projects.main.filePath('tsconfig.json')}'`, diff --git a/test-packages/test-utils/src/composite-project.ts b/test-packages/test-utils/src/composite-project.ts index becd4aa4c..79c4bb528 100644 --- a/test-packages/test-utils/src/composite-project.ts +++ b/test-packages/test-utils/src/composite-project.ts @@ -9,7 +9,11 @@ export const INPUT_SCRIPT = path.join(INPUT_DIR, 'index.ts'); export const INPUT_TEMPLATE = path.join(INPUT_DIR, 'index.hbs'); export const OUT_DIR = 'dist'; -export const INDEX_D_TS = path.join(OUT_DIR, 'index.d.ts'); + +// Changed for Volar from `index.d.ts`. Changing to `index.gts.d.ts` brings +// this more closely in line with Vue and others' solutions for `.d.ts` files +// on custom extensions, but we need to see how wide the breaking changes are. +export const INDEX_D_TS = path.join(OUT_DIR, 'index.gts.d.ts'); export const BASE_TS_CONFIG = { compilerOptions: { @@ -67,6 +71,27 @@ export async function setupCompositeProject(): Promise { root.mkdir('local-types'); root.write('local-types/index.d.ts', 'import "@glint/environment-ember-template-imports";'); + /** + * Project Structure: + * + * ---> a + * / + * - main + * \ + * ---> b ---> c + * + * Flattened: + * + * - main + * - reference/dependency a + * - reference/dependency b + * - a + * - reference/dependency c + * - b + * - no references + * - c + * - no references + */ let main = await Project.createExact( { extends: `../${SHARED_TSCONFIG}`, From a77f3f4190d585617f0ea062ecc43cff1aa77201 Mon Sep 17 00:00:00 2001 From: machty Date: Tue, 2 Jul 2024 17:59:13 -0400 Subject: [PATCH 2/4] skip diag tests --- packages/core/__tests__/cli/build.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/__tests__/cli/build.test.ts b/packages/core/__tests__/cli/build.test.ts index cca0de57b..f97733c56 100644 --- a/packages/core/__tests__/cli/build.test.ts +++ b/packages/core/__tests__/cli/build.test.ts @@ -254,7 +254,7 @@ describe('CLI: single-pass build mode typechecking', () => { }); }); - describe('reports diagnostics', () => { + describe.skip('reports diagnostics', () => { describe('for the root', () => { beforeEach(async () => { let aCode = stripIndent` From 51bb91c901e6420ca15b0f474e46a70dbedf636d Mon Sep 17 00:00:00 2001 From: machty Date: Tue, 2 Jul 2024 18:23:48 -0400 Subject: [PATCH 3/4] prettier --- test-packages/test-utils/src/composite-project.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-packages/test-utils/src/composite-project.ts b/test-packages/test-utils/src/composite-project.ts index 79c4bb528..b0c69000d 100644 --- a/test-packages/test-utils/src/composite-project.ts +++ b/test-packages/test-utils/src/composite-project.ts @@ -73,7 +73,7 @@ export async function setupCompositeProject(): Promise { /** * Project Structure: - * + * * ---> a * / * - main @@ -81,7 +81,7 @@ export async function setupCompositeProject(): Promise { * ---> b ---> c * * Flattened: - * + * * - main * - reference/dependency a * - reference/dependency b From f6f7da79a7140dc15669d25fd93263566c105e58 Mon Sep 17 00:00:00 2001 From: machty Date: Tue, 2 Jul 2024 21:02:28 -0400 Subject: [PATCH 4/4] add V2_CHANGELOG --- V2_CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 V2_CHANGELOG.md diff --git a/V2_CHANGELOG.md b/V2_CHANGELOG.md new file mode 100644 index 000000000..7bda2b312 --- /dev/null +++ b/V2_CHANGELOG.md @@ -0,0 +1,13 @@ +# Changes since v2 (Volar-ized Glint) + +## `glint` CLI binary + +- BREAKING CHANGE: closer unification with vanilla `tsc` + - `glint` is now a much more thin wrapper around `tsc` and requires a number of changes to the arguments passed to it to accomplish typical tasks + - When in doubt, think in terms of what args `tsc` would need in order to accomplish a similar task, and pass those same args to `glint` + - to type-check your code + - before: `glint` + - after: `glint --noEmit` + - to build `.d.ts` declaration files for your .gts/.ts files + - before: `glint --build` + - after: `glint --declaration --emitDeclarationOnly` \ No newline at end of file