- 
                Notifications
    You must be signed in to change notification settings 
- Fork 70
Closed
Labels
kind: featureNew feature or requestNew feature or requestkind: supportAsking for support with something or a specific use caseAsking for support with something or a specific use casesolution: tsc behaviorThis is tsc's behavior as well, so this is not a bug with this pluginThis 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)Related to monorepos and/or symlinks (Lerna, Yarn, PNPM, Rush, etc)
Description
What happens and why it is wrong
Environment
I am trying to setup a monorepo with local packages. I am using pnpm workspaces but could also go with tsconfig's paths features. Whatever, I don't get it to work and would love to see an example where somebody gets a monorepo working with this plugin.
My problem is that I get this all the time:
index.ts → index.js...
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
../greeter/index.ts (2:6)
1: export default class {
2:   name: string
         ^
3:
note that the imported local package (greeter) has a index.js, index.mjs and index.d.ts file
Versions
- typescript: 3.9.7
- rollup: 2.23
- rollup-plugin-typescript2: 3.1.1
rollup.config.js
import alias from '@rollup/plugin-alias'
import typescript from 'rollup-plugin-typescript2'
module.exports = {
  input: 'index.ts',
  output: {
    file: 'index.js',
    format: 'module',
  },
  plugins: [
    alias({
      entries: [{ find: 'greeter', replacement: '../greeter' }],
    }),
    typescript(),
  ],
}tsconfig.json
{
  "compilerOptions": {
    "target": "esnext",
    "moduleResolution": "node"
  }
}package.json
{
  "name": "app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "typescript": "^3.9.7"
  },
  "dependencies": {
    "@rollup/plugin-alias": "^3.1.1",
    "greeter": "workspace:^1.0.0",
    "rollup-plugin-typescript2": "^0.27.1",
    "tslib": "^2.0.0"
  }
}plugin output with verbosity 3
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "inlineSourceMap": false,
    "outDir": "~/test/app/node_modules/.cache/rollup-plugin-typescript2/placeholder",
    "moduleResolution": 2,
    "allowNonTsExtensions": true,
    "module": 5
}
rpt2: parsed tsconfig: {
    "options": {
        "target": 99,
        "moduleResolution": 2,
        "configFilePath": "~/test/app/tsconfig.json",
        "noEmitHelpers": false,
        "importHelpers": true,
        "noResolve": false,
        "noEmit": false,
        "inlineSourceMap": false,
        "outDir": "~/test/app/node_modules/.cache/rollup-plugin-typescript2/placeholder",
        "allowNonTsExtensions": true,
        "module": 5
    },
    "fileNames": [
        "~/test/app/index.ts"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "compilerOptions": {
            "target": "esnext",
            "moduleResolution": "node"
        },
        "compileOnSave": false
    },
    "errors": [],
    "wildcardDirectories": {
        "~/test/app": 1
    },
    "compileOnSave": false,
    "configFileSpecs": {
        "includeSpecs": [
            "**/*"
        ],
        "validatedIncludeSpecs": [
            "**/*"
        ],
        "wildcardDirectories": {
            "~/test/app": 1
        }
    }
}
rpt2: typescript version: 3.9.7
rpt2: tslib version: 1.11.2
rpt2: rollup version: 2.23.0
rpt2: rollup-plugin-typescript2 version: 0.27.1
rpt2: plugin options:
{
    "verbosity": 3,
    "check": true,
    "clean": false,
    "cacheRoot": "~/test/app/node_modules/.cache/rollup-plugin-typescript2",
    "include": [
        "*.ts+(|x)",
        "**/*.ts+(|x)"
    ],
    "exclude": [
        "*.d.ts",
        "**/*.d.ts"
    ],
    "abortOnError": true,
    "rollupCommonJSResolveHack": false,
    "useTsconfigDeclarationDir": false,
    "tsconfigOverride": {},
    "transformers": [],
    "tsconfigDefaults": {},
    "objectHashIgnoreUnknownHack": false,
    "cwd": "~/test/app",
    "typescript": "version 3.9.7"
}
rpt2: rollup config:
{
    "external": [],
    "input": "index.ts",
    "plugins": [
        {
            "name": "alias"
        },
        {
            "name": "rpt2"
        },
        {
            "name": "stdin"
        }
    ],
    "output": [
        {
            "file": "index.js",
            "format": "module",
            "plugins": []
        }
    ]
}
rpt2: tsconfig path: ~/test/app/tsconfig.json
rpt2: included:
[
    "*.ts+(|x)",
    "**/*.ts+(|x)"
]
rpt2: excluded:
[
    "*.d.ts",
    "**/*.d.ts"
]
rpt2: ^[[34mAmbient types:^[[39m
rpt2:     ~/test/node_modules/.pnpm/@types/[email protected]/node_modules/@types/estree/index.d.ts
rpt2: ^[[33mambient types changed, redoing all semantic diagnostics^[[39m
rpt2: ^[[34mtranspiling^[[39m '~/test/app/index.ts'
rpt2:     cache: '~/test/app/node_modules/.cache/rollup-plugin-typescript2/rpt2_4a23a64245ad76cbf88c568d3f033c4b438c240a/code/cache/02a6dc8db60bdf18980df68001d986771ff54b6f'
rpt2: ^[[33m    cache miss^[[39m
rpt2:     cache: '~/test/app/node_modules/.cache/rollup-plugin-typescript2/rpt2_4a23a64245ad76cbf88c568d3f033c4b438c240a/syntacticDiagnostics/cache/02a6dc8db60bdf18980df68001d986771ff54b6f'
rpt2: ^[[33m    cache miss^[[39m
rpt2:     cache: '~/test/app/node_modules/.cache/rollup-plugin-typescript2/rpt2_4a23a64245ad76cbf88c568d3f033c4b438c240a/semanticDiagnostics/cache/02a6dc8db60bdf18980df68001d986771ff54b6f'
rpt2: ^[[33m    cache miss^[[39m
rpt2: ^[[34mresolving^[[39m '../greeter' imported by '~/test/app/index.ts'
rpt2:     to '~/test/greeter/index.ts'
Metadata
Metadata
Assignees
Labels
kind: featureNew feature or requestNew feature or requestkind: supportAsking for support with something or a specific use caseAsking for support with something or a specific use casesolution: tsc behaviorThis is tsc's behavior as well, so this is not a bug with this pluginThis 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)Related to monorepos and/or symlinks (Lerna, Yarn, PNPM, Rush, etc)