How to specify the path when using @JSImport in Scala.js?

222 views Asked by At

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.)

1

There are 1 answers

0
Julien Richard-Foy On BEST ANSWER

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.