Giter VIP home page Giter VIP logo

mill-bundler's Introduction

mill-bundler

A Mill plugin for managing NPM dependencies for Scala.js code, and bundling the output.

Usage

Managing NPM dependencies

To manage NPM dependencies, mix ScalaJSNpmModule into your Mill module.

If you have a dependency on a published library that defines scalajs-bundler's npmDependencies, or otherwise contains an NPM_DEPENDENCIES manifest file in its jar, those NPM dependencies will be automatically added. You can also override the jsDeps target.

You can see the result by running mill frontend.allJsDeps.

import $ivy.`io.github.nafg.millbundler::jsdeps::0.1.0`, io.github.nafg.millbundler.jsdeps._


object frontend extends ScalaJSNpmModule {
  override def scalaVersion = "2.13.10"
  override def scalaJSVersion = "1.12.0"
  override def jsDeps =
    super.jsDeps() ++
      JsDeps(
        dependencies = Map(
          "react" -> "17.0.2",
          "react-dom" -> "^17"
        ),
        devDependencies = Map(
          "typescript" -> "*"
        ),
        jsSources = Map(
          "demo.js" -> "console.log('hello world')"
        )
      )
}

The trait provides an npmInstall target, which will run npm install in the directory specified by the jsDepsDir target, which defaults to the one allocated for it by Mill.

Bundling

To bundle your Scala.js code, mix in ScalaJSRollupModule or ScalaJSWebpackModule into your module. They extend ScalaJSNpmModule, so everything from the previous section applies.

import $ivy.`io.github.nafg.millbundler::millbundler::0.1.0`, io.github.nafg.millbundler._


object frontend extends ScalaJSRollupModule {
  // ...
}

You can then run mill frontend.devBundle or mill frontend.prodBundle to bundle your Scala.js code into a single JavaScript file.

Testing

ScalaJSNpmModule, ScalaJSRollupModule, ScalaJSWebpackModule provide a Test trait in their respective companion objects. You can mix it into your test module to make sure your tests run after the NPM dependencies are installed, and after the bundle is built.

mill-bundler's People

Contributors

mergify[bot] avatar nafg avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

scala-steward

mill-bundler's Issues

Release for Mill 0.11

Is there anything that blocks cutting a new release so that Mill 0.11 is supported?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.