ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
819 stars 71 forks source link

`Error: Unexpected early exit` #430

Closed tjx666 closed 1 year ago

tjx666 commented 1 year ago

Troubleshooting

  1. Does tsc have the same output? If so, please explain why this is incorrect behavior

    tsc no error:

image

but this plugin:

image
  1. Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate Yes

  2. Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction

    This is my company project, maybe later

What happens and why it is incorrect

throw error

image

Environment

Versions

image

rollup.config.js

:
image

tsconfig.json

:
```json5 { "$schema": "https://json.schemastore.org/tsconfig", "display": "Base", "compilerOptions": { "target": "esnext", "module": "esnext", "lib": ["DOM", "ESNext"], "composite": false, "declaration": false, "esModuleInterop": true, "jsx": "preserve", "allowJs": true, "strictFunctionTypes": false, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "inlineSources": false, "isolatedModules": true, "moduleResolution": "node", "noUnusedParameters": false, "preserveWatchOutput": true, "skipLibCheck": true, "strict": true, "resolveJsonModule": true, "removeComments": true, "noUnusedLocals": false, "noImplicitAny": false, "noImplicitThis": true, "experimentalDecorators": true, "types": ["@scripts/types/global"] }, "vueCompilerOptions": { "target": 2.7 } } ```

package.json

:
```json ```

plugin output with verbosity 3

:
```text ```
tjx666 commented 1 year ago

even doesn't work when I add // @ts-no-check comment

image
agilgur5 commented 1 year ago

parsing error

even doesn't work when I add // @ts-no-check comment

So this looks to be a plugin parsing error and unrelated to type-checking.

The error is:

[!] Error: Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(rpt2) transform "<filepath>.ts"

The only reference online I can find for this error is to Vite: https://github.com/vitejs/vite/issues/8479. This seems to be a recent error in Rollup, so I wonder if this is due to a newer version of Rollup that we haven't tested with.

The message and that issue suggests it's either an unresolved Promise somewhere or a deadlock or something. That would be a potential regression from #406 (which added asynchronous transforms in order to pipe elided TS imports into Rollup).

workarounds

As such two possible workarounds would be:

  1. downgrade Rollup
  2. downgrade rpt2 to < 0.34.0, pre #406.

needs more information and repro in order to fix

While this seems to be related to the code in #406, that was extensively tested and hasn't had any bug reports in a few months. I also added deadlock prevention with cycle checking there.

So it's really difficult to tell what the problematic code is without more information.

A minimal reproduction could help quite a bit to narrow down the issue and run this in a debugger.

You seem to have quite a bit of dependencies here (and not all are listed) which makes it difficult to narrow down. The verbosity: 3 log also doesn't seem complete -- with a full log we might be able to see if there's a cycle or something.

I also see that you're using @rollup/plugin-babel as well, and, in particular, running it before rpt2. If Babel is doing any transpiling of TS that could result in a variety of issues, as rpt2 would then instead be running on untyped JS.

extensions is also not a valid option of rpt2 (and there's a typo in it too). The docs explicitly state how to configure allowJs. So there seems to be at least one misconfiguration here as well.

text > screenshots

Please note that text is strongly preferred over screenshots when reporting GitHub issues (or StackOverflow questions, per the link), as text can be copied, searched, etc and is significantly more accessible, while screenshots cannot / are not nearly as accessible.

agilgur5 commented 1 year ago

Closing as stale as there has been no response for over a month now and there is no way to move forward without more information from OP.