Search code examples
javascriptrequirejssbtplayframework-2.3webjars

Paths fallback not supported in optimizer ("reloaded")


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?


Solution

  • 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',