Skip to content

mlrawlings/with-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

totally not a bad idea

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published