babel-plugin-local-scoped-modules
Version:
babel-plugin-local-scoped-modules ================ This plugin intends to avoid typing relative paths.Use relative paths like local modules instead.
24 lines (22 loc) • 582 B
JavaScript
import config from './config'
import dealWithSource from './dealWithSource.js'
import getSource from './getSource.js'
const methodNames = [
"CallExpression",
"ImportDeclaration",
"ExportNamedDeclaration",
"ExportAllDeclaration",
]
let methodPairs = methodNames.map(name => {
return {
name,
fn: myFn
}
})
export default methodPairs
function myFn(path, state, methodname) {
let opts = { ...config, ...state.opts }
let source = getSource(path, methodname, opts)
if (!source) return;
return dealWithSource(source)(state, opts)
}