• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐ŸŽ Taking apart webpackJsonp

moduleRaid

moduleRaid is a utility to get modules and module constructors from webpackJsonp functions (or similar endpoints) embedded on websites by Webpack. It also provides functions to search through returned modules.

Installation

You can get moduleRaid over npm

$ npm install moduleraid

Or if you directly want to use it in the browser

<script src="https://unpkg.com/moduleraid/dist/moduleraid.iife.js"></script>

Or alternatively, just copy the contents from above unpkg link into the devtools console on a website!

Usage

Preparation

Using moduleRaid as a module, simply require and execute it somewhere where it will end up as a public facing script on a page that also includes a Webpack build!

import ModuleRaid from 'moduleRaid'

const mR = new ModuleRaid()

Examples

Now, with the mR instance available and modules being fetched, you can use the two available find*() methods to search for modules!

let results = mR.findModule('coolFeature')
// => Array of fitting modules for the search query

let constRes = mR.findConstructor('_internal')
// => Array of fitting constructor/module tuples for the search query

// after moduleRaid has been set up you can now listen for new chunks being loaded
document.addEventListener('moduleraid:webpack-push', (e) => {
  // e.detail contains the arguments push() was called with

  // your code here...
})

For more in-depth documentation around what you can use of moduleRaid, you can visit the API Documentation!

Special Thanks

License

moduleRaid is licensed under the MIT License