Parcel upgrade and global dependency update
This commit is contained in:
@@ -1,55 +1,8 @@
|
||||
import { sandboxCompile, sandboxCompileModule } from "../compile";
|
||||
import { SysCallMapping } from "../system";
|
||||
|
||||
import globalModules from "../../common/dist/global.plug.json";
|
||||
|
||||
import * as ts from "typescript";
|
||||
|
||||
type CompileError = {
|
||||
message: string;
|
||||
pos: number;
|
||||
};
|
||||
|
||||
function checkTypeScript(scriptFile: string): void {
|
||||
let program = ts.createProgram([scriptFile], {
|
||||
noEmit: true,
|
||||
allowJs: true,
|
||||
});
|
||||
let emitResult = program.emit();
|
||||
|
||||
let allDiagnostics = ts
|
||||
.getPreEmitDiagnostics(program)
|
||||
.concat(emitResult.diagnostics);
|
||||
|
||||
let errors: CompileError[] = [];
|
||||
allDiagnostics.forEach((diagnostic) => {
|
||||
if (diagnostic.file) {
|
||||
let { line, character } = ts.getLineAndCharacterOfPosition(
|
||||
diagnostic.file,
|
||||
diagnostic.start!
|
||||
);
|
||||
let message = ts.flattenDiagnosticMessageText(
|
||||
diagnostic.messageText,
|
||||
"\n"
|
||||
);
|
||||
errors.push({
|
||||
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
|
||||
pos: diagnostic.start!,
|
||||
});
|
||||
// console.log(
|
||||
// `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
|
||||
// );
|
||||
} else {
|
||||
console.log(
|
||||
ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
let exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||
console.log(`Process exiting with code '${exitCode}'.`);
|
||||
process.exit(exitCode);
|
||||
}
|
||||
// TODO: FIgure out a better way to do this
|
||||
const builtinModules = ["yaml", "handlebars"];
|
||||
|
||||
export function esbuildSyscalls(): SysCallMapping {
|
||||
return {
|
||||
@@ -71,17 +24,14 @@ export function esbuildSyscalls(): SysCallMapping {
|
||||
functionName,
|
||||
true,
|
||||
[],
|
||||
[...Object.keys(globalModules.dependencies), ...excludeModules]
|
||||
[...builtinModules, ...excludeModules]
|
||||
);
|
||||
},
|
||||
"esbuild.compileModule": async (
|
||||
ctx,
|
||||
moduleName: string
|
||||
): Promise<string> => {
|
||||
return await sandboxCompileModule(
|
||||
moduleName,
|
||||
Object.keys(globalModules.dependencies)
|
||||
);
|
||||
return await sandboxCompileModule(moduleName, builtinModules);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user