1.3.2 • Published 5 years ago
babel-plugin-export-webpack-module-id v1.3.2
babel-plugin-export-webpack-module-id
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