Skip to content

Commit

Permalink
fix: use dynamic import directly without require.resolve (#345)
Browse files Browse the repository at this point in the history
close #336
close #344
  • Loading branch information
JounQin committed Nov 11, 2023
1 parent f249337 commit 67a52d2
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions packages/size-limit/load-plugins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)

function toArray(obj) {
return typeof obj === 'object' ? Object.keys(obj) : []
}
Expand All @@ -26,13 +23,7 @@ export default async function loadPlugins(pkg) {
.concat(toArray(pkg.packageJson.devDependencies))
.concat(toArray(pkg.packageJson.optionalDependencies))
.filter(i => i.startsWith('@size-limit/') || i.startsWith('size-limit-'))
.map(i =>
import(
require.resolve(i, {
paths: [process.cwd()]
})
).then(module => module.default)
)
.map(i => import(i).then(module => module.default))
).then(arr => arr.flat())

return new Plugins(list)
Expand Down

0 comments on commit 67a52d2

Please sign in to comment.