jspm / npm

NPM Location Service
19 stars 34 forks source link

Better process and Buffer detection #55

Open guybedford opened 9 years ago

guybedford commented 9 years ago

See https://github.com/jspm/jspm-cli/issues/655, we need to be better detecting the process and Buffer identifiers for wrapping.

lookfirst commented 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.

guybedford commented 9 years ago

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.

intellix commented 8 years ago

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.

guybedford commented 8 years ago

@intellix if you use jspm 0.17 you can avoid the wrapping as it does it through editable config then instead.