[2.3.2-scala] Can't get text plugin and sbt-rjs to work together

256 views
Skip to first unread message

descsuit

unread,
Jul 31, 2014, 6:22:24 PM7/31/14
to play-fr...@googlegroups.com
Specifically the error I get is:
[info] TypeError: Cannot read property 'normalize' of undefined
[info] In module tree:
[info]     main
[info]       teacher/teacher_app
[info]         common/diagnoser_utils

Now, I've tried a lot of things to no avail. But the culprit looks to me to be something about how the app.build.js is built with webjars.  In particular all the webjars have a path set to empty: in it.  Not sure why, but that I suspect is the problem, since I've seen people having problems with the path for text including an empty component.  Here's the relevant part of the app.build.js:

...
          ), "preserveLicenseComments": false, "paths": {"text": "empty:", "json3": "empty:", "jQuery": "empty:", "backbone": "empty:", "underscore": "empty:"}, "dir": "/Users/mortea/checkouts/play/diagnoserForTeachers/target/web/rjs/build", "modules": [{"name": "main"}], "mainConfigFile": "/Users/mortea/checkouts/play/diagnoserForTeachers/target/web/rjs/appdir/javascripts/main.js", "baseUrl": "javascripts"}

Maybe you can't use the text plugin from a webjar in the current setup?

Alan

Alejandro Pedraza

unread,
Aug 5, 2014, 12:52:14 PM8/5/14
to play-fr...@googlegroups.com
I had the same problem, and these were my findings, all personal theories about how this works, which could be wrong:

The "empty:"'s are to for the r.js optimizer to bypass those modules and load the corresponding webjars from the CDN at runtime. It works well with regular modules but I've found it breaks with requireJS plugins. I've tested that outside of Play with a minimal web app (just requiring the text plugin with an "empty:" path) and it also breaks, so it seems it's not Play's fault.

In my experiments, I could avoid using a CDN by overriding RjsKeys.buildProfile, but then I stumbled across another problem. If the template file used through the text plugin (say 'text!foobar.html) is not a valid css or js file, then r.js won't find it under target/web/rjs/appdir and so we've got another problem. One kludge to solve that would be to run a custom pipeline task before rjs to place those files somewhere in the target dir...

--Alejandro


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Mortensen

unread,
Aug 5, 2014, 3:30:41 PM8/5/14
to play-fr...@googlegroups.com
I actually figured this out.  First you can't do the webjar thing as far as I can tell, because as you said, the mapping of empty and also when/how the webjar loads.  The other thing was I added a few extensions to the rjs includeFilter so that HTML gets brought over in assets.  There is an example in this groups message history somewhere.  Unfortunately, I could not find a way to add to the include but instead had to list all the extensions(like in the example)

So by adding *.html and using a local copy of the text plugin, I seem to have gotten everything to work.

Alan
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/F789ZzTOthc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.

Alejandro Pedraza

unread,
Aug 5, 2014, 5:21:57 PM8/5/14
to play-fr...@googlegroups.com
Ah of course, the include filter! thanks for the tip :)

ybh6336

unread,
Feb 1, 2016, 9:19:17 PM2/1/16
to play-framework
I am running into the same issue with Play 2.3.10 and SBT 0.13.5. I know this is an old post, but it would be really helpful if you can provide a little more details on how you got around this issue. I already have an includeFilter to include HTML. How did you avoid having text.js included during optimization? I have tried using an excludeFilter for text / text.js and tried other solutions suggested elsewhere, but none of those seem to work.

I did not quite get the part about 'using a local copy of the text plugin'.

Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/F789ZzTOthc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages