sbt-rjs error for text.js: Cannot read property 'normalize' of undefined

107 views
Skip to first unread message

ybh6336

unread,
Jan 29, 2016, 6:43:15 PM1/29/16
to play-framework

Environment: Play 2.3.10; sbt 0.13.5; sbt-rjs 1.0.1

I have tried the suggested solutions to similar questions in this group and StackOverflow, but have not been able to solve this issue so far.

I have upgraded Play from 2.2.3 to 2.3.10 and get the following error on running activator dist:

[info] TypeError: Cannot read property 'normalize' of undefined


Here is the line of code that throws the error:

define([
   
...,
   
'text!ui.template.html',
   
...
]



build.js contains the following:

require.config({
   
...
   
...
    paths
: {
       
...,
        text
: 'empty:',
       
...
   
}
   
...
});


config.js, with the actual paths, looks like this:

require.config({
   
...
   
...
    paths
: {
       
...,
        text
: '../bower_components/requirejs-plugins/lib/text',
       
...
   
}
   
...
});


All the scripts that I want rjs to work on are inside public/scripts. Here are the relevant contents of build.sbt:

JsEngineKeys.engineType := JsEngineKeys.EngineType.Node

pipelineStages
:= Seq(rjs, digest, gzip)

includeFilter
in rjs := new FileFilter {
  val scriptsDir
= (baseDirectory.value / "public" / "scripts").getAbsolutePath
 
def accept(file: File) = file.getAbsolutePath.startsWith(scriptsDir)
}

//excludeFilter in rjs := GlobFilter("text")

excludeFilter
in rjs := new FileFilter {
 
def accept(file: File) = file.getName.equals("text.js")
}

RjsKeys.mainModule := "app"

RjsKeys.mainConfigFile := new File("scripts/build.js")

RjsKeys.baseUrl := "scripts"




And here are the contents of plugins.sbt:

// The Typesafe repository
resolvers
+= "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin
("com.typesafe.play" % "sbt-plugin" % "2.3.10")

addSbtPlugin
("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")

addSbtPlugin
("com.typesafe.sbt" % "sbt-digest" % "1.0.0")

addSbtPlugin
("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")




I added the excludeFilter in build.sbt based on suggestions at https://github.com/jrburke/r.js/issues/221, and have also tried excludeFilter in rjs := GlobFilter("text")
.

I have also tried adding stubModules : ['text'] to build.js, based on suggestions at http://stackoverflow.com/questions/10196977/how-can-i-prevent-the-require-js-optimizer-from-including-the-text-plugin-in-opt.

If I remove text: 'empty:' from build.js, I get the following error:

[info] Error: ENOENT, no such file or directory '/path/to/target/web/rjs/build/scripts/text.js'

I would appreciate any pointers to what I am missing here.

Thanks.


ybh6336

unread,
Feb 1, 2016, 8:18:53 AM2/1/16
to play-framework
I switched to sbt.rjs 1.0.7 and modified SbtRjs.scala to print optimizerMappings inside method private def runOptimizer, and it does not contain text.js. I am not really sure why it still gets included during optimization. Anyone has any ideas?
Reply all
Reply to author
Forward
0 new messages