Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript] Broken vue3 + rollup + typescript #608

Closed
iassasin opened this issue Oct 16, 2020 · 11 comments
Closed

[typescript] Broken vue3 + rollup + typescript #608

iassasin opened this issue Oct 16, 2020 · 11 comments

Comments

@iassasin
Copy link

  • Rollup Plugin Name: typescript
  • Rollup Plugin Version: 6.0.0 (current latest)
  • Rollup Version: 2.29.0
  • Operating System (or Browser): linux if neccesary, reproduces at bundle build time
  • Node Version: 14.13.1
  • Link to reproduction (⚠️ read below): https://github.com/iassasin/vue3-rollup-ts-bug

Expected Behavior

Working bundle.

Actual Behavior

[!] (plugin typescript) Error: Could not load .../MainView.vue?vue&type=script&lang.ts (imported by MainView.vue): Debug Failure. False expression: Expected fileName to be present in command line

Additional Information

Also reported to vue-rollup-plugin (vuejs/rollup-plugin-vue#400), but after some debug I suggess that bug is in plugin-typescript, because with rollup-plugin-typescript2 bundle built successfuly. Difference to plugin-typescript2 is official plugin-typescript uses function ts.getOutputFileNames, that produces failed assert.

@shellscape
Copy link
Collaborator

Please see if any of these issues with the same error message addresses your issue: https://github.com/rollup/plugins/search?q=Expected+fileName+to+be+present+in+command+line&type=issues

@iassasin
Copy link
Author

@shellscape, thanks for fast answer! Only this comment (#243 (comment)) with similar issue, but the issue where comment paced it not about it. Probably this is separate issue. Also in my reproduction repo includes in tsconfig already configured to match vue files, but it doesn't work anyway.

I can suggess the nature of this bug: rollup-plugin-vue generates virtual files (i.e. file.vue?some-plugin-metadata.ts) that doesn't exists on real filesystem, so typescript compiler at init phase doesn't know about this virtual files and cant add it to includes-list. Then plugin-typescript calls ts.getOutputFileNames function, where goes check for current file included in includes and compiler internal check fails, we see error in output. plugin-typescript2 does not call this function, so there is no error.

@shellscape
Copy link
Collaborator

I don't think we're going to be able to resolve this one at present. The nature of the typescript plugin here is that it has to know about all files. You might have to go with a different typescript plugin that doesn't use the same BuilderProgram approach that ours does.

@spaceemotion

This comment has been minimized.

@shellscape
Copy link
Collaborator

@spaceemotion we don't offer support here, and typescript2 is not a plugin in this repo.

@rollup rollup deleted a comment from spaceemotion Dec 16, 2020
@stale stale bot added the x⁷ ⋅ stale label Feb 14, 2021
@stale
Copy link

stale bot commented Feb 15, 2021

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.

@stale stale bot closed this as completed Feb 15, 2021
@mnlipp
Copy link

mnlipp commented Feb 28, 2021

The cause of the problem is that the plugin simply doesn't pick up the file names used (generated) by rollup-plugin-vue.

See this repository for a simple example with some debugging output. The file src/components/hello/Hello.vue?vue&type=script&lang.ts is never transformed by the plugin. Thus rollup tries to process it in its final stage, which fails, of course.

src/components/hello/Hello.vue?vue&type=script&lang.ts (13:16)
11:     
12:     setup(props) {
13:         let temp: string | null = null; 
                    ^
14:         return {};
15:     },
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

@973782523
Copy link

原因是插件根本没有选

I also encountered this situation, will solve later

@973782523
Copy link

问题的原因是插件根本没有选择 rollup-plugin-vue 使用(生成)的文件名。

有关一些调试输出的简单示例,请参阅此存储库。该文件src/components/hello/Hello.vue?vue&type=script&lang.ts永远不会被插件转换。因此, rollup 试图在最后阶段处理它,当然,这失败了。

src/components/hello/Hello.vue?vue&type=script&lang.ts (13:16)
11:     
12:     setup(props) {
13:         let temp: string | null = null; 
                    ^
14:         return {};
15:     },
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

Did you solve it? I'm just like you right now, looking everywhere

@mnlipp
Copy link

mnlipp commented Jun 4, 2021

I've used another typescript plugin instead of this "official" one (as mentioned above).

@973782523
Copy link

I've used another typescript plugin instead of this "official" one (as mentioned above).

I worked late that night, and I was using another TypeScript

rollup-plugin-typescript2
Is this!

Liubasara added a commit to Liubasara/CustomUI that referenced this issue Dec 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants