0

I have:

$ ls -last /home/brandon/workspace/ced2ar/jsgen/target/scala-2.12/scalajs-bundler/main/node_modules/bootstrap/dist/js/bootstrap.min.js
40 -rw-r--r-- 1 brandon brandon 37045 Jul 25  2016 /home/brandon/workspace/ced2ar/jsgen/target/scala-2.12/scalajs-bundler/main/node_modules/bootstrap/dist/js/bootstrap.min.js

and

@JSImport("node_modules/bootstrap/dist/js/bootstrap.min.js", "jQuery")

Yet when I run bundler I get the following error:

[error] ModuleNotFoundError: Module not found: Error: Can't resolve 'node_modules/bootstrap/dist/js/bootstrap.min.js' in '/home/brandon/workspace/ced2ar/jsgen/target/scala-2.12/scalajs-bundler/main'
[error]     at factoryCallback (/home/brandon/workspace/ced2ar/jsgen/target/scala-2.12/scalajs-bundler/main/node_modules/webpack/lib/Compilation.js:269:40)

I also tried just using the filename bootstrap.min.js for @JSImport. (Note: I figure that once I resolve this, I still have the issue of dealing with monkey patching, since that seems to be what bootstrap is doing to JQuery.)

sjrd
  • 21,805
  • 2
  • 61
  • 91
bbarker
  • 11,636
  • 9
  • 38
  • 62
  • You should be able to just write `"bootstrap.min.js"` in `@JSImport`. It should be the job of the bundler to resolve that name inside the Node.js modules. – sjrd Dec 21 '17 at 14:00
  • I'm using sjs bundler 0.9.0; my build.sbt is here (if relevant I'll add the important bits to the question): https://gist.github.com/bbarker/7ba6f1f1e92066343be6d2135a182319 - I've tried a variety of options with `@JSImport` as well as trying to load `jquery.slim.min.js` instead, always with the same result. If that still doesn't elucidate the issue I'll try to put together a minimal example. – bbarker Dec 21 '17 at 14:31
  • This worked: `@JSImport("bootstrap/dist/js/bootstrap.min.js")` - thanks @dispalt – bbarker Dec 21 '17 at 19:34

1 Answers1

3

Remove the node_modules part in your path:

@JSImport("bootstrap/dist/js/bootstrap.min.js", "jQuery")

Be sure also that this file is CommonJS compatible.

Julien Richard-Foy
  • 9,634
  • 2
  • 36
  • 42