All Projects → rrdelaney → Bs Loader

rrdelaney / Bs Loader

Licence: mit
📻 Bucklescript loader for Webpack and Jest

Programming Languages

javascript
184084 projects - #8 most used programming language
ocaml
1615 projects
reason
219 projects
bucklescript
41 projects

Projects that are alternatives of or similar to Bs Loader

Sketch Loader
Webpack loader for Sketch (+43) files
Stars: ✭ 69 (-52.74%)
Mutual labels:  webpack, webpack-loader
Css Modules Flow Types
Creates flow type definitions from CSS Modules files using Webpack loader or CLI 👾
Stars: ✭ 92 (-36.99%)
Mutual labels:  webpack, webpack-loader
Vue Md Loader
✨ Markdown files to ALIVE Vue components.
Stars: ✭ 78 (-46.58%)
Mutual labels:  webpack, webpack-loader
Svgr
Transform SVGs into React components 🦁
Stars: ✭ 8,263 (+5559.59%)
Mutual labels:  webpack, webpack-loader
Webpack Tools
☕️Just a simple webpack sample project.
Stars: ✭ 106 (-27.4%)
Mutual labels:  webpack, webpack-loader
Bootstrap Loader
Load Bootstrap styles and scripts in your Webpack bundle
Stars: ✭ 1,038 (+610.96%)
Mutual labels:  webpack, webpack-loader
Ignore Loader
Webpack loader to ignore certain package on build.
Stars: ✭ 85 (-41.78%)
Mutual labels:  webpack, webpack-loader
Nunjucks Isomorphic Loader
Nunjucks loader for webpack, supporting both javascript templating and generating static HTML files through the HtmlWebpackPlugin.
Stars: ✭ 17 (-88.36%)
Mutual labels:  webpack, webpack-loader
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-28.08%)
Mutual labels:  webpack, webpack-loader
Webpack Core Usage
webpack2完整系列课程,欢迎阅读。同时欢迎移步我的react全家桶文章全集: https://github.com/liangklfangl/react-article-bucket
Stars: ✭ 94 (-35.62%)
Mutual labels:  webpack, webpack-loader
Thread Loader
Runs the following loaders in a worker pool
Stars: ✭ 945 (+547.26%)
Mutual labels:  webpack, webpack-loader
Style Loader
Style Loader
Stars: ✭ 1,572 (+976.71%)
Mutual labels:  webpack, webpack-loader
Flow Bin Loader
webpack loader for Flow
Stars: ✭ 11 (-92.47%)
Mutual labels:  webpack, webpack-loader
Ng Router Loader
Webpack loader for NgModule lazy loading using the angular router
Stars: ✭ 47 (-67.81%)
Mutual labels:  webpack, webpack-loader
Stylefmt Loader
Webpack-loader. Fixes stylelint issues automatically while bundling with Webpack.
Stars: ✭ 24 (-83.56%)
Mutual labels:  webpack, webpack-loader
Graphql Import Loader
Webpack loader for `graphql-import`
Stars: ✭ 84 (-42.47%)
Mutual labels:  webpack, webpack-loader
Inline Style Loader
inline style loader for webpack
Stars: ✭ 16 (-89.04%)
Mutual labels:  webpack, webpack-loader
Node Addon Loader
A loader for node native addons
Stars: ✭ 17 (-88.36%)
Mutual labels:  webpack, webpack-loader
Webpack Conditional Loader
C conditionals directive for JavaScript
Stars: ✭ 93 (-36.3%)
Mutual labels:  webpack, webpack-loader
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (-23.29%)
Mutual labels:  webpack, webpack-loader

bs-loader Build Status

Bucklescript loader for Webpack


This library is in maintanence mode. Instead of using bs-loader we recommend using bsb' new in-source builds in conjunction with .bs.js extensions:

// bcsconfig.json
{
  "package-specs": {
    "module": "commonjs",
    "in-source": true
  },
  "suffix": ".bs.js",
}

This works with both Reason and OCaml files

Installation

npm install bs-loader

Example

Setting up Bucklescript

First install bs-platform into the project:

$ npm i -D bs-platform

Create a bsconfig.json for Bucklescript:

/* bsconfig.json */
{
  "name": "hello",
  "sources": [
    "src"
  ],
  "bs-dependencies": [
    "reason-react"
  ],
  "reason": {
    "react-jsx": 2
  }
}

We will also need reason-react, and bs-platform. You can install bs-platform globally and use npm link to the link the binary, or install bs-platform as a devDependency. Your package.json should look something like this:

/* package.json */
{
  "name": "reason-webpack",
  "private": true,
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "build": "webpack"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "bs-loader": "^1.0.0",
    "reason-react": "0.1.3",
    "webpack": "^2.2.1"
  },
  "dependencies": {
    "react": "^15.4.2",
    "react-dom": "^15.4.2"
  }
}

Using the loader

To use the loader you must:

  • Register the .re and .ml extensions with Webpack
  • Configure .re and .ml to use the loader

An example config would look like:

// webpack.config.js
const path = require('path')

module.exports = {
  // Entry file can be a Reason or OCaml file
  entry: './src/entry.re',
  output: {
    filename: 'out.js',
    path: path.resolve(__dirname, 'build')
  },
  module: {
    rules: [
      // Set up Reason and OCaml files to use the loader
      { test: /\.(re|ml)$/, use: 'bs-loader' },
    ]
  },
  resolve: {
    // Add .re and .ml to the list of extensions webpack recognizes
    extensions: ['.re', '.ml', '.js']
  }
}

Usage with Jest

bs-loader includes a transform for usage with Jest. This lets Jest run Reason and OCaml files as tests. An example Jest configuration using bs-loader:

"jest": {
  "moduleFileExtensions": [
    "re",
    "js",
    "ml"
  ],
  "testMatch": [
    "**/src/*_test.re"
  ],
  "transform": {
    ".(re|ml)": "bs-loader"
  }
}

Options

Most of these settings are inferred from your bsconfig.json. These are available for manual override, but might go away in the future.

module

To tell Webpack to load a module type that isn't JS (for example, amd or goog) give the loader a module option. For example, to use AMD modules produced by Bucklescript, use the config

{ test: /\.(re|ml)$/, use: 'bs-loader?module=amd' }

inSource

To use bs-loader with bsb's in-souce builds, add the inSource option to your loader config:

{
  test: /\.(re|ml)$/,
  use: {
    loader: 'bs-loader',
    options: {
      module: 'es6',
      inSource: true
    }
  }
}

cwd

This option specifies what directory to run bsb from. For example, to run bsb from the same directory as your webpack config, use:

{
  test: /\.(re|ml)$/,
  use: {
    loader: 'bs-loader',
    options: {
     cwd: __dirname
    }
  }
}

showWarnings

Controls whether bsb compile warnings are shown. Defaults to true.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].