Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): don't mistake aliased paths for collections imports
this commit fixes an issue where stencil builds that followed a successful build would result in the following error: ``` [ ERROR ] Component Tag Name "my-component" Must Be Unique Please update the components so "my-component" is only used once: ./src/components/my-component/my-component.tsx ./dist/collection/components/my-component/my-component.js ``` this issue manifested on windows machines when building the ionic framework after a successful build. we were able reproduce this with a minimal stencil-component-starter that included the following in its `tsconfig.json`: ```json { paths: { "@utils/*": ["src/utils/*"] } } ``` the import alias would be used as such: ```ts // src/utils/helpers.ts export const foo = () => console.log('hello'); // src/utils/other-file.ts import { foo } from '@utils/helpers'; export const bar = () => { foo(); } ``` where in the example above, `helpers.ts` is imported by `other-file.ts`, and resolved via the `@utils/*` path alias. note that neither of these files needed to be imported into a stencil component in order for the error to be replicated - they just need to sit in the `src` directory of the project. the reason the project would fail to compile is that the first build would create a `dist/collections` directory, as the `dist` output target would synthetically inject (automatically decide the project should also have) the collections output target in its output. on the second compilation, stencil would attempt to reconcile `@utils/helpers` as a collections output, and inadvertantly pull in `dist/collections/*` into the build context. this caused previously compiled versions of any components to be recommpiled. when stencil tried to check for html tag uniqueness, it would detect multiples components with the same tag, with the previously mentioned error: ``` [ ERROR ] Component Tag Name "my-component" Must Be Unique Please update the components so "my-component" is only used once: ./src/components/my-component/my-component.tsx ./dist/collection/components/my-component/my-component.js ``` Fixes: #2319 STENCIL-1252
- Loading branch information