Fix unplugin emitDeclaration and Windows behavior #895
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement @imm's suggestions for fixing
emitDeclaration
:mkdir
precedingthis.emitFile
;this.emitFile
should do this already (indeed, unplugin does it explicitly for esbuild)emit
call fromasync
to synchronous.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 likemain.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 fromfsMap
in the emit phase.I've tested esbuild and rollup and this seems to work much better.