Skip to content

Extra types path in monorepo -- rootDir #464

@mokone91

Description

@mokone91

Troubleshooting

  1. Does tsc have the same output? If so, please explain why this is incorrect behavior
    N/A

  2. Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate
    yes

  3. Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction
    N/A

What happens and why it is incorrect

Hi!
After upgrading from 0.31.1 to 0.35.0 build for types containing extra 'src' dir, code transpiled fine(same as before package update).
I use pnpm workspaces in my project.
After investigation I found that id I remove import from another package(import screens from @mycompany/styles) - types generated correctly.
I do not have any 'path' or 'rootDir' configured in any repos tsconfigs, and I do not use aliases.

my repo is huge, not sure if I can to extract working example..

UPD:
Have test different package versions, seems extra types folder starts to appear in 0.33.0

Environment

pnpm monorepo

Versions

 System:
    OS: macOS 13.5.2
    CPU: (12) arm64 Apple M2 Pro
    Memory: 550.98 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.19.1 - ~/Library/Caches/fnm_multishells/57093_1695717420463/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/57093_1695717420463/bin/yarn
    npm: 8.19.3 - ~/Library/Caches/fnm_multishells/57093_1695717420463/bin/npm
  npmPackages:
    typescript: 5.1.6 => 5.1.6
    rollup: 2.79.1
    rollup-plugin-typescript2: 0.35.0

rollup.config.js

:
return {
   input: getInput(config), // simple glob to 'src/'
   output,
   plugins: [
     ...getDepsPlugins(config), // depends on build target we add nodeExternals or not
     json(),
     replace({
       'process.env.NODE_ENV': JSON.stringify('production'),
       preventAssignment: true,
     }),
     // Only use typescript for declarations - babel will
     // do actual js transformations
     typescript({
       useTsconfigDeclarationDir: false,
       emitDeclarationOnly: true,
     }),
     vue(vueConfig),
     postcss(getPostCSSConfig(config)),
     babel({
       exclude: 'node_modules/**',
       extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
       babelHelpers: 'bundled',
       presets: [
         [
           '@babel/preset-env',
           {
             targets: 'last 2 versions and > 2%',
           },
         ],
       ],
     }),
     ...(isWatch ? [] : [
       cleaner({
         targets: [output.dir],
       }),
     ]),
   ],
 };

tsconfig.options.json

:
{
  "compilerOptions": {
    "target": "es2019",
    "strict": true,
    "lib": [
      "DOM",
      "DOM.Iterable",
      "ES6"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "downlevelIteration": true,
    "baseUrl": ".",
    "outDir": "./dist",
    "sourceMap": true,
    "declaration": true,
    "preserveSymlinks": true
  }
}

tsconfig.json

:
{
  "extends": "./tsconfig.options.json",
  "exclude": [
    "public",
    "node_modules",
  ]
}

/packages/components/tsconfig.json

:
{
  "extends": "../../tsconfig.options.json",
  "include": [
    "./src/**/*.vue",
    "./src/**/*.ts"
  ],
  "exclude": ["./dist"],
  "compilerOptions": {
    "baseUrl": ".",
    "jsx": "react",
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: supportAsking for support with something or a specific use caseproblem: no reproNo reproduction was provided (and have not tried to repro without one)solution: duplicateThis issue or pull request already existssolution: tsc behaviorThis is tsc's behavior as well, so this is not a bug with this plugintopic: monorepo / symlinksRelated to monorepos and/or symlinks (Lerna, Yarn, PNPM, Rush, etc)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions