mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-09 15:39:45 +08:00
27 lines
639 B
JavaScript
27 lines
639 B
JavaScript
'use strict';
|
|
|
|
const { dirname } = require('path');
|
|
const fs = require('fs');
|
|
const { getProjectPath } = require('./utils/projectHelper');
|
|
|
|
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(getProjectPath('node_modules', esModule));
|
|
if (fs.existsSync(esPath)) {
|
|
path.node.source.value = esModule;
|
|
}
|
|
}
|
|
}
|
|
|
|
function replaceLib() {
|
|
return {
|
|
visitor: {
|
|
ImportDeclaration: replacePath,
|
|
ExportNamedDeclaration: replacePath,
|
|
},
|
|
};
|
|
}
|
|
|
|
module.exports = replaceLib;
|