Skip to content

Commit

Permalink
switch to build constants
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Dec 6, 2023
1 parent 31032fe commit a0597d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeFile } from 'fs/promises'
import { createContext } from './src/index.ts'
import { CONSTANTS, createContext } from './src/index.ts'
import tsc from 'tsc-prog'

const isDev = process.argv.includes('--dev')
Expand Down Expand Up @@ -63,11 +63,11 @@ buildContext.hook('cjs:error', async errors => {
errors.map(x => console.error(x))
})

buildContext.hook('error', async error => {
buildContext.hook(CONSTANTS.BUILD_ERROR, async error => {
console.error(error)
})

buildContext.hook('complete', async () => {
buildContext.hook(CONSTANTS.BUILD_COMPLETE, async () => {
tsc.build({
basePath: process.cwd(),
compilerOptions: {
Expand Down
10 changes: 5 additions & 5 deletions examples/01_express/build.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { copyFile, writeFile } from 'fs/promises'
import { createContext } from 'esbuild-multicontext'
import { nodeExternals } from 'esbuild-plugin-node-externals'
import { spawn } from 'child_process'
import { CONSTANTS, createContext } from 'esbuild-multicontext'
import { nodeExternals } from 'esbuild-plugin-node-externals'
import { copyFile } from 'fs/promises'

const isDev = process.argv.includes('--dev')

Expand Down Expand Up @@ -45,11 +45,11 @@ buildContext.hook('server:complete', () => {
spawnedTask = task.pid
})

buildContext.hook('error', errors => {
buildContext.hook(CONSTANTS.ERROR, errors => {
errors.map(x => process.stdout.write(x.reason.toString() + '\n'))
})

buildContext.hook('complete', async () => {
buildContext.hook(CONSTANTS.COMPLETE, async () => {
process.stdout.write('[custom-builder] Built\n')

// Copy assets after build is complete
Expand Down

0 comments on commit a0597d3

Please sign in to comment.