If multiple entry points or globing ist used with watch or serve when HMR is enabled the compiled js is broken.
parcel watch src/app.ts src/app.scss
parcel watch src/*
The resulting js should not be broken.
The js file generated has multiple errors an is not working. Also the code from my app.ts is missing.
If I use an index.html as entry point all works fine but I have an additional html file that is not needed.

I also tried to use a glob like this src/* but with the same result.
I have no idea.
I only want to use parcel only for js and css without any html. I use it to generate files for an asp.net core site
tbd
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.4 |
| Node | 12.16.1 |
| npm/Yarn | 6.13.4 |
| Operating System | Windows 10 |
It sounds like two processes are writing to the same file concurrently and corrupting it..
I have no idea where to look for a solution but if I can help in any way please give me a hint.
I have the same issue, parcel v1.12.4.
Only if I have multiple entrys
Ok, as a workaround you can turn off HMR: watch somefiles/* --no-hmr
I can confirm the same bug, happening systematically for me, and --no-hmr indeed fixes the issue.
Probably easy to reproduce, but just in case:
1) checkout repo https://github.com/marcandre/np
2) git reset --hard parcelbug
4) cd lib/np/app && yarn && parcel watch assets/index.* --global App --no-cache
Open the newly created dist/index.js file. Locate line with Kludge; that line ends abruptly and is merged with extra code.
Adding --no-hmr option, or changing index.* to index.js does not create the issue.
As a complete newb' to parcel, this was quite frustrating and difficult to understand.
$ parcel info
Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (12) x64 Intel(R) Xeon(R) CPU W3670 @ 3.20GHz
Binaries:
Node: 14.10.1 - /usr/local/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 6.14.8 - /usr/local/bin/npm
Browsers:
Chrome: 85.0.4183.102
Firefox: 80.0.1
Safari: 13.1.2
Most helpful comment
Ok, as a workaround you can turn off HMR:
watch somefiles/* --no-hmr