Open guybedford opened 9 years ago
Right. In one of the comments you mentioned using https://github.com/substack/insert-module-globals which seems like it is a good idea since it uses a parser instead of a regex.
The hard part about this one is we should really be sharing the parse tree with the remap
function calls which does a synchronous parse as well.
One simple way might be to have a cache in the builder implementation, but better would be to load Traceur as a direct dependency and simply share the remapping CommonJS transformer with the builder project, and remove the exports.remap
function entirely in SystemJS builder.
This also seems to happen for isomorphic scripts that work in both Node and Browser like ZoneJS. Example: https://github.com/angular/zone.js/blob/master/dist/zone.js#L745
exports.isNode = (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]');
Was hoping to use JSPM in angular-cli, which uses Zone amongst a few other items, but they're all getting wrapped in require('process')
so it seems impossible at the moment.
@intellix if you use jspm 0.17 you can avoid the wrapping as it does it through editable config then instead.
See https://github.com/jspm/jspm-cli/issues/655, we need to be better detecting the
process
andBuffer
identifiers for wrapping.