Monorepo: watch mode results in `Error: Could not find source file`
See original GitHub issueWhat happens and why it is wrong
A normal one-time build works fine. However, when using rollup -w
, rpt2 seems to have trouble finding source files if I edit one of the deeper module dependencies in one of the other packages.
This is with a Lerna monorepo setting up symlinks to the in-repo dependencies.
Test repo: https://github.com/jrburke/jr-monorepo-rpt2
I do not want to use preserveSymlinks
because in my real project, it results in duplicates of modules in the final built project, since multiple packages in the repo share common dependencies. I have tried a version using preserveSymlinks
, and so as a last resort I could configure a dev setup that uses preserveSymlinks
, but standalone/first time builds work without it, and I would like to keep the watch setup the same as the normal builds.
Environment
Details to reproduce in the above example repo.
Versions
- typescript: 3.8.3
- rollup: 1.32.1
- rollup-plugin-typescript2: 0.26.0
rollup.config.js
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
export default {
input: 'src/index.ts',
output: {
file: 'dist/jr-player.js',
format: 'iife',
name: 'jrPlayer',
exports: 'named'
},
watch: {
include: ['src/**', '../jr-lib/src/**', '../jr-auth/src/**']
},
plugins: [
typescript({
include: ['src/**/*.ts+(|x)', '../jr-lib/**/*.ts+(|x)', '../jr-auth/**/*.ts+(|x)'],
verbosity: 3
}),
resolve(),
commonjs()
]
};
tsconfig.json
Top level tsconfig.json:
{
"compilerOptions": {
"moduleResolution": "node",
"module": "es2015",
"lib": [
"es2015",
"es2016",
"es2017",
"dom"
],
"strict": true,
"sourceMap": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"downlevelIteration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": false,
"esModuleInterop": true,
"removeComments": true,
"resolveJsonModule": true,
"skipLibCheck": true
}
}
packages/jr-player/tsconfig.json
:
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es5",
"declarationDir": "lib",
"outDir": "lib"
},
"include": ["."]
}
package.json
I don’t think it is relevant, but it is in the test repo.
plugin output with verbosity 3
Attached, but also in test repo at verbose-error.txt
:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top GitHub Comments
I have the issue combining
rollup-plugin-typescript2
androllup-plugin-postcss
. When I import a css file (e.g.import * as style from "./mystyle.css"
) and I enable watch flag, it gives me the same error.I’ll try debug a little bit more, but indeed
check: false
fix the issue.I have a similar issue currently, using lerna and a
(plugin rpt2) Error: Could not find source file
showed up.I fix this by simply change the order of the plugins from:
to
Maybe you can have a shot.