Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 01 08:33
    vincenzobaz labeled #399
  • Mar 01 08:33
    vincenzobaz labeled #399
  • Mar 01 08:33
    vincenzobaz opened #399
  • Mar 01 03:34
    ngbinh closed #353
  • Feb 27 02:25

    cquiroz on master

    Update play-json to 2.9.2 Merge pull request #398 from sc… (compare)

  • Feb 27 02:25
    cquiroz closed #398
  • Feb 27 01:54
    cquiroz synchronize #396
  • Feb 27 01:53

    cquiroz on master

    Update sbt-pgp to 2.1.2 Merge pull request #397 from sc… (compare)

  • Feb 27 01:53
    cquiroz closed #397
  • Feb 27 01:02
    scala-steward opened #398
  • Feb 27 01:02
    scala-steward opened #397
  • Feb 27 01:02
    scala-steward opened #396
  • Feb 27 00:25

    cquiroz on master

    Update sbt-pgp to 2.1.1 Merge branch 'master' into upda… Merge pull request #395 from sc… (compare)

  • Feb 27 00:25
    cquiroz closed #395
  • Feb 26 22:07

    cquiroz on master

    Fix webpack-dev-server logs wit… Merge pull request #391 from vh… (compare)

  • Feb 26 22:07
    cquiroz closed #391
  • Feb 26 22:07
    cquiroz closed #389
  • Feb 26 21:28
    cquiroz synchronize #395
  • Feb 26 21:06

    cquiroz on master

    Update play-json to 2.6.14 Merge branch 'master' into upda… Update play-json to 2.6.14 and 1 more (compare)

  • Feb 26 21:06
    cquiroz closed #367
