Widdershin / tricycle

Try Cycle.js in your browser, no setup required.
http://widdersh.in/tricycle/
MIT License
26 stars 4 forks source link

Import npm modules #17

Open schempy opened 8 years ago

schempy commented 8 years ago

Implement importing npm modules as referenced in #8

This is pretty rough but I'm able to import npm modules using https://wzrd.in/. Currently fetching @cycle/core is not working, https://wzrd.in/standalone/@cycle%2Fcore@latest, which is huge but maybe it can be fixed. I could add a condition to only use @cycle/core from the node_modules directory and get all other modules from https://wzrd.in. So far there are no problems importing the other modules.

Widdershin commented 8 years ago

Nice work!

I had a play round with the wzrd.in API, and it looks like it works fine if you POST to /multi:

Try this:

$ curl --data '{
  "options": {
    "debug": true
  },
  "dependencies": {
    "@cycle%2Fcore": "latest"
  }
}' https://wzrd.in/multi

This way we can fetch all the modules in one bundle as well. What do you think?

schempy commented 8 years ago

That's awesome! I'll make the changes.

schempy commented 8 years ago

Looks like there is a problem fetching @cycle/core and other modules. No problems fetching @cycle/core by itself.

$ curl --data '{
    "options": {
        "debug": true
    },
    "dependencies": {
        "@cycle%2Fcore": "latest",
        "lodash": "latest"
    }
}' https://wzrd.in/multi

At least I'm able to get @cycle/core doing a POST to /multi

Widdershin commented 8 years ago

@schempy sorry for the lack of response, this fell off my radar.

When you last updated this, I also received an error attempting to run the above command (install core & lodash).

Now, it seems like it works! Can you check to see if it works for you?

If so, maybe we can move forward?

schempy commented 8 years ago

@Widdershin That's great! It's working for me. I'll make the changes and update the PR.

schempy commented 8 years ago

@Widdershin I included updates that get all npm modules in one request. I'm getting an error that I can't figure out, 'Cannot render into unknown element .app.' Looks like all the modules are getting loaded.

If I override the require function like I do in the following:

const context = {
    error$: error$,
    console: console,
    require: (path) => {
        return moduleCache[path];
    }
};

I get the error. If I don't override the require function like this:

const context = {
    error$: error$,
    console: console,
    require: require
};

Things work. Here's a link to the file.

Any ideas?

Thanks!

Widdershin commented 8 years ago

Hi @schempy, sorry for my lack of followup. I'll have a look at this tomorrow.

Widdershin commented 7 years ago

I resolved the merge conflicts so I could consider this properly.

I'm getting an error because it looks like wzrd.in has invalid security certificates.

This does raise the question, do we want to rely on the uptime of a third party component?

I think perhaps we should run our own module cache.