Parcel: HMR with multiple entry points, resulting JS is broken

Created on 8 Apr 2020  路  5Comments  路  Source: parcel-bundler/parcel

馃悰 bug report

If multiple entry points or globing ist used with watch or serve when HMR is enabled the compiled js is broken.

馃帥 What I used:

parcel watch src/app.ts src/app.scss
parcel watch src/*

馃 Expected Behavior

The resulting js should not be broken.

馃槸 Current Behavior

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.

image

I also tried to use a glob like this src/* but with the same result.

馃拋 Possible Solution

I have no idea.

馃敠 Context

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

馃捇 Code Sample

tbd

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.4 |
| Node | 12.16.1 |
| npm/Yarn | 6.13.4 |
| Operating System | Windows 10 |

Bug

Most helpful comment

Ok, as a workaround you can turn off HMR: watch somefiles/* --no-hmr

All 5 comments

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

medhatdawoud picture medhatdawoud  路  3Comments

termhn picture termhn  路  3Comments

algebraic-brain picture algebraic-brain  路  3Comments

davidnagli picture davidnagli  路  3Comments

devongovett picture devongovett  路  3Comments