-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): fix typedef file generated for dist-custom-elements (#…
…3468) This fixes the typedef file generated for the `index.js` file produced by `dist-custom-elements`. Previously it was mistakenly assuming that the path to a component's `d.ts` file could be generated on the basis of the `tag` set on the component. This _is_ the case if the component's filename is equal to it's tag, but there is no requirement that that be the case. This changes the way that the relative path from `${outputDir}/components/index.d.ts` to the `.d.ts` file for a specific component is generated. Previously we were doing something like: ```ts ${outputDir}/types/components/${component.tagName}/${component.tagName} ``` This doesn't work if a component is saved in `src/components/button/button.tsx` but has a tag like `custom-button`. So to fix this we can instead: - find the relative path from the source root to the component, giving us e.g. `components/button/button.tsx` - join that relative path with the relative path from where `index.d.ts` is going to be saved (`${outputDir}/components/index.d.ts`) to the directory where types are written (e.g. `${outputDir}/types`) This will give us an import in `index.d.ts` that looks like: ```ts export { Button as CustomButton } from '../types/components/button/button.tsx'; ```
- Loading branch information
1 parent
b9fbe85
commit 854d498
Showing
3 changed files
with
22 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters