Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto external peerDeps #25

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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