use the same plugin to bundle any .ts/.tsx file it throws an error
components/index.ts → dist/components/index.js, dist/components/index.es.js...
[!] (plugin typescript) Error: Could not load /Users/madhuds/proj/uie/components/index.ts: Debug Failure. False expression: Expected fileName to be present in command line
Error: Could not load /Users/madhuds/proj/uie/components/index.ts: Debug Failure. False expression: Expected fileName to be present in command line
at Object.getOutputFileNames (/Users/madhuds/proj/uie/node_modules/typescript/lib/typescript.js:92435:18)
at findTypescriptOutput (/Users/madhuds/proj/uie/node_modules/@rollup/plugin-typescript/dist/index.js:389:33)
at Object.load (/Users/madhuds/proj/uie/node_modules/@rollup/plugin-typescript/dist/index.js:508:28)
at Promise.resolve.then (/Users/madhuds/proj/uie/node_modules/rollup/dist/shared/node-entry.js:13117:25)
at process._tickCallback (internal/process/next_tick.js:68:7)
should ideally find the file
unable to find the file
Thanks for opening an issue. Citing the issue template:
Issues without minimal reproductions will be closed! Please provide one by:
- Using the REPL.it plugin reproduction template at https://repl.it/@rollup/rollup-plugin-repro
- Provide a minimal repository link (Read https://git.io/fNzHA for instructions).
These may take more time to triage than the other options.- Using the REPL at https://rollupjs.org/repl/
Please add a reproduction and we'll be happy to triage further.
hi @madhudskumar
could you find a fix after all? I'm having the very same issue.
In my case this was because I didn't add @rollup/plugin-node-resolve
The full error was:
$ npx rollup index.ts -c
index.ts → index.js, module.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
select-dom (imported by index.ts, utils.ts)
onetime (imported by utils.ts)
[!] (plugin typescript) Error: Could not load /Users/rico/Web/projects-modules/github-url-detection/tests/collector.ts (imported by /Users/rico/Web/projects-modules/github-url-detection/index.ts): Debug Failure. False expression: Expected fileName to be present in command line
And the solution:
import typescript from '@rollup/plugin-typescript';
+ import resolve from '@rollup/plugin-node-resolve';
export default {
input: "index.ts",
output: [
{
format: 'cjs',
file: 'index.js'
},
{
format: 'esm',
file: 'module.js'
}
],
plugins: [
+ resolve(),
typescript()
]
};
➡️ Alternatively: you need to include the mentioned file or folder in your tsconfig.json (this is probably the reason)
In my case:
{
"extends": "@sindresorhus/tsconfig",
"include": [
+ "tests", // because my file was under `./tests`
"index.ts",
"test.ts",
"utils.ts",
"webpack.config.ts"
]
}
For anyone (like me) who finds this through Google search, what fixed it for me was moving @rollup/plugin-node-resolve before @rollup/plugin-typescript 😅 :-
- typescript(),
resolve(),
+ typescript(),
I was using these plugins, along with rollup-plugin-chrome-extension.
Another hint: I've been experiencing this with Svelte's TypeScript integration.
The gist was that rollup's watch mode somehow didn't recognize the new files I had created while it was already running, so I had to just restart rollup.
I have it error too.
I have tried to reproduce here.
https://repl.it/repls/FlakyAwkwardViruses
But cal from cli: tsc -p ./appFolder/appA/tsconfig.app.json it is ok.
Just as @loilo mentions, rollup in watch mode does not recognize added files when used in conjunction with Svelte and Typescript. This is very bothersome as all new files added requires a full restart.
Also, this is only when importing from a new .ts file. If you add a new .svelte file, it works as expected, so I'm guessing there is a configuration issue.
To reproduce, simply:
And here is a full stacktrace with the issue from a newly created project as instructed above:
[!] (plugin typescript) Error: Could not load [fullpath]/src/something.ts (imported by src\Test.svelte): Debug Failure. False expression: Expected fileName to be present in command line
Error: Could not load C:/projects/vest/discovered/src/something.ts (imported by src\Test.svelte): Debug Failure. False expression: Expected fileName to be present in command line
at Object.getOutputFileNames (C:\projects\vest\discovered\node_modules\typescript\lib\typescript.js:94573:18)
at findTypescriptOutput (C:\projects\vest\discovered\node_modules\@rollup\plugin-typescript\dist\index.js:392:33)
at Object.load (C:\projects\vest\discovered\node_modules\@rollup\plugin-typescript\dist\index.js:513:28)
at C:\projects\vest\discovered\node_modules\rollup\dist\shared\rollup.js:18269:25
Looks like there is an issue with tsconfig.json file only having my root entry file in the files section, when i changes to "include": [ "src/**/*" ] the error disappears
None of the suggested fixes has worked for me, but as a work-around, you can declare your TS code withing a svelte file with a module context:
<script context="module" lang="ts">
export const serviceFunction = () => {
// ...
}
// etc...
</script>
This seems to work fine with hot reloading etc. Not sure if it has any sideeffects though.
I have the same problem as above, new files are not picked up by Svelte and full reboot is necessary. This is very annoying if you are working inside a large Docker stack because boot time can take a minute.
Using .svelte files with module context fixes the issue, but it annoys the crap out of me to write pure TS files inside .svelte files.
@sudomaxime while I'm sorry for your frustration, the issues here are not for venting. If you have the same problem, but don't have any technical information to aid in triage or resolution of the issue, please abstain from replying with a "me too" type reply, and use the reaction buttons instead.
@shellscape then can you reopen the issue since the reproduction steps were given in a previous comment?
This might help someone else, i had the same error. But i had wrong imports using lowercase, while the filenames where CamelCase
I seem to be having a similar issue here. When I try to load a typescript file from an ESM module using rollup.
[!] (plugin typescript) Error: Could not load .../rollup-ng-typescript-demo/ng/Application.ts (imported by index.mjs): Debug Failure. False expression: Expected fileName to be present in command line
I tried both with and without the .ts extension in the import
Most helpful comment
Another hint: I've been experiencing this with Svelte's TypeScript integration.
The gist was that rollup's watch mode somehow didn't recognize the new files I had created while it was already running, so I had to just restart rollup.