Skip to content

bug: Stencil truncates import paths when using direct imports (missing characters in filenames) #6418

@exorex

Description

@exorex

Prerequisites

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

  1. Create a component that imports from a nested file path (e.g., @utils/controllers/typeahead).
  2. Build the project.
  3. Inspect the generated files under dist/collection/components.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within StencilHelp Wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions