alexisvincent / systemjs-hot-reloader

reloads your modules as needed so that you can have satisfyingly fast feedback loop when developing your app
MIT License
228 stars 36 forks source link

Recovery from SystemJS error #139

Closed ArmorDarks closed 6 years ago

ArmorDarks commented 7 years ago

Is it possible to somehow automatically recover from SystemJS error?

For example, if there were a typo in imported file, we've got following error:

Error: (SystemJS) http://localhost:3000/source/scripts/main.js: Unexpected token (18:6)
      16 |     return React.createElement('div', null, [
      17 |       React.createElement('div', null, 'test')
    > 18 |       React.createElement(Second, null, null)
         |       ^
      19 |     ])
      20 |   }
      21 | }

Hot reloading not working after this error until whole page will be reloaded, which takes quite a lot of time for large apps.

alexisvincent commented 7 years ago

Recovery is actually built into systemjs-hot-reloader. Which version are you running?

alexisvincent commented 7 years ago

Potentially the only thing we don't account for is if importing fails on the very first load of the app. But after that it should recover.

ArmorDarks commented 7 years ago

Hm, in my case nothing happens after hitting syntax error. Chokidar emits change event on change, but hot-reloader does not react on changes until full page refresh.

alexisvincent commented 7 years ago

Which version are you running. Also what is the output after enabling systemjs-hmr debug. (localStorage.debug = "systemjs-hmr:*" in console). Including a refresh

ArmorDarks commented 7 years ago

I'm using system-hot-reloader 1.1.0

Also what is the output after enabling systemjs-hmr debug. (localStorage.debug = "systemjs-hmr:*" in console)

That's displayed right after the load:

1smr5u

This is on reload:

3

This is after cleaning console and introducing syntax error (I removed , in array):

2

And when I remove error and resave file, shows:

1

Same message will be on all other attempts to resave without reloading whole page:

last

alexisvincent commented 7 years ago

Hmm, which version of SystemJS are you running? There was a bug with the old version of SystemJS.

Also, notice the warning at the top. You need to load systemjs-hot-reloader after SystemJS itself has run.

ArmorDarks commented 7 years ago

Wow, I didn't notice that JSPM beta.41 already came out yesterday... my SystemJS indeed was old, now I've updated to v0.20.10 Dev.

This fixed a lot of issues, but particular case with syntax error still there. But now it behaves differently:

On error introduction:

1111

And when error has been fixed, it keep showing like it still exist:

222

Any attempts to resave file with fixed error will just show again messages from last screenshot.

Also, notice the warning at the top. You need to load systemjs-hot-reloader after SystemJS itself has run.

Well, I'm quite sure that I do load it after SystemJS, but it still shows up.

My configuration:

sublime_text_2017-03-17_14-46-52

Don't mind @ in the beginning. Those are just mapping for Browser Sync routes, so that it could serve files properly (our files served not from same directory as jspm):

sublime_text_2017-03-17_14-48-20

peteruithoven commented 7 years ago

I'm also experiencing this issue. I've tried to make a simple example: https://github.com/peteruithoven/hot-reloader-error-recovery

alexisvincent commented 7 years ago

Thanks, will sort this out this weekend. Have a deadline for Friday evening 🍕

ArmorDarks commented 7 years ago

I actually found out that workflow with this hot reloader much more enjoyable than with jspm build --watch even with this issue in-place, so I'm sold out anyway

alexisvincent commented 7 years ago

Apologies that I haven't been present. Have major deadlines for Friday. Will be pushing forwards next week.

ArmorDarks commented 7 years ago

No need for that, it isn't your work after all!

kanoshin commented 7 years ago

@alexisvincent sorry for bothering. This bug seriously interrupts development :(. Have you been able to fix it? Do you need help to fix it?

isitrita commented 7 years ago

Hi, @alexisvincent , I would also love to see this thing to be fixed! Fix for this issue will make development much less painful

alexisvincent commented 7 years ago

Sorry guys, been in a heavy deadline crunch for the past couple of months. Going to try get a look at this in the coming week or so.

kanoshin commented 7 years ago

@alexisvincent after recent system.js update hot reload is able to recover from transpilation errors. I think you can close this bug.

ArmorDarks commented 6 years ago

Yeap, seems so.