0

Trying to avoid child_process to spawn a new process to execute javascript file in gulp as below.

var count = 0;
function run() {
  SystemJS.defaultJSExtensions = true;
  //./src/main or any of its dependencies may change in subsequent calls e.g. gulp.watch
  SystemJS.import('./src/main').then(function (main) {
     count++;
     console.log(count+'Running ----------------- main -------------');
     main.main("main from gulp");
     console.log(count+'Done    ----------------- main -------------');
  }).catch(function(e){
     console.error(e);
  });
}

In subsequent run() my `src\main' or its subsequent child imports may have changed and so I would like it to reload.

Tried System.delete as per artem but no luck

file:///C:/Users/SSSSSSSS/projs/DDDDDDDD/e2e/src/main.js

Any ideas ?

bhantol
  • 9,368
  • 7
  • 44
  • 81
  • Cannot find any specifics about SystemJS, but if using good old `require` - there's a duplicate http://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate As I imagine SystemJS is using it internally, this should also work. – Marius Balčytis Oct 11 '16 at 17:07
  • For SystemJS you could try [System.delete('url')](https://github.com/systemjs/systemjs/blob/master/docs/system-api.md#systemdeletemodulename), but you have to figure out normalized url for `./src/main` first: `SystemJS.normalize('./src/main').then(url) { ... }` – artem Oct 11 '16 at 19:40
  • Tried `System.delete(System.normalizeSync('./src/main'));` but no luck. – bhantol Oct 11 '16 at 19:50

0 Answers0