diff --git a/files/jsconfig.json b/files/jsconfig.json new file mode 100644 index 0000000..3091061 --- /dev/null +++ b/files/jsconfig.json @@ -0,0 +1,24 @@ +/** + * This jsconfig is not used for publishing. + * It enables Glint editor tooling for the addon's local editing experience. + */ +{ + "extends": "@ember/app-tsconfig", + "include": [ + "src/**/*", + "tests/**/*", + "unpublished-development-types/**/*", + "demo-app/**/*" + ], + "compilerOptions": { + "allowJs": true, + "noEmit": true, + "rootDir": ".", + "types": [ + "ember-source/types", + "vite/client", + "@embroider/core/virtual", + "@glint/ember-tsc/types" + ] + } +} diff --git a/files/package.json b/files/package.json index 6cd454e..752527a 100644 --- a/files/package.json +++ b/files/package.json @@ -49,10 +49,10 @@ "@embroider/macros": "^1.20.1", "@embroider/vite": "^1.1.5", "@eslint/js": "^9.17.0", - "@glimmer/component": "^2.0.0<% if (typescript) { %>", + "@glimmer/component": "^2.0.0", "@glint/ember-tsc": "^1.0.3", "@glint/template": "^1.6.1", - "@glint/tsserver-plugin": "^2.0.0<% } %>", + "@glint/tsserver-plugin": "^2.0.0", "@rollup/plugin-babel": "^6.0.4<% if (typescript) { %>", "@types/qunit": "^2.19.12<% } %>", "babel-plugin-ember-template-compilation": "^4.0.0", @@ -74,9 +74,9 @@ "qunit": "^2.24.1", "qunit-dom": "^3.4.0", "rollup": "^4.22.5", - "testem": "^3.15.1<% if (typescript) { %>", - "typescript": "~5.8.3", - "typescript-eslint": "^8.19.1<% } %>", + "testem": "^3.15.1", + "typescript": "~5.8.3",<% if (typescript) { %> + "typescript-eslint": "^8.19.1",<% } %> "vite": "^7.1.9" }, "ember": { diff --git a/files/rollup.config.mjs b/files/rollup.config.mjs index 3ba54f9..bdf9cc1 100644 --- a/files/rollup.config.mjs +++ b/files/rollup.config.mjs @@ -25,7 +25,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js'<% if (typescript) {%>, 'template-registry.js'<% } %>]), + addon.publicEntrypoints(['**/*.js', 'index.js']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/files/src/template-registry.ts b/files/src/template-registry.ts deleted file mode 100644 index 7e1a8b0..0000000 --- a/files/src/template-registry.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Easily allow apps, which are not yet using strict mode templates, to consume your Glint types, by importing this file. -// Add all your components, helpers and modifiers to the template registry here, so apps don't have to do this. -// See https://typed-ember.gitbook.io/glint/environments/ember/authoring-addons - -// import type MyComponent from './components/my-component'; - -// Uncomment this once entries have been added! 👇 -// export default interface Registry { -// MyComponent: typeof MyComponent -// } diff --git a/index.js b/index.js index ed1e5b9..b2d54f9 100644 --- a/index.js +++ b/index.js @@ -75,6 +75,9 @@ module.exports = { files = files.filter( (filename) => !filename.match(/.*\.ts$/) && !ignoredFiles.includes(filename), ); + } else { + // jsconfig.json is only for the JS path; TS addons use tsconfig.json. + files = files.filter((filename) => filename !== 'jsconfig.json'); } return files; diff --git a/tests/fixtures/explicit-imports/my-addon/src/template-registry.ts b/tests/fixtures/explicit-imports/my-addon/src/template-registry.ts deleted file mode 100644 index 2cb1e88..0000000 --- a/tests/fixtures/explicit-imports/my-addon/src/template-registry.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { default as JSComponent } from './components/js-component.js'; -import { default as TSComponent } from './components/ts-component.ts'; -import { default as Nested } from './components/nested/index.js'; - -// Easily allow apps, which are not yet using strict mode templates, to consume your Glint types, by importing this file. -// Add all your components, helpers and modifiers to the template registry here, so apps don't have to do this. -// See https://typed-ember.gitbook.io/glint/environments/ember/authoring-addons - -// import type MyComponent from './components/my-component'; - -// Remove this once entries have been added! 👇 -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export default interface Registry { - Nested: typeof Nested; - JsComponent: typeof JSComponent; - TsComponent: typeof TSComponent; -} diff --git a/tests/fixtures/explicit-imports/test-app/types/registry.d.ts b/tests/fixtures/explicit-imports/test-app/types/registry.d.ts deleted file mode 100644 index e69de29..0000000 diff --git a/tests/rollup-build-tests/explicit-imports.test.ts b/tests/rollup-build-tests/explicit-imports.test.ts index 7fdf34b..180e90c 100644 --- a/tests/rollup-build-tests/explicit-imports.test.ts +++ b/tests/rollup-build-tests/explicit-imports.test.ts @@ -60,8 +60,6 @@ describe(`rollup-build | explicit-imports`, () => { 'services', 'index.js', 'index.js.map', - 'template-registry.js', - 'template-registry.js.map', ]); expect(await dirContents(declarationsDir)).to.deep.equal([ @@ -69,8 +67,6 @@ describe(`rollup-build | explicit-imports`, () => { 'index.d.ts', 'index.d.ts.map', 'services', - 'template-registry.d.ts', - 'template-registry.d.ts.map', ]); expect(await dirContents(path.join(distDir, 'services'))).to.deep.equal([ diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index aa1d5a2..01be9c2 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -105,7 +105,6 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { "src/lint-test-gts.gts", "src/lint-test-ts.ts", "src/services/example.ts", - "src/template-registry.ts", ] `); @@ -126,8 +125,6 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { "declarations/lint-test-ts.d.ts.map", "declarations/services/example.d.ts", "declarations/services/example.d.ts.map", - "declarations/template-registry.d.ts", - "declarations/template-registry.d.ts.map", "dist/_app_/components/another-gts.js", "dist/_app_/components/template-import.js", "dist/_app_/services/example.js", @@ -143,8 +140,6 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { "dist/lint-test-ts.js.map", "dist/services/example.js", "dist/services/example.js.map", - "dist/template-registry.js", - "dist/template-registry.js.map", ] `); });