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

Fix unplugin emitDeclaration and Windows behavior #895

Merged
merged 2 commits into from
Dec 26, 2023
Merged

Conversation

edemaine
Copy link
Collaborator

Implement @imm's suggestions for fixing emitDeclaration:

  • Remove mkdir preceding this.emitFile; this.emitFile should do this already (indeed, unplugin does it explicitly for esbuild)
  • Switch emit call from async to synchronous.
  • Add warning when using esbuild and no outdir option (as our example was doing), which prevents us (technically, unplugin) from emitting declarations because don't know where to put them.

Additionally, I realized there were bugs specific to Windows, which I was seeing but @imm wasn't (presumably not being on Windows):

  • fsMap was getting the wrong code for slashed versions of filenames: the Civet source instead of the compiled TS! So I was getting error messages like main.civet.jsx:1:5 - error TS1434: Unexpected keyword or identifier., despite things seeming to also work (but probably not very well).
  • this.emitFile was getting called on both original and slashed versions of files. This was leading to double emits, with error messages like (!) The emitted file "main.civet.d.ts" overwrites a previously emitted file of the same name. To fix this, I removed the duplicates from fsMap in the emit phase.

I've tested esbuild and rollup and this seems to work much better.

@edemaine edemaine merged commit a11cc7e into main Dec 26, 2023
3 checks passed
@edemaine edemaine deleted the unplugin-windows branch December 26, 2023 16:13
@edemaine edemaine mentioned this pull request Dec 26, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants