@@ -37,6 +37,7 @@ export async function bootstrapProductionBuild(config) {
3737 keepNames : true ,
3838 outDir,
3939 silent : true ,
40+ watch : false ,
4041 entry : [ src , '!dist' , '!.commandkit' , `!${ outDir } ` ] ,
4142 } ) ;
4243
@@ -63,40 +64,40 @@ export async function injectShims(outDir, main, antiCrash, polyfillRequire) {
6364 const tail = '\n})();' ;
6465 const requireScript = polyfillRequire
6566 ? [
66- '// --- CommandKit require() polyfill ---' ,
67- ' if (typeof require === "undefined") {' ,
68- ' const { createRequire } = await import("node:module");' ,
69- ' const __require = createRequire(import.meta.url);' ,
70- ' Object.defineProperty(globalThis, "require", {' ,
71- ' value: (id) => {' ,
72- ' return __require(id);' ,
73- ' },' ,
74- ' configurable: true,' ,
75- ' enumerable: false,' ,
76- ' writable: true,' ,
77- ' });' ,
78- ' }' ,
79- '// --- CommandKit require() polyfill ---' ,
80- ] . join ( '\n' )
67+ '// --- CommandKit require() polyfill ---' ,
68+ ' if (typeof require === "undefined") {' ,
69+ ' const { createRequire } = await import("node:module");' ,
70+ ' const __require = createRequire(import.meta.url);' ,
71+ ' Object.defineProperty(globalThis, "require", {' ,
72+ ' value: (id) => {' ,
73+ ' return __require(id);' ,
74+ ' },' ,
75+ ' configurable: true,' ,
76+ ' enumerable: false,' ,
77+ ' writable: true,' ,
78+ ' });' ,
79+ ' }' ,
80+ '// --- CommandKit require() polyfill ---' ,
81+ ] . join ( '\n' )
8182 : '' ;
8283
8384 const antiCrashScript = antiCrash
8485 ? [
85- '// --- CommandKit Anti-Crash Monitor ---' ,
86- " // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process" ,
87- ' // instead of using it as a means to resume operation.' ,
88- ' // But it exists here due to compatibility reasons with discord bot ecosystem.' ,
89- " const p = (t) => `\\x1b[33m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';" ,
90- ' if (!process.eventNames().includes(e1)) // skip if it is already handled' ,
91- ' process.on(e1, (e) => {' ,
92- ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));' ,
93- ' })' ,
94- ' if (!process.eventNames().includes(e2)) // skip if it is already handled' ,
95- ' process.on(e2, (r) => {' ,
96- ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));' ,
97- ' });' ,
98- '// --- CommandKit Anti-Crash Monitor ---' ,
99- ] . join ( '\n' )
86+ '// --- CommandKit Anti-Crash Monitor ---' ,
87+ " // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process" ,
88+ ' // instead of using it as a means to resume operation.' ,
89+ ' // But it exists here due to compatibility reasons with discord bot ecosystem.' ,
90+ " const p = (t) => `\\x1b[33m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';" ,
91+ ' if (!process.eventNames().includes(e1)) // skip if it is already handled' ,
92+ ' process.on(e1, (e) => {' ,
93+ ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));' ,
94+ ' })' ,
95+ ' if (!process.eventNames().includes(e2)) // skip if it is already handled' ,
96+ ' process.on(e2, (r) => {' ,
97+ ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));' ,
98+ ' });' ,
99+ '// --- CommandKit Anti-Crash Monitor ---' ,
100+ ] . join ( '\n' )
100101 : '' ;
101102
102103 const contents = await readFile ( path , 'utf-8' ) ;
0 commit comments