jmdobry/angular-cache

Issue with require.js since 4.4.1

Closed this issue · 6 comments

xi commented

Loading angular-cache with require.js fails for me since 4.4.1. If I revert 8e85231, it works fine. Tested with require 2.1.22 and 2.2.0.

I just did this to test:

$ git clone git@github.com:jmdobry/angular-cache.git
$ cd angular-cache
$ npm install -g bower requirejs
$ bower install
$ cd build_examples/r.js
$ r.js -o require.config.js
$ open index.html

and everything worked. Can you explain what you did differently so I can reproduce your error? Maybe provide more information like, what exactly your error is?

xi commented

Thanks for the feedback. I will investigate this further. However, that won't be possible for the next two weeks. I will come back to you after that.

xi commented

Sorry for the long wait. I found somewhat minimal test case:

require.config({
  paths: {
    angular: '../../bower_components/angular/angular',
    angularCache: '../../dist/angular-cache',
  },
  shim: {
    'angular': {
      exports: 'angular'
    }
  }
});

Note the camelCase in angularCache (app.js was changed accordingly). If I change to angular-cache, everything works fine. This may not be a major issue, but still a bug.

How is it a bug? The key you use in the paths object should match the name of the package, i.e. angular-cache.

require.config({
  paths: {
    angular: '../../bower_components/angular/angular',
    'angular-cache': '../../dist/angular-cache',
  },
  shim: {
    'angular': {
      exports: 'angular'
    }
  }
});
xi commented

As far as I know the keys in the paths object are completely arbitrary. In our project, we have the convention to use camelCase module names, so we naturally mapped angular-cache to angularCache.

The require.js docs seems to agree with that:

You can explicitly name modules yourself, but it makes the modules less portable

As I said earlier, this is not a huge issue though. I just thought I should report it in case other people have the same issue.

Sounds good.