Skip to content

bug: Stencil v5 overrides TypeScript’s rootDir, causing TS6059 for shared monorepo source #7064

Backlog

Description

@exorex

Prerequisites

Stencil Version

Stencil 5.0.0-rc.15

Current Behavior

Our Stencil package lives at packages/web-components/ and imports TypeScript source from the repository’s shared/ directory. stencil.config.ts selects tsconfig.build.json, which sets compilerOptions.rootDir to "../.." so both directories are within the TypeScript root.

During stencil build, getTsOptionsToExtend() sets TypeScript’s rootDir to Stencil’s config.rootDir, which points to the package directory. TypeScript then reports TS6059 because the imported shared files fall outside that directory.

Expected Behavior

Stencil should honor an explicit compilerOptions.rootDir from the selected tsconfig and fall back to config.rootDir when the option is unset. TypeScript rootDir reference

Steps to Reproduce

  1. Create a Stencil project at packages/web-components/ in a monorepo using @stencil/[email protected].
  2. Set tsconfig: 'tsconfig.build.json' in stencil.config.ts and set compilerOptions.rootDir to "../.." in that tsconfig.
  3. Import a function from a .ts file in the repository-level shared/ directory and call it from a Stencil component.
  4. Run stencil build from packages/web-components/. The TS6059 diagnostic identifies the shared file and uses the Stencil package directory as rootDir.

Environment

Stencil 5.0.0-rc.15 in a pnpm workspace on Windows.

Activity

  1. changed the title [-]bug: Stencil 5.0.0 overrides TypeScript’s `rootDir`, causing TS6059 for shared monorepo source[/-] [+]bug: Stencil v5 overrides TypeScript’s `rootDir`, causing TS6059 for shared monorepo source[/+] on Nov 28, 2026
  2. harshbhx commented on Nov 28, 2026

    @harshbhx
    Contributor

    I can take this. getTsOptionsToExtend in packages/core/src/compiler/transpile/ts-config.ts hardcodes rootDir: config.rootDir, which overrides compilerOptions.rootDir from the selected tsconfig. I'll use the tsconfig value when it is set and fall back to config.rootDir, with unit tests. Is v5 the right base branch for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions