Add ModuleType `none`

This commit is contained in:
Tony Garnock-Jones 2023-12-01 12:23:35 +01:00
parent 0f9c200583
commit 939004264a
1 changed files with 7 additions and 2 deletions

View File

@ -28,7 +28,7 @@ export function stripShebang(items: Items): Items {
return items; return items;
} }
export type ModuleType ='es6' | 'require' | 'global'; export type ModuleType ='es6' | 'require' | 'global' | 'none';
export type ErrorSink = (message: string, start: Pos | undefined, end: Pos | undefined) => void; export type ErrorSink = (message: string, start: Pos | undefined, end: Pos | undefined) => void;
@ -37,7 +37,6 @@ export interface CompileOptions {
name?: string, name?: string,
runtime?: string, runtime?: string,
module?: ModuleType, module?: ModuleType,
global?: string,
typescript?: boolean, typescript?: boolean,
emitError: ErrorSink, emitError: ErrorSink,
} }
@ -331,6 +330,12 @@ export function compile(options: CompileOptions): CompilerOutput {
case 'global': case 'global':
tree = ts`const __SYNDICATE__ = ${runtime};\n${tree}`; tree = ts`const __SYNDICATE__ = ${runtime};\n${tree}`;
break; break;
case 'none':
break;
default:
((_: never) => {
throw new Error(`Unsupported ModuleType: ${moduleType}`);
})(moduleType);
} }
} }