Skip to content

[@rollup/plugin-typescript] Doesn't parse packages outside root dir, monorepo packages #1520

@taylorfsteele

Description

@taylorfsteele

Rollup Version

3.25.1

Operating System (or Browser)

Browser

Node Version (if applicable)

16.14.2

Link To Reproduction

https://stackblitz.com/edit/stackblitz-starters-tyztyr?file=packages%2Fmy-package-with-rollup%2Frollup.config.mjs

Reproduction Steps

  1. Open https://stackblitz.com/edit/stackblitz-starters-tyztyr?file=packages%2Fmy-package-with-rollup%2Frollup.config.mjs
  2. Run cd packages/my-package-with-rollup/
  3. Run npm run build

Expected Behaviour

Using the @rollup/plugin-typescript plugin in conjunction with the @rollup/plugin-node-resolve plugin should allow rollup to parse TypeScript in files outside the main directory:

// rollup.config.mjs
import nodeResolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';

export default {
  input: ['index.ts'],
  output: {
    file: 'bundle.js',
    format: 'esm',
  },
  plugins: [nodeResolve(), typescript()],
};

// package.json
...
 "dependencies": {
    "my-workspace-package": "workspace:^"
  }

Actual Behaviour

Rollup errors: [!] RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript).

Including outside files in the include pattern does nothing as well:

typescript({ include: ['index.ts', '../my-workspace-package/index.ts'] }),

The filterRoot set to false also doesn't fix it, which I would expect it to based on the docs:

typescript({ filterRoot: flase })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions