wessberg / rollup-plugin-ts

A TypeScript Rollup plugin that bundles declarations, respects Browserslists, and enables seamless integration with transpilers such as babel and swc
MIT License
496 stars 33 forks source link

Watch mode breaks when editing style files. #178

Closed diego-toro closed 2 years ago

diego-toro commented 2 years ago

Reproduction

When working on watch mode

rollup -c -w

An error pops up when trying to edit a .module.scss

Here is a sample code to replicate the issue https://github.com/diego-toro/rollup-ts-reexport-bug.

  1. Clone the repo
  2. Start running the app: npm run start
  3. Try to edit the .module.scss file
  4. You should get an error

Expected Behavior

Rebuilds code

Actual Behavior

Throws an error after editing a .module.scss file when rollup in watch mode

[!] (plugin Typescript) TypeError: Cannot read properties of null (reading 'length')
TypeError: Cannot read properties of null (reading 'length')
    at iterateCommentRanges (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:10470:45)
    at reduceEachLeadingCommentRange (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:10561:16)
    at Object.getLeadingCommentRanges (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:10576:16)
    at Object.getJSDocCommentRanges (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:15302:16)
    at addJSDocComment (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:31050:42)
    at parseSourceFileWorker (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:31023:34)
    at Object.parseSourceFile (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:30855:26)
    at Object.createSourceFile (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/typescript/lib/typescript.js:30653:29)
    at CompilerHost.constructSourceFile (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/rollup-plugin-ts/dist/cjs/index.js:7700:37)
    at CompilerHost.add (/Users/diegotoro/code/rollup-ts-reexport-bug/node_modules/rollup-plugin-ts/dist/cjs/index.js:7660:37)
wessberg commented 2 years ago

Fixed in v2.0.7. Sorry about that!

diego-toro commented 2 years ago

Awesome! thanks