Skip to content

outDir set to process.cwd() cause TS5055 error easily #83

@grayflow

Description

@grayflow

What happens and why it is wrong

Environment

Versions

  • typescript: 2.9.1
  • rollup: 0.59.4
  • rollup-plugin-typescript2: 0.14.0

rollup.config.js

import commonjs from "rollup-plugin-commonjs";
import json from 'rollup-plugin-json';
import resolve from "rollup-plugin-node-resolve";

import ts from "typescript";

import typescript from "rollup-plugin-typescript2";

export default {
    input: 'src/main.ts',
    output: {
        file: 'bin/js/bundle.js',
        format: 'iife',
        strict: true,
        sourcemap: true,
    },
    plugins: [
        json({
        }),
        resolve(),
        commonjs(),

        typescript({
            typescript: ts,
            verbosity: 3
        }),
    ]
};

tsconfig.json

{
  "compilerOptions": {
    "charset": "utf8",
    "locale": "zh-CN",
    "module": "es2015",
    "target": "es5",
    "baseUrl": ".",

    "moduleResolution": "node",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "noEmitOnError": true,
    "sourceMap": true,
    "diagnostics": true
  },
  "include": [
    "src",
    "json",
    "LayaAir/LayaAir.d.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

package.json

plugin output with verbosity 3

yarn run v1.7.0
$ rollup -c rollup.config.js

src/main.ts → bin/js/bundle.js...
rpt2: typescript version: 2.9.1
rpt2: rollup-plugin-typescript2 version: 0.14.0
rpt2: plugin options:
{
    "typescript": "version 2.9.1",
    "verbosity": 3,
    "check": true,
    "clean": false,
    "cacheRoot": "/Users/gray/projects/LayaTemplates/1.7.19beta/.rpt2_cache",
    "include": [
        "*.ts+(|x)",
        "**/*.ts+(|x)"
    ],
    "exclude": [
        "*.d.ts",
        "**/*.d.ts"
    ],
    "abortOnError": true,
    "rollupCommonJSResolveHack": false,
    "useTsconfigDeclarationDir": false,
    "tsconfigOverride": {},
    "transformers": [],
    "tsconfigDefaults": {}
}
rpt2: rollup config:
{
    "external": [
        "",
        ""
    ],
    "input": "src/main.ts",
    "chunkGroupingSize": 5000,
    "perf": false,
    "plugins": [
        {
            "name": "json"
        },
        {
            "name": "node-resolve"
        },
        {
            "name": "commonjs"
        },
        {
            "name": "rpt2"
        }
    ],
    "entry": "src/main.ts"
}
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "inlineSourceMap": false,
    "outDir": "/Users/gray/projects/LayaTemplates/1.7.19beta",
    "moduleResolution": 2,
    "declarationDir": null
}
rpt2: parsed tsconfig: {
    "options": {
        "module": 5,
        "charset": "utf8",
        "locale": "zh-CN",
        "target": 1,
        "baseUrl": "/Users/gray/projects/LayaTemplates/1.7.19beta",
        "moduleResolution": 2,
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "forceConsistentCasingInFileNames": true,
        "noEmitOnError": true,
        "sourceMap": true,
        "diagnostics": true,
        "configFilePath": "/Users/gray/projects/LayaTemplates/1.7.19beta/tsconfig.json",
        "noEmitHelpers": false,
        "importHelpers": true,
        "noResolve": false,
        "noEmit": false,
        "inlineSourceMap": false,
        "outDir": "/Users/gray/projects/LayaTemplates/1.7.19beta",
        "declarationDir": null
    },
    "fileNames": [
        "/Users/gray/projects/LayaTemplates/1.7.19beta/src/main.ts",
        "/Users/gray/projects/LayaTemplates/1.7.19beta/LayaAir/LayaAir.d.ts"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "compilerOptions": {
            "module": "es2015",
            "charset": "utf8",
            "locale": "zh-CN",
            "target": "es5",
            "baseUrl": ".",
            "moduleResolution": "node",
            "resolveJsonModule": true,
            "esModuleInterop": true,
            "allowSyntheticDefaultImports": true,
            "forceConsistentCasingInFileNames": true,
            "noEmitOnError": true,
            "sourceMap": true,
            "diagnostics": true
        },
        "include": [
            "src",
            "json",
            "LayaAir/LayaAir.d.ts"
        ],
        "exclude": [
            "node_modules",
            "json"
        ]
    },
    "errors": [],
    "wildcardDirectories": {},
    "compileOnSave": false,
    "configFileSpecs": {
        "includeSpecs": [
            "src",
            "json",
            "LayaAir/LayaAir.d.ts"
        ],
        "excludeSpecs": [
            "node_modules",
            "json"
        ],
        "validatedIncludeSpecs": [
            "src",
            "json",
            "LayaAir/LayaAir.d.ts"
        ],
        "validatedExcludeSpecs": [
            "node_modules",
            "json"
        ],
        "wildcardDirectories": {}
    }
}
rpt2: included:
'[
    "*.ts+(|x)",
    "**/*.ts+(|x)"
]'
rpt2: excluded:
'[
    "*.d.ts",
    "**/*.d.ts"
]'
rpt2: options error TS5055 Cannot write file '/Users/gray/projects/LayaTemplates/1.7.19beta/json/a.json' because it would overwrite input file.
rpt2: Ambient types:
rpt2:     /Users/gray/projects/LayaTemplates/1.7.19beta/LayaAir/LayaAir.d.ts
rpt2:     /Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/@types/estree/index.d.ts
rpt2:     /Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/@types/node/index.d.ts
rpt2: transpiling '/Users/gray/projects/LayaTemplates/1.7.19beta/src/main.ts'
rpt2:     cache: '/Users/gray/projects/LayaTemplates/1.7.19beta/.rpt2_cache/60d02db33c5a1f3b2416647a31884b4a2a666d0d/code/cache/8fa213cd863a0deec8ed932ab96e42abc1472537'
rpt2:     cache miss
rpt2:     cache: '/Users/gray/projects/LayaTemplates/1.7.19beta/.rpt2_cache/60d02db33c5a1f3b2416647a31884b4a2a666d0d/syntacticDiagnostics/cache/8fa213cd863a0deec8ed932ab96e42abc1472537'
rpt2:     cache hit
rpt2:     cache: '/Users/gray/projects/LayaTemplates/1.7.19beta/.rpt2_cache/60d02db33c5a1f3b2416647a31884b4a2a666d0d/semanticDiagnostics/cache/8fa213cd863a0deec8ed932ab96e42abc1472537'
rpt2:     cache hit
rpt2: rolling caches
[!] (rpt2 plugin) Error: failed to transpile '/Users/gray/projects/LayaTemplates/1.7.19beta/src/main.ts'
src/main.ts
Error: failed to transpile '/Users/gray/projects/LayaTemplates/1.7.19beta/src/main.ts'
    at error (/Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/rollup/dist/rollup.js:199:15)
    at Object.error (/Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/rollup/dist/rollup.js:17550:21)
    at /Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20162:31
    at TsCache.getCompiled (/Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:19817:31)
    at Object.transform (/Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20148:34)
    at /Users/gray/projects/LayaTemplates/1.7.19beta/node_modules/rollup/dist/rollup.js:17555:48
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions