aurelia / hot-module-reload

Core functionality for Aurelia's hot-module-reolad (HMR) capabilities, which is shared by all loaders and tools.
MIT License
25 stars 8 forks source link

Global resources don't hot-reload #8

Open jods4 opened 7 years ago

jods4 commented 7 years ago

I was playing with a basic value converter:

export class UpperValueConverter {
  toView(name: string) {
    return name && name.toUpperCase();
  }
}

When imported locally in a view with <require from="converters/upper"></require>, the code does hot reload. The bindings don't refresh immediately but on the next value change I can see that the new converter code is running.

If I declare that converter as a global resource in my main file, like so:

import 'aurelia-bootstrapper';
import { Aurelia } from 'aurelia-framework';

export function configure(aurelia: Aurelia) {
  aurelia.use
         .standardConfiguration()
         .developmentLogging()
         .globalResources('converters/upper');
  aurelia.start().then(() => aurelia.setRoot());
}

Then it doesn't work and triggers a full-reload.

I noticed that in the second case, loading the converter does not go through any of the module.hot.accept paths in aurelia-loader-webpack, which explains why HMR doesn't work.

niieani commented 7 years ago

Hm, seems like a similar problem to #9. Not sure how to tackle this best.