janhommes / o.js

o.js - client side oData lib.
https://janhommes.github.io/o.js/example/
MIT License
238 stars 57 forks source link

The .js suffix in the module name is not... isomorphic #27

Closed IceOnFire closed 8 years ago

IceOnFire commented 8 years ago

Hi Jan,

I'm trying to integrate o.js inside an isomorphic app, which in my case means loading the same library on Node with

var o = require('o.js')

and at the same time on the browser (through RequireJS) with

define(['o.js'], function(o) {})

Unluckily, since o.js has the '.js' extension in its name, RequireJS seems to resolve the dependency as http://localhost:3000/o.js. As you may know, RequireJS can be configured with aliases, so you can e.g. require 'jquery' instead of 'bower_components/jquery/dist/jquery.min', but this mechanism does not work when modules have the suffix '.js' in their name.

So in short the question is: is there a way to rename this package or add an alias on NPM so it can be easily loaded in every environment? I saw that there are already packages named o-js, o, o-, ojs, etc. so it may not be a simple task... What do you think?

Antony

janhommes commented 8 years ago

Hi Antony,

I actually thought about this before I named the app, but there was no better name I can think of and I thought RequireJS alias will work as workaround. But if they do not, this is an bug.

An alias is an good idea to solve it. I quickly google if it is possivble in npm, but I can not find any resources. Do you know how to alias a npm package or can point me to some resources?

Maybe something like ojs-odata would suffer.

Regards Jan

IceOnFire commented 8 years ago

Hi Jan,

AFAIK NPM is not able to handle aliases and is not considering adding this feature in the future (see #2943).

There are some packages that add them in different ways (see aliasify and alias-module), but I feel this should work out of the box.

The odata project seems dead, maybe we could ask the original author or NPM itself to free the package name for o.js. It could become the de facto standard for Odata on JavaScript :)

Antony

janhommes commented 8 years ago

Hi Antony,

great Idea. I just send him an E-Mail

regards Jan

2016-05-19 15:02 GMT+02:00 Matteo Antony Mistretta <notifications@github.com

:

Hi Jan,

AFAIK NPM is not able to handle aliases and is not considering adding this feature in the future (see #2943 https://github.com/npm/npm/issues/2943 ).

There are some packages that add them in different ways (see aliasify https://www.npmjs.com/package/aliasify and alias-module https://www.npmjs.com/package/alias-module), but I feel this should work out of the box.

The odata https://www.npmjs.com/package/odata project seems dead, maybe we could ask the original author or NPM itself to free the package name for o.js. It could become the de facto standard for Odata on JavaScript :)

Antony

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/janhommes/o.js/issues/27#issuecomment-220317313

IceOnFire commented 8 years ago

Hi Jan,

I made all the changes that were to be made. Could you please launch an npm publish on the project, or give me access on NPM? Thanks!

Antony

IceOnFire commented 8 years ago

I just published the o.js library as NPM package odata. Winter is coming...