`outDir` set to `process.cwd()` cause `TS5055` error easily
See original GitHub issueWhat 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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Getting a storm of "error TS5055" messages on every ...
The solution is to add a new field, "outDir", to the compilerOptions, so it looks like this ... There will be no more...
Read more >TSConfig Option: rootDir - TypeScript
It would be an error to specify rootDir as core and include as * because it creates a file ( helpers.ts ) that...
Read more >TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >How To Fix the “Enoent” Error? - Position Is Everything
The enoent error can be appeared because of some missing files. You can get to know what other causes are by reading this...
Read more >Package Diff: @angular/compiler-cli @ 7.2.0 .. 7.2.15
+ kind: 'variable', type, get definition() { return getDefinitionOf(info, variable); }. }); ... + const basePath = path.resolve(process.cwd(), projectDir);.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@grayflow I don’t think I can respect mapRoot – I’m not writing out maps myself, I give them to rollup and it meshes them with maps generated by other plugins on the chain and then generates its own mapping for the bundle. For example if you add uglify plugin, maps will go
ts -> plain js -> uglified js -> bundled js
(not sure about the order of the last two)@ezolenko , it works