1.0.0 • Published 5 years ago

with-loader v1.0.0

Weekly downloads
7
License
-
Repository
github
Last release
5 years ago

with-loader

image image image image

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);

image