Skip to content

rpt2 does not resolve pnpm symlinked dependencies #234

Closed
@davelsio

Description

@davelsio

What happens and why it is wrong

When trying to build a project installed with pnpm, rpt2 fails to resolve the created symlinked dependencies in node_modules (non-flat).

Setting check: false is (arguably) a workaround.

Related issues: #188, #214

Reproduction

Repository: https://github.com/davelsan/rpt2-pnpm-symlinks
Config: https://github.com/davelsan/rpt2-pnpm-symlinks/blob/master/rollup.config.js

The provided repro is a minimal vue3 plugin that imports the App interface from vue in index.ts

import  { App } from 'vue'

This import causes the following error on build:

 [!] (plugin rpt2) Error: semantic error TS2305: Module '"../node_modules/vue/dist/vue"' has no exported member 'App'.

Setting the check option to false in rollup.config.js eliminates the error.

Versions

  • typescript: 4.2.3
  • rollup: 2.41.5
  • rollup-plugin-typescript2: 0.30.0

rollup.config.js

import path    from 'path';
import rpt2    from 'rollup-plugin-typescript2';
import pkgJson from './package.json';

export default {

  input: './src/index.ts',

  external: ['vue'],

  plugins: [
    rpt2({
      check: true,
      tsconfig: path.resolve(__dirname, 'tsconfig.json'),
    })
  ],

  output: [
    {
      file: pkgJson.browser, // dist/index.esm.js
      format: 'es',
      sourcemap: true,
    },
  ],
}

tsconfig.json

A snippet with the relevant module resolution options only.

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
  }
}

package.json

A snippet with the relevant dependencies only.

{
  "peerDependencies": {
    "vue": "^3.0.7"
  },
  "devDependencies": {
    "rollup": "^2.41.5",
    "rollup-plugin-typescript2": "^0.30.0",
    "typescript": "^4.2.3",
    "vue": "^3.0.7"
  }
}

Metadata

Metadata

Assignees

Labels

kind: bugSomething isn't working properlytopic: TS Compiler API DocsRelated to the severely lacking TS Compiler API Docstopic: 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