Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const server = async ({ port }) => {
const compiler = new TypescriptCompiler(CWD, 'config/server/tsconfig.json', require('typescript/lib/typescript'));
const { error, config } = compiler.configParser().parse();
if (error || !config || config.errors.length) {
return;
}
const watcher = compiler.watcher(config);
let app;
watcher.on('watcher:ready', async () => {
// start the HTTP server
app = await start({ port });
});
private _setupCompiler () {
const compilerPath = require.resolve('typescript/lib/typescript', { paths: [this.projectRoot] })
/**
* Create typescript compiler instance
*/
this._compiler = new TypescriptCompiler(require(compilerPath), 'tsconfig.json', this.projectRoot)
this._compiler.use((ts) => iocTransformer(ts, this._rcFile), 'after')
/**
* Hold reference to the underlying typescript instance
*/
this.ts = this._compiler.ts
}
import {
RCFILE_NAME,
TSCONFIG_FILE_NAME,
SERVER_ENTRY_FILE,
DEFAULT_BUILD_DIR,
} from '../../config/paths'
/**
* Exposes the API to build the AdonisJs project for development or
* production. The production build has it's own set of node_modules
*/
export class Compiler {
/**
* Reference to typescript compiler
*/
public tsCompiler = new TypescriptCompiler(
this.appRoot,
TSCONFIG_FILE_NAME,
require(resolveFrom(this.appRoot, 'typescript/lib/typescript')),
)
/**
* Reference to HTTP server
*/
public httpServer: HttpServer | DummyHttpServer
/**
* Reference to rc File
*/
public rcFile = new RcFile(this.appRoot)
/**