caspervonb / amokify

Other
25 stars 2 forks source link

More performant wrap phase #7

Open caspervonb opened 9 years ago

caspervonb commented 9 years ago

The way the current prelude works takes a lot of time because it works in several (redundant) steps

It also completely destroys any source maps.

If we redesign the prelude ever so slightly.

(function bundle(acquire, cache, entries, modules) {
  function require(name) {
    var updates = acquire();
    Object.keys(updates).forEach(function(key) {
      if (modules[key]) {
        modules[key][1] = updates[key][1];
      } else {
        modules[key] = updates[key];
      }
    });
  }
}(function() { 
  return {
    '0': [function() {
    }, {}]
  };
}, {}, [], {}));

Provided that this works as expected, it should tho as function references are being kept. We should be able to do it in a wrap phase with just some basic string searching in the first and last chunk of the bundle stream. Drastically reducing the overhead of Amokify.