From a0597d359b0e29197dc784f1cfd43081301d8515 Mon Sep 17 00:00:00 2001 From: Reaper Gelera Date: Wed, 6 Dec 2023 12:09:42 +0530 Subject: [PATCH] switch to build constants --- build.js | 6 +++--- examples/01_express/build.mjs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.js b/build.js index 6aa1974..5f1edc9 100644 --- a/build.js +++ b/build.js @@ -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') @@ -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: { diff --git a/examples/01_express/build.mjs b/examples/01_express/build.mjs index 22f93fe..20de9ef 100644 --- a/examples/01_express/build.mjs +++ b/examples/01_express/build.mjs @@ -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') @@ -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