Skip to content

Commit

Permalink
fix: spnpmImportsPlugin not work as expectation in pd (#6462)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoonIter committed Apr 27, 2023
1 parent 59160ff commit 893936b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pnpm/dev/pd.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@ const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'pack
name: 'spnpmImports',
setup: (build) => {
// E.g. @pnpm/config -> /<some_dir>/pnpm/packages/config/src/index.ts
build.onResolve({ filter: /@pnpm\// }, ({path, resolveDir}) => {
const pathParts = path.split('/')
const packageName = pathParts[1]

build.onResolve({ filter: /@pnpm\// }, ({ path, resolveDir }) => {
// Bail if the package isn't present locally
if (!localPackages.includes(packageName)) {
if (!localPackages.includes(path)) {
return
}

const newPath = pathLib.resolve(dirByPackageName[packageName], packageName, 'src', 'index.ts')

const newPath = pathLib.resolve(dirByPackageName[path], 'src', 'index.ts')
return {
path: newPath
}
Expand Down

0 comments on commit 893936b

Please sign in to comment.