Code Monkey home page Code Monkey logo

executabledllplugin's Introduction

ExecutableDllPlugin

Install

Install with yarn:

yarn add executable-dll-plugin --dev

With npm:

npm install executable-dll-plugin --save-dev

Motivation

DllPlugin webpack plugin cannot be configured to meet both requirements: a) bundle shared modules and b) run these modules. That is, it is impossible for a DllPlugin bundle to execute code when it is imported via a script tag into the page.

ExecutableDllPlugin allows you to execute an entrypoint module(s) included to a DllPlugin bundle.

API

Add ExecutableDllPlugin to webpack configuration next to DllPlugin:

+ const ExecutableDllPlugin = require('executable-dll-plugin');
//...
output: {
  //...
  library: 'MyLibrary'
},
plugins: [
  new DllPlugin({
    name: 'MyLibrary',
    path: path.join(__dirname, 'manifest.json')
  }),
+ new ExecutableDllPlugin()
]

By default all entry modules are run, if you would like to execute a particular entrypoint(s), you could specify it via plugin options:

new ExecutableDllPlugin({
  execute: [path.resolve(__dirname, './src/A.js')]
})

How it works

The idea is to call __webpack_require__ for each entry during webpack bootstrapping, e.g.:

['0','./src/A.js','./src/B.js','./src/C.js'].forEach(__webpack_require__);

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.