Licence
—
Version
1.0.0
Deps
1
Size
1 kB
Vulns
0
Weekly
0
with-loader
Why
- reduce bundle size by eliminating property access
- less code === more beautiful code
- your co-workers won't know what hit them
- totally not a bad idea
Installation
npm i -D with-loader
Example Usage
Within your webpack configuration object, you'll need to add the with-loader to the list of modules, like so:
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'with-loader',
options: {
contexts: ['Math', JSON.stringify({ radius:10 })]
}
}
}
]
}
Now the code that we're bundling can access variables from Math and our custom object!
const area = PI * pow(radius, 2);
