
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Bucklescript loader for Webpack
This works with both Reason and OCaml files
npm install bs-loader
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"
}
}
To use the loader you must:
.re
and .ml
extensions with Webpack.re
and .ml
to use the loaderAn 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']
}
}
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"
}
}
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
.
FAQs
Bucklescript integration in Webpack
The npm package bs-loader receives a total of 84 weekly downloads. As such, bs-loader popularity was classified as not popular.
We found that bs-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.