Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

feathers client and requireJS #85

Closed
MarcGodard opened this issue Sep 6, 2016 · 9 comments
Closed

feathers client and requireJS #85

MarcGodard opened this issue Sep 6, 2016 · 9 comments

Comments

@MarcGodard
Copy link

Hi I am loading feathersJS client into an app that uses requireJS and I am getting errors.

Error:

require.js:143 Uncaught Error: Module name "events" has not been loaded yet for context: _. Use require([])

How I am loading it:

paths: {
         feathers_client: "../libs/feathers-client/dist/feathers",
         ...
}

Then I just do like any other require module.

Am I missing something?

@daffl
Copy link
Member

daffl commented Sep 7, 2016

I thought the Browserify --standalone option creates a RequireJS compatible build but you may have to shim it as a global:

shim: {
  feathers_client: {
    exports: "feathers"
  }
}

@MarcGodard
Copy link
Author

I will try this tomorrow. Thanks.

@MarcGodard
Copy link
Author

Same error. As soon as I require feathers in a module (even with the shim).

Has feathers been used with steals? I might try that if you know it will work.

@fedevela
Copy link

fedevela commented Sep 8, 2016

@MarcGodard Can't webpack do what you need to get done? I have gotten that to work with feathers seamlessly.

@daffl
Copy link
Member

daffl commented Sep 8, 2016

So does Browserify and StealJS. Nevertheless it should still work with RequireJS.

@daffl
Copy link
Member

daffl commented Sep 8, 2016

So apparently I made this comment in the wrong issue so here again: It looks like the RequireJS problem can be fixed with https://github.com/rse/browserify-derequire so I'll give that a try later today.

@MarcGodard
Copy link
Author

@fedevela never used webpack but this is an already existing large program.

@daffl Will look into that. I hope its available with bower, because again, old large program that I am slowly updating. However, if you can tell me if you have seen it work nicely with stealsJS I will do that conversion next.

@MarcGodard
Copy link
Author

I looked into the derequire, and this makes the package even more complicated. I will just skip feathers for now and use my regular server API. Thanks for all your help.

@daffl
Copy link
Member

daffl commented Sep 9, 2016

It looks like the trick is to use the require format like this:

define(function (require) {
    var feathers = require('feathers');

I put a working example based on the create-template at https://github.com/daffl/create-template.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants