Skip to content

Commit

Permalink
feat: auto external peerDeps (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Dec 3, 2021
1 parent 468347f commit f629d74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export async function build (rootDir: string, stub: boolean) {
externals: [...Module.builtinModules],
dependencies: [],
devDependencies: [],
peerDependencies: [],
rollup: {
emitCJS: true,
cjsBridge: false,
Expand Down Expand Up @@ -94,10 +95,11 @@ export async function build (rootDir: string, stub: boolean) {

// Infer dependencies from pkg
options.dependencies = Object.keys(pkg.dependencies || {})
options.peerDependencies = Object.keys(pkg.dependencies || {})
options.devDependencies = Object.keys(pkg.devDependencies || {})

// Add all dependencies as externals
options.externals.push(...options.dependencies)
options.externals.push(...options.dependencies, ...options.peerDependencies)

// Call build:before
await ctx.hooks.callHook('build:before', ctx)
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export interface BuildOptions {
outDir: string
stub: boolean
externals: string[]
dependencies: string[],
dependencies: string[]
peerDependencies: string[]
devDependencies: string[]
rollup: RollupBuildOptions
}
Expand Down

0 comments on commit f629d74

Please sign in to comment.