https://repl.it/repls/EnchantingHatefulFunctions
Module builds correctly
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
It looks like this is because the paths stored in emittedFileNames don't match the paths in emittedFiles.
{
emittedFileNames: [
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/src/index.fx.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/src/index.fx.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/src/index.fx.d.ts'
],
emittedFiles: [Map Iterator] {
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/utils.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/utils.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/utils.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/errors.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/errors.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/errors.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/types.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/types.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/types.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/http.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/http.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/http.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/endpoint.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/endpoint.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/endpoint.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/requests.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/requests.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/requests.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/batch.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/batch.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/batch.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/collection.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/collection.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/collection.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/bucket.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/bucket.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/bucket.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/base.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/base.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/base.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.browser.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.browser.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.browser.d.ts',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.fx.js.map',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.fx.js',
'C:/Users/Dylan/Documents/git/kinto/kinto-http.js/lib/index.fx.d.ts'
}
}
This only happens when tsconfig.json has a outDir property, and removing it results in the bundle being correctly generated. This didn't occur on v3.0.0, so I assume it's related to switching to the BuilderProgram API.
Give v4.0.0 a shot. We had some issues with how 3.1.0 was published.
@shellscape Just tested and the issue still occurs on 4.0.0.
We've made some adjustments to the plugin and right now we're requiring that outDir be located within your Rollup output dir. Unfortunately the hook that checks this is run after the error is emitted. I'll try to fix this particular case where emittedFileNames and emittedFiles doesn't match.
A quick fix for now is to set compilerOptions.rootDir to "src".
@NotWoods So I just got around to adding rootDir to my tsconfig, and now get the following error:
Error: Could not load C:\Users\Dylan\Desktop\khttp-rollup-ts\node_modules\tslib\tslib.es6.js (imported by C:/Users/Dylan/Desktop/khttp-rollup-ts/src/base.ts): Debug Failure. False expression: Expected fileName to be present in command line at Object.getOutputFileNames (C:\Users\Dylan\Desktop\khttp-rollup-ts\node_modules\typescript\lib\typescript.js:92435:18)
at findTypescriptOutput (C:\Users\Dylan\Desktop\khttp-rollup-ts\node_modules\@rollup\plugin-typescript\dist\index.js:389:33)
at Object.load (C:\Users\Dylan\Desktop\khttp-rollup-ts\node_modules\@rollup\plugin-typescript\dist\index.js:508:28) at C:\Users\Dylan\Desktop\khttp-rollup-ts\node_modules\rollup\dist\shared\node-entry.js:13113:25
at processTicksAndRejections (internal/process/task_queues.js:94:5)
tslib is correctly installed, and I confirmed that the referenced path exists, ,so I'm not sure what it's complaining about. (Also for the record, src/base.ts doesn't import tslib directly.)
May be related to #249.
I have a reproduction repo that can build with outDir configured.
For me this is happening because I want to emit declaration files. When I add "outDir": "" to my tsconfig.json I get the following error:
[!] (plugin babel) SyntaxError: /some/path/types.ts: Support for the experimental syntax 'exportDefaultFrom' isn't currently enabled (5:8):
4 |
> 5 | export enum Alignment {
6 |
before bug fixed, use rollup-plugin-typescript2 instead. Works good.
rollup-plugin-typescript2 - npm
https://www.npmjs.com/package/rollup-plugin-typescript2
@dstaley I'm experiencing a similar error when trying to use this plugin with Vue.js single file components. Did you find a workaround?
```
[!] (plugin typescript) Error: Could not load /Users/[USERNAME]/[PROJECT]/src/components/[COMPONENT].vue?rollup-plugin-vue=script.ts (imported by /Users/[USERNAME]/[PROJECT]/src/components/[COMPONENT].vue): Debug Failure. False expression: Expected fileName to be present in command line
Error: Could not load /Users/[USERNAME]/[PROJECT]/src/components/[COMPONENT].vue?rollup-plugin-vue=script.ts (imported by /Users/[USERNAME]/[PROJECT]/src/components/[COMPONENT].vue): Debug Failure. False expression: Expected fileName to be present in command line
at Object.getOutputFileNames (/Users/[USERNAME]/[PROJECT]/node_modules/typescript/lib/typescript.js:89684:18)
at findTypescriptOutput (/Users/[USERNAME]/[PROJECT]/node_modules/@rollup/plugin-typescript/dist/index.js:389:33)
at Object.load (/Users/[USERNAME]/[PROJECT]/node_modules/@rollup/plugin-typescript/dist/index.js:508:28)
at /Users/[USERNAME]/[PROJECT]/node_modules/rollup/dist/shared/rollup.js:17441:25
@gwardwell Same here. Changed the order of the vue plugin so it's before the ts plugin
@MarvinRudolph I tried that and saw the same error. Rearranging corejs to after typescript and Vue plugins ultimately solved it for me.
Thanks for replying!
Hey folks, if you'd like to share an error with this thread, please make sure that it's accompanied by a reproduction:
- Using the REPL at https://rollupjs.org/repl/, or
- Using the REPL.it reproduction template at https://repl.it/@rollup/rollup-repro
(allows full use of all rollup options and plugins), or- Provide a minimal repository link (Read https://git.io/fNzHA for instructions).
These may take more time to triage than the other options.
Moving forward, replies with nothing but error messages, or +1, "me too," or "same error" will be hidden as off-topic.
I tried using recommendations from this branch:
1)
typescript()
Error: @rollup/plugin-typescript: 'outDir' or 'declarationDir' must be specified to generate declaration files.
2)
typescript({
outDir: outDir
})
Error: @rollup/plugin-typescript: 'dir' must be used when 'outDir' is specified.
3)
typescript({
dir: outDir,
outDir: outDir
})
Error: @rollup/plugin-typescript: Couldn't process compiler options
I tried everything. How do I write it correctly?
dir is specified under Rollup's output options.
Faced the same issue, and fixed it as suggested by @NotWoods. However it seems that the "chunkFileNames" option is ignored when generating output... Given that the "file" option is incompatible with the "dir" option, how can the name of generated output files be specified?
My use case is to bundle multiple variants from the same typescript project which uses incremental builds and multiple modules.
So I changed typescript.compilerOptions.outDir to "build/ts" (to make sure it's in rollup's dir as described) and the plugin works but the result ends up right in build (while straight tsc results end up in build/ts as expected)...
@gwardwell
I tried that and saw the same error. Rearranging corejs to after typescript and Vue plugins ultimately solved it for me.
Same problem you are facing.
I tried to change the order but it can't work.
Can you show your rollup config?.
This issue, along with other TS problems, make it a pain to use rollup from inside of a npm package, and use the source files from the CWD where its ran :(
Hey folks. This is a call for contribution and help in resolving this TypeScript plugin issue. We're working with limited resources and the folks who can help have limited time. If you can help by triaging and submitting a Pull Request, we'd be happy to review it.
fwiw, I just got also... (node:9170) UnhandledPromiseRejectionWarning: Error: Cannot find module 'tslib/tslib.es6.js' from '[...]/node_modules/@rollup/plugin-typescript/dist'
but when checking that dir it contains no tslib/tslib.es6.js but only
index.es.js
index.js
_Edit: ignore what I wrote, I just had to install tslib_
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ
For anyone who stumbles on this: I believe most of the discussion is now happening in https://github.com/rollup/plugins/issues/287
Most helpful comment
Faced the same issue, and fixed it as suggested by @NotWoods. However it seems that the "chunkFileNames" option is ignored when generating output... Given that the "file" option is incompatible with the "dir" option, how can the name of generated output files be specified?
My use case is to bundle multiple variants from the same typescript project which uses incremental builds and multiple modules.