vuecssuiant-designantdreactantantd-vueenterprisefrontendui-designvue-antdvue-antd-uivue3vuecomponent
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
602 B
27 lines
602 B
'use strict' |
|
|
|
const { join, dirname } = require('path') |
|
const fs = require('fs') |
|
|
|
const cwd = process.cwd() |
|
|
|
function replacePath (path) { |
|
if (path.node.source && /\/lib\//.test(path.node.source.value)) { |
|
const esModule = path.node.source.value.replace('/lib/', '/es/') |
|
const esPath = dirname(join(cwd, `node_modules/${esModule}`)) |
|
if (fs.existsSync(esPath)) { |
|
path.node.source.value = esModule |
|
} |
|
} |
|
} |
|
|
|
function replaceLib () { |
|
return { |
|
visitor: { |
|
ImportDeclaration: replacePath, |
|
ExportNamedDeclaration: replacePath, |
|
}, |
|
} |
|
} |
|
|
|
module.exports = replaceLib
|
|
|