Skip to content

bloody-ux/babel-plugin-export-webpack-module-id

Repository files navigation

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

About

Support adding `module.id ` to named export and default export

Resources

License

Stars

Watchers

Forks

Packages

No packages published