Skip to content

Commit

Permalink
fix(preset): pkg src folder alias bug (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Mar 10, 2020
1 parent f335887 commit 913d776
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/preset-dumi/src/plugins/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,18 @@ export default function(api: IApi) {
hostPkgAlias
.filter(([pkgName]) => pkgName)
.forEach(([pkgName, pkgPath]) => {
let srcModule;
const srcPath = path.join(pkgPath, 'src');
const linkPath = path.join(api.paths.cwd, 'node_modules', pkgName);

try {
srcModule = require(srcPath);
} catch (err) {
/* nothing */
}

// use src path instead of main field in package.json if exists
if (fs.existsSync(srcPath)) {
if (srcModule) {
// exclude es & lib folder
if (!config.resolve.alias.has(`${pkgName}/es`)) {
config.resolve.alias.set(`${pkgName}/es`, srcPath);
Expand Down

0 comments on commit 913d776

Please sign in to comment.