From 3de2ce4e31982875557e5818fd3ffa27918e2833 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 6 Jun 2025 12:00:12 -0400 Subject: [PATCH 01/29] Add new fixture file --- .../typescript/test-app/tests/unit/ember-types-test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/fixtures/typescript/test-app/tests/unit/ember-types-test.ts diff --git a/tests/fixtures/typescript/test-app/tests/unit/ember-types-test.ts b/tests/fixtures/typescript/test-app/tests/unit/ember-types-test.ts new file mode 100644 index 0000000..127165f --- /dev/null +++ b/tests/fixtures/typescript/test-app/tests/unit/ember-types-test.ts @@ -0,0 +1,8 @@ +import { tracked, cached } from '@glimmer/tracking'; +import Component from '@glimmer/component'; +import Route from '@ember/routing/route'; +import { uniqueId } from '@ember/utils'; + +export const everythingHasTypes = { + tracked, cached, Component, Route, uniqueId +} From 13686db52b900019a9ad1a643fb7264b9ee646a3 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 6 Jun 2025 12:06:48 -0400 Subject: [PATCH 02/29] unskip typescript tests --- tests/smoke-tests/--typescript.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index 8639c60..a808189 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -11,7 +11,7 @@ import { } from '../helpers.js'; for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { - describe.skip(`--typescript with ${packageManager}`, () => { + describe(`--typescript with ${packageManager}`, () => { let distDir = ''; let declarationsDir = ''; let helper = new AddonHelper({ From e3ea6ea7aa85255d077660dd51af92cd84abeb69 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 6 Jun 2025 12:08:39 -0400 Subject: [PATCH 03/29] Fix helper usage --- tests/smoke-tests/--typescript.test.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index a808189..42986d0 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -24,8 +24,8 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { await helper.setup(); await helper.installDeps(); - distDir = path.join(helper.addonFolder, 'dist'); - declarationsDir = path.join(helper.addonFolder, 'declarations'); + distDir = path.join(helper.projectRoot, 'dist'); + declarationsDir = path.join(helper.projectRoot, 'declarations'); }); afterAll(async () => { @@ -63,14 +63,6 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { // the files in a way that would break consumers await helper.run('lint:fix'); - /** - * In order to use build with components, we need to add more dependencies - * We may want to consider making these default - */ - await execa('pnpm', ['add', '--save-peer', '@glimmer/component'], { - cwd: helper.addonFolder, - }); - let buildResult = await helper.build(); expect(buildResult.exitCode).toEqual(0); From 2755fc035802af9bb9b5e00ecf6fd24884bdb84d Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 6 Jun 2025 12:14:29 -0400 Subject: [PATCH 04/29] Delete the files from the typescript fixture that are no longer supported --- .../my-addon/src/components/co-located-ts.hbs | 3 --- .../my-addon/src/components/co-located-ts.ts | 9 --------- .../my-addon/src/components/co-located.hbs | 1 - .../my-addon/src/components/co-located.js | 5 ----- .../my-addon/src/components/template-only.hbs | 1 - .../my-addon/src/components/template-only.ts | 3 --- .../src/components/another-gts.gts | 0 .../src/components/template-import.gts | 3 +-- .../{my-addon => }/src/services/example.ts | 0 .../tests/rendering/co-located-test.ts | 20 ------------------- .../tests/rendering/template-only-test.ts | 14 ------------- .../rendering/template-import-test.gts} | 4 +++- .../tests/unit/ember-types-test.ts | 0 13 files changed, 4 insertions(+), 59 deletions(-) delete mode 100644 tests/fixtures/typescript/my-addon/src/components/co-located-ts.hbs delete mode 100644 tests/fixtures/typescript/my-addon/src/components/co-located-ts.ts delete mode 100644 tests/fixtures/typescript/my-addon/src/components/co-located.hbs delete mode 100644 tests/fixtures/typescript/my-addon/src/components/co-located.js delete mode 100644 tests/fixtures/typescript/my-addon/src/components/template-only.hbs delete mode 100644 tests/fixtures/typescript/my-addon/src/components/template-only.ts rename tests/fixtures/typescript/{my-addon => }/src/components/another-gts.gts (100%) rename tests/fixtures/typescript/{my-addon => }/src/components/template-import.gts (85%) rename tests/fixtures/typescript/{my-addon => }/src/services/example.ts (100%) delete mode 100644 tests/fixtures/typescript/test-app/tests/rendering/co-located-test.ts delete mode 100644 tests/fixtures/typescript/test-app/tests/rendering/template-only-test.ts rename tests/fixtures/typescript/{test-app/tests/rendering/template-import-test.ts => tests/rendering/template-import-test.gts} (75%) rename tests/fixtures/typescript/{test-app => }/tests/unit/ember-types-test.ts (100%) diff --git a/tests/fixtures/typescript/my-addon/src/components/co-located-ts.hbs b/tests/fixtures/typescript/my-addon/src/components/co-located-ts.hbs deleted file mode 100644 index af543d6..0000000 --- a/tests/fixtures/typescript/my-addon/src/components/co-located-ts.hbs +++ /dev/null @@ -1,3 +0,0 @@ -Hello, -{{this.whereAmI}} -(in TypeScript) diff --git a/tests/fixtures/typescript/my-addon/src/components/co-located-ts.ts b/tests/fixtures/typescript/my-addon/src/components/co-located-ts.ts deleted file mode 100644 index c250674..0000000 --- a/tests/fixtures/typescript/my-addon/src/components/co-located-ts.ts +++ /dev/null @@ -1,9 +0,0 @@ -import Component from '@glimmer/component'; -import { service } from '@ember/service'; -import type Example from '../services/example.ts'; - -export default class CoLocatedTs extends Component { - @service declare example: Example; - - whereAmI = 'from a co-located TS component'; -} diff --git a/tests/fixtures/typescript/my-addon/src/components/co-located.hbs b/tests/fixtures/typescript/my-addon/src/components/co-located.hbs deleted file mode 100644 index 22fe19c..0000000 --- a/tests/fixtures/typescript/my-addon/src/components/co-located.hbs +++ /dev/null @@ -1 +0,0 @@ -Hello, {{this.whereAmI}} diff --git a/tests/fixtures/typescript/my-addon/src/components/co-located.js b/tests/fixtures/typescript/my-addon/src/components/co-located.js deleted file mode 100644 index 77f1391..0000000 --- a/tests/fixtures/typescript/my-addon/src/components/co-located.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component from '@glimmer/component'; - -export default class CoLocated extends Component { - whereAmI = 'from a co-located component'; -} diff --git a/tests/fixtures/typescript/my-addon/src/components/template-only.hbs b/tests/fixtures/typescript/my-addon/src/components/template-only.hbs deleted file mode 100644 index fc5daef..0000000 --- a/tests/fixtures/typescript/my-addon/src/components/template-only.hbs +++ /dev/null @@ -1 +0,0 @@ -Hello from a template-only component diff --git a/tests/fixtures/typescript/my-addon/src/components/template-only.ts b/tests/fixtures/typescript/my-addon/src/components/template-only.ts deleted file mode 100644 index fa85053..0000000 --- a/tests/fixtures/typescript/my-addon/src/components/template-only.ts +++ /dev/null @@ -1,3 +0,0 @@ -import templateOnly from '@ember/component/template-only'; - -export default templateOnly(); diff --git a/tests/fixtures/typescript/my-addon/src/components/another-gts.gts b/tests/fixtures/typescript/src/components/another-gts.gts similarity index 100% rename from tests/fixtures/typescript/my-addon/src/components/another-gts.gts rename to tests/fixtures/typescript/src/components/another-gts.gts diff --git a/tests/fixtures/typescript/my-addon/src/components/template-import.gts b/tests/fixtures/typescript/src/components/template-import.gts similarity index 85% rename from tests/fixtures/typescript/my-addon/src/components/template-import.gts rename to tests/fixtures/typescript/src/components/template-import.gts index 443f08e..f38f863 100644 --- a/tests/fixtures/typescript/my-addon/src/components/template-import.gts +++ b/tests/fixtures/typescript/src/components/template-import.gts @@ -1,5 +1,4 @@ import Component from '@glimmer/component'; -import TemplateOnly from './template-only.ts'; import AnotherGts from './another-gts.gts'; // N.B. relative imports inside a v2 addon should have explicit file extensions (this is consistent with how node treats ES modules) import { on } from '@ember/modifier'; import { action } from '@ember/object'; @@ -15,7 +14,7 @@ interface Signature { export default class TemplateImport extends Component { diff --git a/tests/fixtures/typescript/tests/rendering/template-import-test.gts b/tests/fixtures/typescript/tests/rendering/template-import-test.gts index c0fb54b..5693569 100644 --- a/tests/fixtures/typescript/tests/rendering/template-import-test.gts +++ b/tests/fixtures/typescript/tests/rendering/template-import-test.gts @@ -10,6 +10,6 @@ module('Rendering | template-import', function(hooks) { test('it renders', async function(assert) { await render(); - assert.dom().hasText('Hello from a GTS file but also Hello from a template-only component and Hello from another GTS file!'); + assert.dom().hasText('Hello from a GTS file but also Hello from another GTS file!'); }) }); diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index e5756ca..e4b4004 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -46,7 +46,11 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { await execa({ cwd: tmpDir, })`${localEmberCli} addon ${addonName} -b ${blueprintPath} --skip-npm --prefer-local true --${packageManager} --typescript`; - await execa({ cwd: addonDir })`${packageManager} install`; + // Have to use --force because NPM is *stricter* when you use tags in package.json + // than pnpm (in that tags don't match any specified stable version) + await execa({ + cwd: addonDir, + })`${packageManager} install ${packageManager === 'npm' ? '--force' : ''}`; }); it('was generated correctly', async () => { @@ -65,11 +69,8 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { describe('with fixture', () => { beforeEach(async () => { - let addonFixture = fixturify.readSync('./fixtures/addon'); - fixturify.writeSync(join(addonDir, 'src'), addonFixture); - - let testFixture = fixturify.readSync('./fixtures/rendering-tests'); - fixturify.writeSync(join(addonDir, 'tests/rendering'), testFixture); + let addonFixture = fixturify.readSync('./fixtures/typescript'); + fixturify.writeSync(addonDir, addonFixture); // It's important that we ensure that dist directory is empty for these tests, // troll-y things can happen with shared dists From fdff098b3aec9875db3d8f1bd4f6d325bc35c811 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 7 Jun 2025 14:42:10 -0400 Subject: [PATCH 21/29] Do all file diffs at once for clarity --- tests/smoke-tests/--typescript.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index e4b4004..8f0ab70 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -88,16 +88,17 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { let dist = await dirContents(join(addonDir, 'dist')); let declarations = await dirContents(join(addonDir, 'declarations')); - expect({ src }, 'ensure we dont litter the src dir with declarations').to.deep.equal({ - src: ['components', 'index.ts', 'template-registry.ts'], - }); - - expect({ dist, declarations }).to.deep.equal({ + expect( + { src, dist, declarations }, + `ensure we don't pollute the src dir with declarations and emit the js and .d.ts to the correct folders`, + ).to.deep.equal({ + src: ['components', 'index.ts', 'services', 'template-registry.ts'], dist: [ '_app_', 'components', 'index.js', 'index.js.map', + 'services', 'template-registry.js', 'template-registry.js.map', ], @@ -105,6 +106,7 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { 'components', 'index.d.ts', 'index.d.ts.map', + 'services', 'template-registry.d.ts', 'template-registry.d.ts.map', ], From 2d1cbe17b44badceb73dbaa52f839b5c0f5be0de Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 7 Jun 2025 14:52:34 -0400 Subject: [PATCH 22/29] Check all generated files --- tests/smoke-tests/--typescript.test.ts | 30 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index 8f0ab70..3d5f79d 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -84,12 +84,18 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { it('build', async () => { await commandSucceeds(`${packageManager} run build`); - let src = await dirContents(join(addonDir, 'src')); - let dist = await dirContents(join(addonDir, 'dist')); - let declarations = await dirContents(join(addonDir, 'declarations')); - expect( - { src, dist, declarations }, + { + src: await dirContents(join(addonDir, 'src')), + // rollup output: + dist: await dirContents(join(addonDir, 'dist')), + 'dist/components': await dirContents(join(addonDir, 'dist/components')), + 'dist/services': await dirContents(join(addonDir, 'dist/services')), + // glint output: + declarations: await dirContents(join(addonDir, 'declarations')), + 'declarations/components': await dirContents(join(addonDir, 'declarations/components')), + 'declarations/services': await dirContents(join(addonDir, 'declarations/services')), + }, `ensure we don't pollute the src dir with declarations and emit the js and .d.ts to the correct folders`, ).to.deep.equal({ src: ['components', 'index.ts', 'services', 'template-registry.ts'], @@ -102,6 +108,13 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { 'template-registry.js', 'template-registry.js.map', ], + 'dist/components': [ + 'another-gts.js', + 'another-gts.js.map', + 'template-import.js', + 'template-import.js.map', + ], + 'dist/services': ['example.js', 'example.js.map'], declarations: [ 'components', 'index.d.ts', @@ -110,6 +123,13 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { 'template-registry.d.ts', 'template-registry.d.ts.map', ], + 'declarations/components': [ + 'another-gts.gts.d.ts', + 'another-gts.gts.d.ts.map', + 'template-import.gts.d.ts', + 'template-import.gts.d.ts.map', + ], + 'declarations/services': ['example.d.ts', 'example.d.ts.map'], }); }); From 8d9416c8d32379de06f87b1172c37088ac633a16 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:53:34 -0400 Subject: [PATCH 23/29] Change from unstable to alpha --- files/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/files/package.json b/files/package.json index 177fbea..f4649f5 100644 --- a/files/package.json +++ b/files/package.json @@ -45,11 +45,11 @@ "@embroider/vite": "^1.1.5", "@eslint/js": "^9.17.0", "@glimmer/component": "^2.0.0",<% if (typescript) { %> - "@glint/core": "unstable", - "@glint/environment-ember-loose": "unstable", - "@glint/environment-ember-template-imports": "unstable", - "@glint/tsserver-plugin": "unstable", - "@glint/template": "unstable", + "@glint/core": "^2.0.0-alpha.1", + "@glint/environment-ember-loose": "^2.0.0-alpha.1", + "@glint/environment-ember-template-imports": "^2.0.0-alpha.1", + "@glint/tsserver-plugin": "^2.0.0-alpha.1", + "@glint/template": "^1.6.0-alpha.1", "@ember/app-tsconfig": "^1.0.0", "@ember/library-tsconfig": "^1.0.0",<% } %> "@rollup/plugin-babel": "^6.0.4",<% if (typescript) { %> From dd3a0bd680f85db13129ab410b6f58d526aaa650 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:55:35 -0400 Subject: [PATCH 24/29] Alpha 0 --- files/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/package.json b/files/package.json index f4649f5..b81c494 100644 --- a/files/package.json +++ b/files/package.json @@ -49,7 +49,7 @@ "@glint/environment-ember-loose": "^2.0.0-alpha.1", "@glint/environment-ember-template-imports": "^2.0.0-alpha.1", "@glint/tsserver-plugin": "^2.0.0-alpha.1", - "@glint/template": "^1.6.0-alpha.1", + "@glint/template": "^1.6.0-alpha.0", "@ember/app-tsconfig": "^1.0.0", "@ember/library-tsconfig": "^1.0.0",<% } %> "@rollup/plugin-babel": "^6.0.4",<% if (typescript) { %> From 7378a8ade3d46b6a0251034bb507683255763338 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 16 Jun 2025 23:45:07 -0400 Subject: [PATCH 25/29] Bump glint versions --- files/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/files/package.json b/files/package.json index b81c494..4deb4e8 100644 --- a/files/package.json +++ b/files/package.json @@ -45,11 +45,11 @@ "@embroider/vite": "^1.1.5", "@eslint/js": "^9.17.0", "@glimmer/component": "^2.0.0",<% if (typescript) { %> - "@glint/core": "^2.0.0-alpha.1", - "@glint/environment-ember-loose": "^2.0.0-alpha.1", - "@glint/environment-ember-template-imports": "^2.0.0-alpha.1", - "@glint/tsserver-plugin": "^2.0.0-alpha.1", - "@glint/template": "^1.6.0-alpha.0", + "@glint/core": "^2.0.0-alpha.2", + "@glint/environment-ember-loose": "^2.0.0-alpha.2", + "@glint/environment-ember-template-imports": "^2.0.0-alpha.2", + "@glint/tsserver-plugin": "^2.0.0-alpha.2", + "@glint/template": "^1.6.0-alpha.1", "@ember/app-tsconfig": "^1.0.0", "@ember/library-tsconfig": "^1.0.0",<% } %> "@rollup/plugin-babel": "^6.0.4",<% if (typescript) { %> From 43aa024198becf036a6168eda7633b8689fc58e1 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:23:14 -0400 Subject: [PATCH 26/29] Add comments explaining publish vs not for babel/tsconfig --- files/babel.config.cjs | 5 +++++ files/babel.publish.config.cjs | 5 +++++ files/tsconfig.publish.json | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/files/babel.config.cjs b/files/babel.config.cjs index c43a709..ce930e9 100644 --- a/files/babel.config.cjs +++ b/files/babel.config.cjs @@ -1,3 +1,8 @@ +/** + * This babel.config is not used for publishing. + * It's only for the local editing experience + * (and linting) + */ const { buildMacros } = require('@embroider/macros/babel'); const { diff --git a/files/babel.publish.config.cjs b/files/babel.publish.config.cjs index f8bcf11..d5f2900 100644 --- a/files/babel.publish.config.cjs +++ b/files/babel.publish.config.cjs @@ -1,3 +1,8 @@ +/** + * This babel.config is only used for publishing. + * + * For local dev experience, see the babel.config + */ module.exports = { plugins: [<% if (typescript) { %> [ diff --git a/files/tsconfig.publish.json b/files/tsconfig.publish.json index d17e951..e100b77 100644 --- a/files/tsconfig.publish.json +++ b/files/tsconfig.publish.json @@ -1,3 +1,8 @@ +/** + * This tsconfig is only used for publishing. + * + * For local dev experience, see the tsconfig.json + */ { "extends": "@ember/library-tsconfig", "include": ["./src/**/*", "./unpublished-development-types/**/*"], From 30291c60be99a516ab9d48e6abd8054e17bd4edb Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:28:54 -0400 Subject: [PATCH 27/29] De-object the config files --- files/rollup.config.mjs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/files/rollup.config.mjs b/files/rollup.config.mjs index 344e724..f074e03 100644 --- a/files/rollup.config.mjs +++ b/files/rollup.config.mjs @@ -9,10 +9,8 @@ const addon = new Addon({ }); const rootDirectory = dirname(fileURLToPath(import.meta.url)); -const configs = { - babel: resolve(rootDirectory, './babel.publish.config.cjs'),<% if (typescript) { %> - ts: resolve(rootDirectory, './tsconfig.publish.json'),<% } %> -}; +const babelConfig = resolve(rootDirectory, './babel.publish.config.cjs');<% if (typescript) { %> +const tsConfig = resolve(rootDirectory, './tsconfig.publish.json');<% } %> export default { // This provides defaults that work well alongside `publicEntrypoints` below. @@ -53,7 +51,7 @@ export default { babel({ extensions: ['.js', '.gjs'<% if (typescript) { %>, '.ts', '.gts'<% } %>], babelHelpers: 'bundled', - configFile: configs.babel, + configFile: babelConfig, }), // Ensure that standalone .hbs files are properly integrated as Javascript. @@ -65,8 +63,8 @@ export default { // Emit .d.ts declaration files addon.declarations( 'declarations',<% if (packageManager === 'pnpm') { %> - `pnpm glint --declaration --project ${configs.ts}`,<% } else { %> - `npm exec glint -- --declaration --project ${configs.ts}`,<% } %> + `pnpm glint --declaration --project ${tsConfig}`,<% } else { %> + `npm exec glint -- --declaration --project ${tsConfig}`,<% } %> ),<% } %> // addons are allowed to contain imports of .css files, which we want rollup From 30540e67d2344476ca65219d70d5780297a9851d Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:30:34 -0400 Subject: [PATCH 28/29] Use npx for invoking glint, rather than pnpm/npm directly (simplifies part of the blueprint) --- files/rollup.config.mjs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/files/rollup.config.mjs b/files/rollup.config.mjs index f074e03..29576ce 100644 --- a/files/rollup.config.mjs +++ b/files/rollup.config.mjs @@ -62,9 +62,8 @@ export default { // Emit .d.ts declaration files addon.declarations( - 'declarations',<% if (packageManager === 'pnpm') { %> - `pnpm glint --declaration --project ${tsConfig}`,<% } else { %> - `npm exec glint -- --declaration --project ${tsConfig}`,<% } %> + 'declarations', + `npx glint --declaration --project ${tsConfig}`, ),<% } %> // addons are allowed to contain imports of .css files, which we want rollup From 4cf6fd15133be50faaed53a1efc1dc4b166ce12c Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:25:42 -0400 Subject: [PATCH 29/29] Switch to inline snapshot for the files list --- pnpm-lock.yaml | 40 +++++++++++ tests/helpers/utils.ts | 13 ++++ tests/package.json | 1 + tests/smoke-tests/--typescript.test.ts | 95 +++++++++++++------------- 4 files changed, 102 insertions(+), 47 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a994e79..620ac20 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ importers: fs-extra: specifier: ^10.0.0 version: 10.1.0 + globby: + specifier: ^14.1.0 + version: 14.1.0 tmp-promise: specifier: ^3.0.3 version: 3.0.3 @@ -607,6 +610,10 @@ packages: '@sec-ant/readable-stream@0.4.1': resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} + '@sindresorhus/merge-streams@2.3.0': + resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} + engines: {node: '>=18'} + '@sindresorhus/merge-streams@4.0.0': resolution: {integrity: sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==} engines: {node: '>=18'} @@ -2140,6 +2147,10 @@ packages: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} + globby@14.1.0: + resolution: {integrity: sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA==} + engines: {node: '>=18'} + gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} @@ -2289,6 +2300,10 @@ packages: ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + ignore@7.0.5: + resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} + engines: {node: '>= 4'} + imurmurhash@0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} @@ -3113,6 +3128,10 @@ packages: path-to-regexp@0.1.12: resolution: {integrity: sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==} + path-type@6.0.0: + resolution: {integrity: sha512-Vj7sf++t5pBD637NSfkxpHSMfWaeig5+DKWLhcqIYx6mWQz5hdJTGDVMQiJcw1ZYkhs7AazKDGpRVji1LJCZUQ==} + engines: {node: '>=18'} + pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} @@ -3501,6 +3520,10 @@ packages: resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==} engines: {node: '>= 10'} + slash@5.1.0: + resolution: {integrity: sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==} + engines: {node: '>=14.16'} + smart-buffer@4.2.0: resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} @@ -4675,6 +4698,8 @@ snapshots: '@sec-ant/readable-stream@0.4.1': {} + '@sindresorhus/merge-streams@2.3.0': {} + '@sindresorhus/merge-streams@4.0.0': {} '@socket.io/component-emitter@3.1.2': {} @@ -6533,6 +6558,15 @@ snapshots: globals@11.12.0: {} + globby@14.1.0: + dependencies: + '@sindresorhus/merge-streams': 2.3.0 + fast-glob: 3.3.3 + ignore: 7.0.5 + path-type: 6.0.0 + slash: 5.1.0 + unicorn-magic: 0.3.0 + gopd@1.2.0: {} graceful-fs@4.2.10: {} @@ -6704,6 +6738,8 @@ snapshots: ieee754@1.2.1: {} + ignore@7.0.5: {} + imurmurhash@0.1.4: {} indent-string@4.0.0: {} @@ -7505,6 +7541,8 @@ snapshots: path-to-regexp@0.1.12: {} + path-type@6.0.0: {} + pathe@2.0.3: {} pathval@2.0.0: {} @@ -7934,6 +7972,8 @@ snapshots: mrmime: 2.0.1 totalist: 3.0.1 + slash@5.1.0: {} + smart-buffer@4.2.0: {} snapdragon-node@2.1.1: diff --git a/tests/helpers/utils.ts b/tests/helpers/utils.ts index 5b33eb0..6322f79 100644 --- a/tests/helpers/utils.ts +++ b/tests/helpers/utils.ts @@ -4,6 +4,7 @@ import assert from 'node:assert'; import path from 'node:path'; import { $ } from 'execa'; import { fileURLToPath } from 'node:url'; +import { globby } from 'globby'; import { execa, type Options } from 'execa'; @@ -106,6 +107,18 @@ export async function runScript({ } } +export async function filesMatching(glob: string, dirPath: string) { + try { + let files = await globby(glob, { cwd: dirPath }); + + return files; + } catch (e) { + console.error('error', e); + + return []; + } +} + export async function dirContents(dirPath: string) { try { let files = await fs.readdir(dirPath); diff --git a/tests/package.json b/tests/package.json index e7bd42f..e42c56c 100644 --- a/tests/package.json +++ b/tests/package.json @@ -13,6 +13,7 @@ "execa": "^9.5.2", "fixturify": "^3.0.0", "fs-extra": "^10.0.0", + "globby": "^14.1.0", "tmp-promise": "^3.0.3", "typescript": "^4.7.4", "vite": "^3.0.0", diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index 3d5f79d..b0ec7ec 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -5,7 +5,12 @@ import fixturify from 'fixturify'; import { execa } from 'execa'; import { beforeAll, beforeEach, describe, expect, it } from 'vitest'; -import { assertGeneratedCorrectly, dirContents, SUPPORTED_PACKAGE_MANAGERS } from '../helpers.js'; +import { + assertGeneratedCorrectly, + dirContents, + filesMatching, + SUPPORTED_PACKAGE_MANAGERS, +} from '../helpers.js'; const blueprintPath = path.join(__dirname, '../..'); let localEmberCli = require.resolve('ember-cli/bin/ember'); @@ -85,52 +90,48 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { await commandSucceeds(`${packageManager} run build`); expect( - { - src: await dirContents(join(addonDir, 'src')), - // rollup output: - dist: await dirContents(join(addonDir, 'dist')), - 'dist/components': await dirContents(join(addonDir, 'dist/components')), - 'dist/services': await dirContents(join(addonDir, 'dist/services')), - // glint output: - declarations: await dirContents(join(addonDir, 'declarations')), - 'declarations/components': await dirContents(join(addonDir, 'declarations/components')), - 'declarations/services': await dirContents(join(addonDir, 'declarations/services')), - }, - `ensure we don't pollute the src dir with declarations and emit the js and .d.ts to the correct folders`, - ).to.deep.equal({ - src: ['components', 'index.ts', 'services', 'template-registry.ts'], - dist: [ - '_app_', - 'components', - 'index.js', - 'index.js.map', - 'services', - 'template-registry.js', - 'template-registry.js.map', - ], - 'dist/components': [ - 'another-gts.js', - 'another-gts.js.map', - 'template-import.js', - 'template-import.js.map', - ], - 'dist/services': ['example.js', 'example.js.map'], - declarations: [ - 'components', - 'index.d.ts', - 'index.d.ts.map', - 'services', - 'template-registry.d.ts', - 'template-registry.d.ts.map', - ], - 'declarations/components': [ - 'another-gts.gts.d.ts', - 'another-gts.gts.d.ts.map', - 'template-import.gts.d.ts', - 'template-import.gts.d.ts.map', - ], - 'declarations/services': ['example.d.ts', 'example.d.ts.map'], - }); + await filesMatching('src/**', addonDir), + `ensure we don't pollute the src dir with declarations and emit the js and .d.ts to the correct folders -- this should be the same as the input files (no change from the fixture + default files)`, + ).toMatchInlineSnapshot(` + [ + "src/index.ts", + "src/template-registry.ts", + "src/components/another-gts.gts", + "src/components/template-import.gts", + "src/services/example.ts", + ] + `); + + expect( + await filesMatching('{dist,declarations}/**/*', addonDir), + `ensure we emit the correct files out of the box to the correct folders`, + ).toMatchInlineSnapshot(` + [ + "dist/index.js", + "dist/index.js.map", + "dist/template-registry.js", + "dist/template-registry.js.map", + "dist/components/another-gts.js", + "dist/components/another-gts.js.map", + "dist/components/template-import.js", + "dist/components/template-import.js.map", + "dist/services/example.js", + "dist/services/example.js.map", + "dist/_app_/components/another-gts.js", + "dist/_app_/components/template-import.js", + "dist/_app_/services/example.js", + "declarations/index.d.ts", + "declarations/index.d.ts.map", + "declarations/template-registry.d.ts", + "declarations/template-registry.d.ts.map", + "declarations/components/another-gts.gts.d.ts", + "declarations/components/another-gts.gts.d.ts.map", + "declarations/components/template-import.gts.d.ts", + "declarations/components/template-import.gts.d.ts.map", + "declarations/services/example.d.ts", + "declarations/services/example.d.ts.map", + ] + `); }); it('test', async () => {