babel-plugin-export-webpack-module-id

1.3.2 • Public • Published

babel-plugin-export-webpack-module-id

Build Status License No Dependencies

Adding webpackModuleId to default export and named export, it's useful for HMR support

Installation

yarn

yarn add babel-plugin-export-webpack-module-id

npm

npm install babel-plugin-export-webpack-module-id

.babelrc:

{
  "plugins": ["export-webpack-module-id"]
}

What it does

For each module, export webpackModuleId

Taking from the test snapshots, it does this:

export default function() {
  var x = 5;
  console.log('xxxx');
}
 
      ↓ ↓ ↓ ↓ ↓ ↓
 
var _ref = function () {
  var x = 5;
  console.log('xxxx');
};
 
_ref.webpackModuleId = module.id;
export default _ref;
export const webpackModuleId = module.id;

For more usages, please find the detail in ./__tests__/index.js

Options

webpackModuleId:The property name of the module id. string, default: 'webpackModuleId'

include: which files to add module id. string | string[], default: undefined exclude: which files not to add module id. string | string[], has higher priority than include, default: undefined

Dependencies (0)

    Dev Dependencies (26)

    Package Sidebar

    Install

    npm i babel-plugin-export-webpack-module-id

    Weekly Downloads

    1

    Version

    1.3.2

    License

    MIT

    Unpacked Size

    173 kB

    Total Files

    16

    Last publish

    Collaborators

    • bloody-ux