Sina
@sinaghaffari
Hi everyone. I'm having a lot of trouble figuring out how to bundle things like fonts using scalajs-bundler. I'm using scalacss to define font-faces which have "url(...)"s in them. I've tried a bunch of different things, but can't seem to get scalajs-bundler to actually recognize that the fonts are being referenced and including them within the bundle
Carlos Quiroz
@cquiroz
You probably need to specify a font loader on your webpack configuration
If the url is to some external site it should just work
Sina
@sinaghaffari
The url is to a local directory relative to the scala file
so something like ../../../../public/fonts/My-Font.eot
I defined a file-loader in my webpack config
Sina
@sinaghaffari
Im actually not sure if the url should be relative to the .scala source file, or the compiled js file, or the bundled js file
Carlos Quiroz
@cquiroz
that’s tricky, it has to be relative to the bundled file
but I’ve used aliases pointing to a resources dir
Sina
@sinaghaffari
I gave up and used an external url :(
I figure that the same server that's serving the JS will serve the font, so there wont be any problems there
Carlos Quiroz
@cquiroz
e..g.
const resourcesDir = path.resolve(rootDir, "../common/src/main/resources”);
and then I need to add tha to the search dir
  resolve: {
     alias: {
       resources: resourceDir
That lets you refer on you import something like resources/fonts/etc
Domantas Petrauskas
@dope9967
Hi, maybe there's some example project on how to make sbt-web-scalajs-bundler work with akka http? I tried adapting Play example, but somethings missing - assets do not seem to link up in classpath, I'm guessing Play provides some helpful settings under the hood and Akka doesn't.
Domantas Petrauskas
@dope9967
Or maybe I have more of a sbt-web issue, because Scala.js bundle does appear in server module's /target
Domantas Petrauskas
@dope9967
Just for reference, my issue is with simply with IntelliJ - sbt run or sbt ~reStart work just fine
Julien Richard-Foy
@julienrf
@dope9967 Maybe this is an issue with IntelliJ then?
Domantas Petrauskas
@dope9967
@julienrf yes, maybe I didn't phrase this most correctly, but my last message was to just note that the issue is "solved" - it's IntelliJ's classpath issue, not related to this plugin. Though it works both from sbt shell and sbt Run/Debug configurations, issue arises when server is ran as simple application from the main class through Run/Debug configurations, so it's not completely unusable, just got to fallback to sbt everywhere.
Adrien Piquerez
@adpi2
Hi! I have a .jpeg file in src/main/resources and I would like it to be bundled when I run fastOptJS / webpack. I guess that file should be automatically copied to target/scala-2.13/scalajs-bundler/mainbut how can I do that properly?
Julien Richard-Foy
@julienrf
Hello, it should not be in src/main/resources but in src/main/js
Then you also need to configure webpack to use an image loader
Adrien Piquerez
@adpi2
Cool thanks! That worked!
Jasper Denkers
@jasperdenkers
Hi, I'm working on a setup similar to the js-source-directory test, i.e., including some Javascript sources at src/main/js. While this works fine on the first compilation, changes to the Javascript sources are not picked up by fastOptJS::webpack. I tried adding webpackMonitoredDirectories += sourceDirectory.value / "js", but that didn't help. Would it be possible to have fastOptJS::webpack automatically detect changes to Javascript sources and retrigger webpack bundling if changes are detected?
Jasper Denkers
@jasperdenkers
Based on the SBT docs on tracking file inputs and outputs I tried fastOptJS / fileInputs += sourceDirectory.value.toGlob / "js" / "*.js", but that also didn't help. Maybe I'm misunderstanding SBT internals here?
lazno
@lazno

Hello. I just made the switch from 0.6.x to 1.3.1. I am struggling with getting our build to work again. I hope I can get help here.

We are using ScalaJS with the sbt-web-scalajs-bundler for a small SPA. In 0.6 we imported some static files located in our resource folder like this

@js.annotation.JSImport("resources/Main.scss", js.annotation.JSImport.Default)

which worked fine. After upgrading, webpack complains, that there is no loader defined for our sass files, although we have it in place (as we did before):

[error] Module parse failed: Unexpected character '@' (1:0)
[error] You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.[...]
resolve: {
    alias: {
      'resources': path.resolve(__dirname, '../../../../src/main/js'),
    },
    modules: [path.resolve(__dirname, 'node_modules')]
},
module: {
    rules: [
     {
        test: new RegExp("\\.scss$"),
        use: [
          // Creates `style` nodes from JS strings
          'style-loader',
          // Translates CSS into CommonJS
          'css-loader',
          // Compiles Sass to CSS
          'sass-loader',
        ],
    }
  ]
 },

Also the source-map-loader emits warnings about not finding the scala sources.

[warn] Module Warning (from ./node_modules/source-map-loader/index.js):
[...]
[warn] NonErrorEmittedError: (Emitted value instead of an instance of Error) Cannot find source file[...]

I guess i am missing something basic here?

Sébastien Doeraene
@sjrd
Did you upgrade to 0.6.33 first, and addressed all the deprecation warnings, and made your build work that way?
Then, did you upgrade scalajs-bundler to 0.19, and made your build work that way?
If yes, then from there we can talk about upgrading to Scala.js 1.3.1 and scalajs-bundler 0.20 (at the same time).
lazno
@lazno
Hi Sebastien.
we were on 0.6.33 with sbt-web-scalajs-bundler-sjs06 0.18.0 and no deprecation warnings
I now verified that 0.19.0 also didn't cause any deprecation warnings
Sadly I am forced to do the jump straight to 1.3.1 since one of our dependencies was only published for that version. And from what I understand the bundler only supports scalajs 1.3.1 from version 0.20 onward
lazno
@lazno

i think the problem lies somewhere in the way our folder structure is configured. our client application is located in a "client" subproject
projectroot/client

and the folder layout in there is as follows
projectroot/client/src/main/js
projectroot/client/src/main/scala
projectroot/client/webpack
projectroot/client/public

and this is the config in build.sbt to reflect that layout

   webpackResources := baseDirectory.value / "webpack" * "*",
    webpackConfigFile in fastLinkJS := Some(baseDirectory.value / "webpack" / "webpack-fastopt.config.js"),
    webpackConfigFile in fullLinkJS := Some(baseDirectory.value / "webpack" / "webpack-opt.config.js"),
    webpackConfigFile in Test := Some(baseDirectory.value / "webpack" / "webpack-core.config.js"),
    webpackDevServerExtraArgs in fastLinkJS := Seq("--inline"),
    webpackBundlingMode in fastLinkJS := BundlingMode.LibraryOnly(),

i succeeded in making the whole thing compile when i change the above to use fullOptJS and fastOptJS instead of the linker version. which i don't quite understand to be honest, since to documentation states to use the fast/fullLinkJS in the newest versions.

i still get the sourcemap warnings though

vonchav
@voonchav_gitlab
Hi all, I was wondering why jsdom 9.9.0 is used as the default version. There is probably a reason that I'm not aware of. Just curious, as that version is 4 years old :)
Kahli Burke
@kahliburke
Forgive me if this is documented somewhere, I've tried to search around. I'm upgrading a project from Scala 0.6.x to 1.3.1 and attempting to update all the various SBT plugins at the same time. So I've started using the scalajs-bundler but now the sourcemaps for the JS files are handled by webpack instead of getting packaged up with the Play assets. Is there a canonical way to make sourcemaps work with Play and scalajs-bundler?
I do get a sourcemap generated, but it points at a relative path like ../../../../src/main/scala/org/...
So the browser tries to resolve it at http://localhost:9000/src/main/scala/org/...
Kahli Burke
@kahliburke
Hmm I see that they are working in the example play project inside the scalajs-bundler repo, so I guess I probably need to debug on my side
Kahli Burke
@kahliburke
Aha ... that project is using the webpackBundlingMode := BundlingMode.Application default, if I change to the webpackBundlingMode := BundlingMode.LibraryOnly() mode, sourcemaps stop working there in the same way. Any advice on the right way to make these work?
Eric K Richardson
@ekrich
@kahliburke Did you start by upgrading to the latest version of 0.6 and remove deprecations etc. People have said that should be the first step.
Kahli Burke
@kahliburke
@ekrich oh yeah things are working in general, just have this issue with the way the source maps are generated and not being processed by Play in the same way they used to be (run through digest pipeline and served under a hashed asset url). The example play project in the scalajs-bundler repo shows the same behavior when using the settings mentioned above. I want to use those aettings to avoid the long processing times running scalajs output through webpack in development.
Eric K Richardson
@ekrich
There have been some discussions on the Scala.js list now that code splitting is supported about using some other tool. I am not directly involved so I can't remember the name. I try and see if I can find it.
It was snowpack but you can just scrollback a little bit to see the larger discussion - https://gitter.im/scala-js/scala-js
@kahliburke :point_up:
Kahli Burke
@kahliburke
@ekrich Thanks for the reference, in this case I'm not really concerned with the way that the code is split. I'm happy with the external JS libraries being bundled to one file and the ScalaJS output to another. It's just the source map doesn't work out of the box, I'd need to add server routes for http://host/src/* for the browser to resolve them. Which I'm somewhat OK doing as it's only for development purposes, I can disable that route for production. But since it worked "out of the box" previously before I switched to scalajs-bundler, I thought I'd see if there's a better solution first.
I will check out snowpack use too, although it would be nice to stick with something more SBT oriented.
Eric K Richardson
@ekrich
Good luck, just wanted to let you know as code splitting is really cool to have as an option.
Mark de Jong
@Fristi

Is there a write up about reducing the bundle size? Quickly scanning through this channel it's kind of a duplicate quesetion being asked... I've seen some docs Bundling mode, but I think there is more to it I think:

  • Specific bundles which can be identified with maybe https://www.npmjs.com/package/webpack-bundle-analyzer ? I tried it, but couldn't make it work yet
  • What scalajs libs contribute to a large size?
  • Does tree shaking work? And what would be needed to enable it?
  • Does code splitting work with this plugin? And what would be needed to enable it?

At the moment with fullOptJS::webpack my bundle size is 7,2 mb (using scalajs-react, circe, endpoints4s, droste (local build)).. I guess there are transitive dependencies and maybe code which is not being used?

Julien Richard-Foy
@julienrf
@Fristi The Scala.js optimizer removes unused Scala code. Webpack won’t include dependencies that are not imported. So, the only thing I can think of is to make sure that your NPM dependencies are also minified (remember that fullOptJS does minify the output of Scala.js, but it doesn’t process your dependencies).
Julien Richard-Foy
@julienrf
@Fristi what is the size of the -opt.js file produced by Scala.js?