Skip to content

Commit

Permalink
feat(experimental): add optimizeDeps.exclude option
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Dec 26, 2021
1 parent 822d71c commit 0a0efe2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"releaseRules": [
{ "type": "refactor", "release": "patch" },
{ "type": "style", "release": "patch" },
{ "scope": "no-release", "release": false }
{ "scope": "no-release", "release": false },
{ "scope": "experimental", "release": "patch" }
]
}
],
Expand Down
6 changes: 6 additions & 0 deletions src/optimizer/optmize-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import esModuleLexer from 'es-module-lexer'

export type OptimizeDepsOptions = {
include: string[]
exclude?: string[]
cwd: string
esbuildOptions?: EsbuildOptions
sourceMap: boolean
Expand Down Expand Up @@ -41,6 +42,11 @@ export const optimizeDeps = async (
name: 'optimize-deps',
async setup(build) {
build.onResolve({ filter: /.*/ }, async (args) => {
if (options.exclude?.includes(args.path)) {
return {
external: true,
}
}
if (args.pluginData?.__resolving_dep_path__) {
return // use default resolve algorithm
}
Expand Down

0 comments on commit 0a0efe2

Please sign in to comment.