question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Could not find source file` when running in watch mode with `rollup-plugin-vue`

See original GitHub issue

What happens and why it is wrong

When running rollup in watch mode, the project will initially compile but changes to some files that trigger rollup watch, will cause a source file not found error from rp2:

[!] (plugin rpt2) Error: Could not find source file: '/<path removed>/watch-err/source/lib/module1.ts'.
Error: Could not find source file: '/<path removed>/watch-err/source/lib/module1.ts'.
    at getValidSourceFile (/<path removed>/watch-err/node_modules/typescript/lib/typescript.js:153646:29)
    at Object.getSyntacticDiagnostics (/<path removed>/watch-err/node_modules/typescript/lib/typescript.js:153896:52)
    at /<path removed>/watch-err/node_modules/rollup-plugin-typescript2/src/index.ts:306:23
    at TsCache.getDiagnostics (/<path removed>/watch-err/node_modules/rollup-plugin-typescript2/src/tscache.ts:298:49)
    at TsCache.getSyntacticDiagnostics (/<path removed>/watch-err/node_modules/rollup-plugin-typescript2/src/tscache.ts:238:15)
    at /<path removed>/watch-err/node_modules/rollup-plugin-typescript2/src/index.ts:304:15
    at /<path removed>/watch-err/node_modules/rollup-plugin-typescript2/src/tscache.ts:183:61
    at arrayEach (/<path removed>/watch-err/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:516:11)
    at Function._.each [as forEach] (/<path removed>/watch-err/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9368:14)
    at TsCache.walkTree (/<path removed>/watch-err/node_modules/rollup-plugin-typescript2/src/tscache.ts:183:4)

Repository with reproduction code

Steps to reproduce:

  1. Run rollup -c rollup.config.js --watch
  2. Trigger rollup watch by re-saving module2.ts or index.ts. Note that triggering watch with module1.ts will not produce the error.

I assume this is related to the directory structure of the project which uses baseUrl to point up to the “lib” dir. Also, I was not able to reproduce this without Vue.

Environment

MacOS 10.15 Node 16

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
danielvycommented, Jun 25, 2022

@agilgur5

Great news. Thank you for taking the time to fix this. I can go back to using rollup’s watch instead of relying on nodemon during development.

0reactions
agilgur5commented, Aug 23, 2022

#364 has been released in 0.33.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source file not found error when running in "watch" mode -
When running rollup in watch mode, the project will initially compile ... rollup watch, will cause a source file not found error from...
Read more >
Bundling with Rollup - Vue.js 3 Course
In this article we will write a rollup config from scratch to compile a project written in TypeScript. Our goal will be three...
Read more >
snowpack.config.js
Specifies the “mode” that Snowpack should run in. ... "test" : testOptions.files are not excluded, and will be scanned & built as normal...
Read more >
Installation - Vue.js
You can browse the source of the NPM package at cdn.jsdelivr.net/npm/vue. Vue is also available on unpkg and cdnjs (cdnjs takes some time...
Read more >
Configuring Vitest
VITEST or mode property on defineConfig (will be set to test ... and cannot fail before your running code, so you will most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found