jspm / npm

NPM Location Service
19 stars 34 forks source link

Support `module` as a built in #39

Closed guybedford closed 9 years ago

guybedford commented 9 years ago

Only in Node.

victorwpbastos commented 9 years ago

How can you plan to do that? Maybe I could help but I need some guidance.

guybedford commented 9 years ago

Thanks, it's mostly just the same pattern as the others https://github.com/jspm/npm/blob/master/npm.js#L28.

It isn't much more than a wrapper though, so I will aim to get to it soon.

victorwpbastos commented 9 years ago

I can't create the repo. :cry:

guybedford commented 9 years ago

Ok, I've added this above.

victorwpbastos commented 9 years ago

How can I test this? When I try to reinstall npm:ractive-load nodelibs-module is not being intalled together.

guybedford commented 9 years ago

You need to update the jspm-npm dependency of jspm to this master version, then use install -f

victorwpbastos commented 9 years ago

I did that. Doesn't work.

guybedford commented 9 years ago

Ahh, this is because ractive contains this code:

Module = (require.nodeRequire || require)('module');

The above isn't a require that can be picked up by static analysis.

Instead I would suggest loading ractive-load as a global or AMD library using an override, something like:

jspm install npm:ractive-load@0.4.0 -o "{ format: 'global' }"

See https://github.com/jspm/registry/wiki/Configuring-Packages-for-jspm#package-module-format for more info.

guybedford commented 9 years ago

Created an issue to track this above, will help as soon as I can, overrides are a pain to test out as there are quite a few factors, but perseverance pays off!

victorwpbastos commented 9 years ago

Thanks for the support!

victorwpbastos commented 9 years ago

I installed ractive-load as a global. Now when jspm bundle-sfx runs I get this:

captura de tela de 2015-01-19 23 19 13

My ract plugin:

require('ractive');
require('ractive-load');

exports.translate = function(load) {
    load.source = 'module.exports = ' + JSON.stringify(load.source);
    return Ractive.load(load.address).then(function(c) {
        Ractive.components['ract-test'] = c;
    });
}