1.3.2 • Published 4 years ago
babel-plugin-module-mapper v1.3.2
babel-plugin-module-mapper
TODO
- generate only one import when transform to exist import declaretion
This plugin aim to map particular import to another module.
demo
for some reason, you can't modify code, you need babel to do this
import { createElement, PropTypes } from 'react';
to
import { createElement } from 'react';
import PropTypes from 'prop-types';
config
{
'${targetModuleName}': {
'${targetExport (defaultExport alias to default)}': ['${targetModuleName}', '${targetExportName}', ${targetLocalName?}]
}
}
// demo config for demo
{
'react': {
'PropTypes': ['prop-types', 'default']
}
}
targetLocalName
{
'preact': {
'preact': ['preact', 'default', 'React']
}
}
transform:
import preact from 'preact';
// will transform to:
import React from 'preact';
lis
WTF lis.