sbt / sbt-rjs

RequireJs optimizer plugin for sbt-web
Other
39 stars 28 forks source link

Files not being concatenated before optimization #23

Closed benmccann closed 10 years ago

benmccann commented 10 years ago

What I expect

I believe the way this is supposed to work is that with "play run" all the js is loaded in as it appears in my editor and with "play start" all the files are supposed to be concatenated together and then optimized.

What actually happens

When I do "play run" and when I do "play start" my main.js looks exactly the same in both instancess with each file being optimized independently. I would think no optimization should happen in dev mode and that in prod mode that there would be some concatenation happening first.

My setup

I see that SbtRjs is enabled in my project and I've also set "pipelineStages := Seq(rjs)". I'm not sure what else to look into. I see another open bug for adding logging. It seems like that would be helpful here as well so that I could enable debug logging since the plugin seems to not be working for me

$ sbt about
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, play.Play, play.PlayJava, play.PlayScala, play.twirl.sbt.SbtTwirl, com.typesafe.sbt.jse.SbtJsEngine, com.typesafe.sbt.jse.SbtJsTask, com.typesafe.sbt.web.SbtWeb, com.typesafe.sbt.webdriver.SbtWebDriver, com.typesafe.sbt.rjs.SbtRjs, com.typesafe.sbt.less.SbtLess, com.typesafe.sbteclipse.plugin.EclipsePlugin, org.sbtidea.SbtIdeaPlugin, com.typesafe.sbt.SbtNativePackager

Debugging

It seems I need to delete the following directory to cause it to try to optimize again.

target/streams/$global/rjs/$global/streams/rjs

Once I do that I can get it to say "Optimizing JavaScript with RequireJS", but my main.js still isn't actually optimized

benmccann commented 10 years ago

Okay figured this one out. I broke the r.js static analysis with my script

Doesn't work:

var deps = ['a', 'b', 'c'];
require(deps);

Does work:

require(['a', 'b', 'c']);
huntc commented 10 years ago

There's a bug in sbt-rjs. That logging should use log.info(...) not log(...)