Make explicit extensions in imports work.
Resolves https://github.com/typed-ember/glint/issues/628
See repro repo: https://stackblitz.com/edit/stackblitz-starters-g58nhp?file=examples%2Fts-addon-node16%2Fpackage.json,examples%2Fts-addon-node16%2Fsrc%2Findex.ts
-
pnpm build - poke around in the
declarationsdirectories
Using the patch from here: https://github.com/typed-ember/glint/issues/628#issuecomment-1805416937 (where TS would allow)
And the test from here: https://github.com/typed-ember/glint/pull/648/files#diff-a835cb215198fc0a50973a4ae3bf66eac5a4b0bc21293fa29fc70888d663f797
The downside to this approach is "what if" someone has a foo.gts.ts file (probably co-located with a foo.gts.hbs file) -- but like, realistically, this isn't a thing they can use unless they're going half-in on static component references.
Notes:
- subpath-imports: https://nodejs.org/api/packages.html#subpath-imports
this feature can't be used because all subpath-imports must start with a
#to differentiate from packages. - subpath-exports: https://nodejs.org/api/packages.html#subpath-exports not relevant because from a library perspective, our own exports are not referenced except by consumers
Testing locally
The Glint Terminal
- clone this branch
-
yarn -
yarn build - delete
glint-monorepo-test-utilsfrom@glint/cores package.json's devDependencies
Repro Terminal
- download extract and cd into the repro
-
pnpm i -
pnpm link ~/path/to/this/branch/of/glint -
pnpm build
note that after every pnpm link, in order to work in the glint repo again, you'll need to re-run yarn, and un-delete the glint-monorepo-test-utils package.
Wondering, is allowArbitraryExtensions may help us here? https://www.typescriptlang.org/tsconfig#allowArbitraryExtensions
Also, looks like we may have customConditions https://www.typescriptlang.org/tsconfig#customConditions dynamically generated
Interesting part: {file basename}.d.{extension}.ts - is proposed type definition for custom extensions, so, instead of having component.gts.d.ts we may need to use component.d.gts.ts
@lifeart yeah, that sounds like a reasonable feature -- but we'd still need glint to to remove the extension during emitting.
So far, I've found it easiest, to work around the problem :( Not ideal, but I don't know what the correct fix is yet. Maybe it's what you link to!