- Corrected module_bar settings to restore custom extension visibility in UI. - Fixed 'fs' dynamic require in acquisition endpoint by externalizing Node.js built-ins. - Standardized local environment branding to AT Mintel.
45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
import { build } from 'esbuild';
|
|
import { resolve, dirname } from 'path';
|
|
import { mkdirSync } from 'fs';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
const entryPoint = resolve(__dirname, 'src/index.ts');
|
|
const outfile = resolve(__dirname, 'dist/index.js');
|
|
|
|
try {
|
|
mkdirSync(dirname(outfile), { recursive: true });
|
|
} catch (e) { }
|
|
|
|
console.log(`Building from ${entryPoint} to ${outfile}...`);
|
|
|
|
build({
|
|
entryPoints: [entryPoint],
|
|
bundle: true,
|
|
platform: 'node',
|
|
target: 'node18',
|
|
outfile: outfile,
|
|
format: 'esm',
|
|
external: ["jsdom", "jsdom/*", "jquery", "jquery/*", "canvas", "fs", "path", "os", "http", "https", "zlib", "stream", "util", "url", "net", "tls", "crypto"],
|
|
plugins: [{
|
|
name: 'mock-canvas',
|
|
setup(build) {
|
|
build.onResolve({ filter: /^canvas/ }, args => ({ path: args.path, namespace: 'mock-canvas' }));
|
|
build.onLoad({ filter: /.*/, namespace: 'mock-canvas' }, () => ({ contents: 'export default {};', loader: 'js' }));
|
|
}
|
|
}, {
|
|
name: 'mock-jsdom',
|
|
setup(build) {
|
|
build.onResolve({ filter: /^jsdom/ }, args => ({ path: args.path, namespace: 'mock-jsdom' }));
|
|
build.onLoad({ filter: /.*/, namespace: 'mock-jsdom' }, () => ({ contents: 'export default {};', loader: 'js' }));
|
|
}
|
|
}]
|
|
}).then(() => {
|
|
console.log("Build succeeded!");
|
|
}).catch((e) => {
|
|
console.error("Build failed:", e);
|
|
process.exit(1);
|
|
});
|