1

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.

Community
  • 1
  • 1
ybh6336
  • 61
  • 1
  • 3
  • I switched to sbt.rjs 1.0.7 and modified _SbtRjs.scala_ to print `optimizerMappings` inside method `private def runOptimizer`, and text.js is not included there. I am not really sure why it still gets included during optimization. Anyone has any ideas? – ybh6336 Jan 31 '16 at 21:28

0 Answers0