Skip to content

Commit

Permalink
feat: custom tsconfig and allow multpile tsup config
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 22, 2021
1 parent 3f37270 commit 555c535
Show file tree
Hide file tree
Showing 11 changed files with 364 additions and 211 deletions.
75 changes: 75 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -66,6 +66,7 @@
"svelte": "3.37.0",
"ts-essentials": "^7.0.1",
"ts-jest": "^26.5.5",
"tsconfig-paths": "^3.12.0",
"tsup": "^5.7.2",
"typescript": "^4.2.4",
"wait-for-expect": "^3.0.2"
Expand Down
15 changes: 10 additions & 5 deletions src/esbuild/index.ts
Expand Up @@ -4,7 +4,7 @@ import { transform as transformToEs5 } from 'buble'
import { build as esbuild, BuildResult, formatMessages } from 'esbuild'
import { NormalizedOptions, Format } from '..'
import { getDeps, loadPkg } from '../load'
import { log } from '../log'
import { Logger } from '../log'
import { nodeProtocolPlugin } from './node-protocol'
import { externalPlugin } from './external'
import { postcssPlugin } from './postcss'
Expand Down Expand Up @@ -34,7 +34,11 @@ const getOutputExtensionMap = (

export async function runEsbuild(
options: NormalizedOptions,
{ format, css }: { format: Format; css?: Map<string, string> }
{
format,
css,
logger,
}: { format: Format; css?: Map<string, string>; logger: Logger }
) {
const pkg = await loadPkg(process.cwd())
const deps = await getDeps(process.cwd())
Expand All @@ -55,7 +59,7 @@ export async function runEsbuild(
options.minify || options.minifyWhitespace ? 'production' : 'development'
}

log(format, 'info', 'Build start')
logger.info(format, 'Build start')

const startTime = Date.now()

Expand Down Expand Up @@ -84,6 +88,7 @@ export async function runEsbuild(
target: options.target === 'es5' ? 'es2016' : options.target,
footer: options.footer,
banner: options.banner,
tsconfig: options.tsconfig,
loader: {
'.aac': 'file',
'.css': 'file',
Expand Down Expand Up @@ -172,7 +177,7 @@ export async function runEsbuild(
metafile: Boolean(options.metafile),
})
} catch (error) {
log(format, 'error', 'Build failed')
logger.error(format, 'Build failed')
throw error
}

Expand Down Expand Up @@ -200,7 +205,7 @@ export async function runEsbuild(
// Manually write files
if (result && result.outputFiles) {
const timeInMs = Date.now() - startTime
log(format, 'success', `Build success in ${Math.floor(timeInMs)}ms`)
logger.success(format, `Build success in ${Math.floor(timeInMs)}ms`)

await Promise.all(
result.outputFiles.map(async (file) => {
Expand Down

1 comment on commit 555c535

@vercel
Copy link

@vercel vercel bot commented on 555c535 Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.