33 lines
1.0 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
/**
* @open-matrix/browser-host build
*
* Shell-phase build. Compiles src/ via tsc to dist/. Phase 1 of
* core-decontamination uses this to verify the package boundary works
* end-to-end before files are moved out of core.
*/
import { execFileSync } from 'node:child_process';
import { createRequire } from 'node:module';
import { rmSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const distDir = resolve(__dirname, 'dist');
const require = createRequire(import.meta.url);
const typescriptPackageJson = require.resolve('typescript/package.json', { paths: [__dirname] });
const tscBin = resolve(dirname(typescriptPackageJson), 'bin/tsc');
rmSync(distDir, { recursive: true, force: true });
execFileSync(process.execPath, [
tscBin,
'-p',
resolve(__dirname, 'tsconfig.build.json'),
], {
cwd: __dirname,
stdio: 'inherit',
});
console.log('[browser-host-build] dist/index.js');