TS files outside project dir not being parsed -- `microbundle` uses outdated version of rpt2
See original GitHub issueWhat happens and why it is wrong
Environment
TS files outside the project directory being parsed as Flow files instead of TS
SyntaxError: /absolute/path/to/file.ts: Support for the experimental syntax 'flow' isn't currently enabled (2:8):
I am experiencing this when using microbundle to bundle my monorepo projects/packages
Original issue: https://github.com/developit/microbundle/issues/808
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
microbundle-crl - npm Package Health Analysis - Snyk
Ensure you're using the healthiest npm packages. Snyk scans all the packages in your projects for vulnerabilities and provides automated fix advice.
Read more >visual studio - Typescript error "Cannot write file ... because it ...
In my instance, I was using the outDir option but not excluding the destination directory from the inputs: // Bad { "compileOnSave": true ......
Read more >microbundle - Bountysource
I'm trying to bundle a React component library. I'm using Typescript and CSS Modules. When I try to build (or watch for that...
Read more >unknown compiler option jsximportsource - TechKnowByte
The current TS version is not aware of the new @jsxImportSource and thus it ... The command dotnet build invokes the F# compiler...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you so much @agilgur5, you inspired me today! Hope to collaborate again in the future.
Got it to work
Can see my fork and read through the detailed commit log to understand it, but I’ll summarize here too.
microbundle
uses an outdated version of rpt2microbundle
is using an older version of rpt2 from ~1.5 years ago, 0.29.0. Notably, 0.30.0 updated the@rollup/pluginutils
dep to v4, which contains a breaking change in https://github.com/rollup/plugins/pull/517. With that change tofilter
, it now resolves files outside of thecwd
.I’ll report downstream to the
microbundle
folks that they should probably update to fix some issues like these.empty chunk
With the
pnpm
override added, rpt2 resolves the file correctly and there is no error anymore… but it produces an empty chunk! But rpt2 does actually transform the code properly; here’s the output of some logs I added on this line 🤔 :That was pretty perplexing for a while, but it turns out that’s actually correct behavior though because Rollup applies treeshaking and the export does nothing. This is because
export * from ...
actually doesn’t include thedefault
export, and hence it is empty and treeshaken. I changed this toexport { default } from ...
and then it outputs a correct non-empty file 😉workaround in older rpt2 exists too, setting
rootDir
The older rpt2 that
microbundle
uses has a workaround for this too, usingrootDir
as was implemented in #249. I confirmed that this works in your repo when you add"rootDir": "../../"
tosome-package
’stsconfig.json
.Notably, in my last comment I couldn’t get this to work for some reason… but that’s actually because I made a coding error while modifying the local rpt2 😅 (I didn’t add braces to a previously one-line conditional when I added logging to it and completely broke the
transform
hook as such). Project references don’t quite work in this version, but I think that’s because https://github.com/rollup/plugins/pull/517 fixes absolute paths as well, so that’s probably due to the older version too.