1

While building my Play 2.3 app (sbt 0.13.5) with command "activator stage" I'm getting the error:

Optimizing JavaScript with RequireJS
Error: Error: paths fallback not supported in optimizer. Please provide a build config path override for angular-easyfb

build.sbt:

...
"org.webjars.bower" % "angular-easyfb" % "1.3.1"

main.js:

shim: {
  'angular': {
      deps: ['jquery'],
      exports: 'angular'
  },
  ...
  'angular-easyfb': ['angular']
},
paths: {
    ...
    'angular': ['../lib/angularjs/angular'],
    'angular-easyfb': ['../lib/angular-easyfb/angular-easyfb'],
     ...
}});

In dev mode everything works fine. My other webjar based js-libs function well, even in production mode (e.g., "org.webjars" % "angular-elastic" % "2.4.2").

Google and SO give me lots of results for "Paths fallback not supported in optimizer". It seems that some found a solution but others did not.

How can I (as Java and Javascript guy) systematically analyze what the problem is?

cnmuc
  • 5,769
  • 2
  • 21
  • 26

1 Answers1

2

Take a look on this post: How to use RequireJS optimizer in Play framework?

It turns out that RequireJS optimization support does not apply to all Webjars, but rather limited to Classic Webjars.

There are some explanations. If you look at http://mvnrepository.com/artifact/org.webjars.bower/angular-easyfb/1.3.1 and it's jar file you won't see any webjars-requirejs.js inside. So this is your case where webjar is not compatible with requirejs by default.

And here is another thing:

Remember to have square brackets, otherwise CDN replacement will not happen. For the non-requirejs ready scripts, you should not have square brackets when declaring the paths. Otherwise, rjs will refuse to build with error path fallback not supported.

So try to remove square brackets from paths:

'angular-easyfb': '../lib/angular-easyfb/angular-easyfb',
Community
  • 1
  • 1
MipH
  • 123
  • 10
  • Another way to fix it is to edit build.sbt `RjsKeys.paths += ("angular-easyfb" -> ("../lib/angular-easyfb/angular-easyfb" -> "[some CDN url here]"))` – MipH Jul 14 '15 at 08:23
  • Ok but now what solution is the preferred one? What is the difference or is there some other impact on library or optimization process? – icl7126 Apr 04 '16 at 07:49
  • 1
    @icl7126 It depends on how you are using RJS in your project. For example: `pipelineStages := Seq(rjs, digest, gzip)` - for this case RJS will take all your LOCAL js files (not in square brakets in main.js), compact them to just ONE main.js and send to user gziped and with correct cache/digest headers (cache strategy). BUT all CDN files (which are in square brakets in main.js) will be loaded separatly from public CDN servsers without impact of RJS (less requests to your server). – MipH Apr 04 '16 at 12:07