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

238 views Asked by At

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

I have tried the suggested solutions to similar questions on play-framework Google group and StackOverflow, but have not been able to solve this issue so far. I have posted the same question on Google Groups.

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 here, and have also tried excludeFilter in rjs := GlobFilter("text.js") and excludeFilter in rjs := GlobFilter("text").

I have also tried adding stubModules : ['text'] to build.js, as suggested here.

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.

0

There are 0 answers