Skip to content

Commit

Permalink
feat: support alias and esbuild config (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
  • Loading branch information
hannoeru and pi0 authored Dec 10, 2021
1 parent fe1ac94 commit b0b09e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export async function build (rootDir: string, stub: boolean, inputConfig: BuildC
dependencies: [],
devDependencies: [],
peerDependencies: [],
alias: {},
rollup: {
esbuild: {
target: 'es2020'
},
emitCJS: false,
cjsBridge: false,
inlineDependencies: false
Expand Down
9 changes: 5 additions & 4 deletions src/builder/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {

plugins: [
alias({
[ctx.pkg.name!]: ctx.options.rootDir
entries: {
[ctx.pkg.name!]: ctx.options.rootDir,
...ctx.options.alias
}
}),

nodeResolve({
Expand All @@ -160,9 +163,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {

shebangPlugin(),

esbuild({
target: 'es2020'
}),
esbuild(ctx.options.rollup.esbuild),

commonjs({
extensions,
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { PackageJson } from 'pkg-types'
import type { Hookable } from 'hookable'
import type { RollupOptions, RollupBuild } from 'rollup'
import type { MkdistOptions } from 'mkdist'
import type { Options as EsbuildOptions } from 'rollup-plugin-esbuild'
import { Schema } from 'untyped'

export interface BaseBuildEntry {
Expand Down Expand Up @@ -34,6 +35,7 @@ export interface RollupBuildOptions {
emitCJS?: boolean
cjsBridge?: boolean
inlineDependencies?: boolean
esbuild: EsbuildOptions
}

export interface BuildOptions {
Expand All @@ -47,6 +49,7 @@ export interface BuildOptions {
dependencies: string[]
peerDependencies: string[]
devDependencies: string[]
alias: { [find: string]: string },
rollup: RollupBuildOptions
}

Expand Down

0 comments on commit b0b09e0

Please sign in to comment.