-
Notifications
You must be signed in to change notification settings - Fork 816
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
4.38.1
Current Behavior
When building a Stencil project, some direct imports are incorrectly transformed in the compiled output (dist/collection/components).
For example, this source import:
import { TYPEAHEAD_RECORD, TypeaheadController } from '@utils/controllers/typeahead';
is transformed in the build output to:
import { TYPEAHEAD_RECORD, TypeaheadController } from "../../utils/controllers/typeahe";
As shown above, the compiler truncates the filename — the final "ad"
letters from "typeahead"
are missing.
This issue causes the generated files to reference invalid paths and prevents components from working correctly when built and used in another project.
Notably, this problem does not occur when using barrel file imports instead, for example:
import { TYPEAHEAD_RECORD, TypeaheadController, KeyboardController } from '@utils/controllers';
Expected Behavior
The compiler should correctly preserve the full import paths during the build process, without truncating filenames or modifying valid import strings.
System Info
System: node 22.13.1
Platform: windows (10.0.26100)
CPU Model: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz (12 cpus)
Compiler: C:\Users\exorex\OneDrive\Desktop\my-component\node_modules\@stencil\core\compiler\stencil.js
Build: 1760088209
Stencil: 4.38.1
TypeScript: 5.9.3
Rollup: 4.34.9
Parse5: 7.2.1
jQuery: 4.0.0-pre
Terser: 5.37.0
Steps to Reproduce
- Create a component that imports from a nested file path (e.g., @utils/controllers/typeahead).
- Build the project.
- Inspect the generated files under
dist/collection/components
. - Observe that the compiled import path is truncated (missing final characters from the original filename).
The issue only occurs when importing directly (not through barrel files) and becomes noticeable when the built library is used as a dependency in another project.
Code Reproduction URL
https://github.com/exorex/stencil-truncates-import-paths-issue
Additional Information
No response