Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging and module loading questions #117

Closed
wyattanderson opened this issue Mar 17, 2015 · 14 comments
Closed

Packaging and module loading questions #117

wyattanderson opened this issue Mar 17, 2015 · 14 comments

Comments

@wyattanderson
Copy link

Hey, I have a couple quick questions about packaging and module loading of Orbit.js:

  1. What's the preferred way to load Orbit.js? CommonJS support with the version distributed on Bower seems lacking. If I require orbit-common and orbit-common-jsonapi, Orbit and OC are actually leaked to the window object. Is this intentional? Is there a way to build Orbit to avoid this? Are ES6 modules preferred?
  2. Why isn't Orbit published to NPM?

I'm trying to set up a new project with Orbit in a CommonJS/webpack stack and these two things are making it tough.

@dgeb
Copy link
Member

dgeb commented Mar 20, 2015

I've really just been optimizing for my own use cases until others are requested.

I've been targeting AMD usage but am open to exporting CommonJS as well. We should look into customizing the Brocfile to enable CommonJS output from the transpiler.

Also, I'd be willing to publish builds to npm in addition to bower.

@wyattanderson
Copy link
Author

Alright, cool. I ended up getting it working with Webpack, Bower and AMD, but need to wait for JSONAPI RC3 or 1.0 support before I go any further. Glad to know you're open to NPM and CommonJS, though! Thanks!

@dgeb
Copy link
Member

dgeb commented Mar 21, 2015

Sure - glad you worked something out in the meantime.

Also, we're tracking JSON API compliance in #113 - it's very high on the priority list.

@john-griffin
Copy link

@dgeb it would be awesome if the builds were also pushed to npm thanks. I was trying to integrate orbit and react native and this seems to be the only way to do it.

@amutz
Copy link

amutz commented May 30, 2015

@dgeb Another vote here for publishing to NPM. Any guess as to when this might happen?

@dgeb
Copy link
Member

dgeb commented Jun 1, 2015

@john-griffin @amutz Can you tell me more about your use cases? Are you looking for CommonJS builds as well? Are you using webpack?

If you know of any, please point me to any well done examples of libs published to both bower and npm and transpiled for AMD, CommonJS, and globals.

@john-griffin
Copy link

@dgeb I was attempting to integrate a React Native app with a JSON API data source. Orbit could be a good fit for that because it can be used with any framework, is JSON API compatible and allows for defining a custom data source (e.g. I could implement the equivalent of LocalStorageSource for React Native).

React Native apps are complied in Node so use CommonJS. I'm sorry but I'm not familiar with other projects that publish to both bower and npm.

@dgeb
Copy link
Member

dgeb commented Jun 1, 2015

@john-griffin thanks for the details. I'd definitely like to support this use case and will look into transpiling for CommonJS and simultaneous publishing to bower and npm.

@gnarf
Copy link
Contributor

gnarf commented Jun 24, 2015

I'd like npm if only to not need bower for anything :)

@damon-kreft
Copy link

@wyattanderson , hey. Could you let us know how you got Orbit working with Webpack?

Thanks

@wyattanderson
Copy link
Author

could you let us know how you got Orbit working with Webpack?

Sorry, I don't have the code around anymore. We ended up going a different direction. I needed to do a lot of things mentioned on the shimming modules page to make it work.

@Emerson
Copy link

Emerson commented Mar 10, 2016

+1 for Webpack and NPM

@dgeb
Copy link
Member

dgeb commented Aug 27, 2016

Orbit is now published to npm as orbit-core. In addition, sources have been extracted into their own repos as published as orbit-jsonapi and orbit-local-storage. Builds include CommonJS and AMD modules in /dist along with ES modules in /src.

Please let me know if you have any problems with the builds.

@dgeb dgeb closed this as completed Aug 27, 2016
@tatemz
Copy link

tatemz commented Aug 1, 2017

Related to this issue: I am using a React project that imports another one of my modules (an "sdk' that uses OrbitJS).

On a basic test, I am getting compilation errors (using Webpack) such as the following:

Unexpected token: punc (,) [./~/@orbit/core/dist/modules/es2017/main.js:16,0][static/js/main.ee237ffc.js:17062,11]

What is the standard practice for using the es5 version of each Orbit module?

This is the pr that motivated me to post my question here: facebook/create-react-app#2650

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

No branches or pull requests

8 participants