Repository navigation
Typescript watcher cannot recover #255
Copy link
Copy link
Closed
Description
- Rollup Plugin Name:
@rollup/plugin-typescript - Rollup Plugin Version:
4.0.0 - Rollup Version:
2.0.3 - Operating System (or Browser): mac
- Node Version:
10.15.0
How Do We Reproduce?
Running rollup in watch mode with typescript plugin if the typescript code is invalid the watcher breaks and exits with exit code 1. This make it impossible to re-build the code on code changes - you need to re-start the command every time.
- Start with a simple ts file:
export default (a: number, b: number): number => {
return a + b;
};- Start the watcher
rollup -c --watch - Comment out out some code (making it invalid syntax) and save the file:
export default (a: number, b: number): number => {
return a + b;
// };- The watcher breaks completely:
{ Error: @rollup/plugin-typescript TS1005: '}' expected.
at error (/THE_REPRO/node_modules/rollup/dist/shared/rollup.js:10120:30)
at throwPluginError (/THE_REPRO/node_modules/rollup/dist/shared/rollup.js:16242:12)
at Object.error (/THE_REPRO/node_modules/rollup/dist/shared/rollup.js:17226:24)
at emitDiagnostic (/THE_REPRO/node_modules/@rollup/plugin-typescript/dist/index.js:412:17)
at reportDiagnostics (/THE_REPRO/node_modules/@rollup/plugin-typescript/dist/index.js:420:9)
at Array.forEach (<anonymous>)
at emitFilesAndReportErrors (/THE_REPRO/node_modules/typescript/lib/typescript.js:102879:21)
at Object.result.afterProgramCreate (/THE_REPRO/node_modules/typescript/lib/typescript.js:103054:13)
at Object.afterProgramCreate (/THE_REPRO/node_modules/@rollup/plugin-typescript/dist/index.js:441:29)
at synchronizeProgram (/THE_REPRO/node_modules/typescript/lib/typescript.js:103300:22)
pluginCode: 'TS1005',
loc:
{ column: 1,
line: 4,
file:
'/THE_REPRO/packages/app/src/test.ts' },
frame:
'\n\u001b[7m4\u001b[0m \n\u001b[7m \u001b[0m \u001b[91m\u001b[0m\n\n \u001b[96msrc/test.ts\u001b[0m:\u001b[93m1\u001b[0m:\u001b[93m50\u001b[0m\n \u001b[7m1\u001b[0m export default (a: number, b: number): number => {\n \u001b[7m \u001b[0m \u001b[96m ~\u001b[0m\n The parser expected to find a \'}\' to match the \'{\' token here.\n',
code: 'PLUGIN_ERROR',
plugin: 'typescript' }
error Command failed with exit code 1.
rollup.config.js:
import typescript from '@rollup/plugin-typescript';
import babel from 'rollup-plugin-babel';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import { terser } from 'rollup-plugin-terser';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import reactSvg from 'rollup-plugin-react-svg';
import pkg from './package.json';
const isProd = process.env.NODE_ENV === 'production';
export default {
input: 'src/index.js',
output: { format: 'cjs', file: pkg.main, sourcemap: true },
plugins: [
typescript(),
babel({ exclude: 'node_modules/**' }),
resolve(),
commonjs(),
peerDepsExternal({ includeDependencies: true }),
postcss({ plugins: isProd ? [autoprefixer, cssnano] : [] }),
reactSvg({ svgo: { plugins: [{ removeViewBox: false }] } }),
isProd && terser({ compress: true, mangle: true }),
].filter(Boolean),
};
Expected Behavior
The watcher shouldn't exit with exit code 1, it should wait for further code changes and try to recompile modified source.
Actual Behavior
Watcher breaks and exits with exit code 1.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
shellscape commentedon Mar 12, 2020
Thanks for opening an issue. Citing the issue template:
Please add a reproduction and we'll be happy to triage further.
NotWoods commentedon Mar 12, 2020
You should also use the
noEmitOnErroroption to only warn, rather than error.