Skip to content

Commit dc4b764

Browse files
committed
Fix playground crashing on imports
1 parent 7f3b1e4 commit dc4b764

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/pages/play/ts.worker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import * as worker from "monaco-editor/esm/vs/editor/editor.worker";
22
import { TypeScriptWorker } from "monaco-editor/esm/vs/language/typescript/tsWorker";
33
import * as tstl from "typescript-to-lua";
44

5+
// Mock unsupported in path-browserify@0.0.1 parse and format functions used for normalization in
6+
// https://github.com/TypeScriptToLua/TypeScriptToLua/blob/3ebc76745f74ce709bf0ba39f830a8f5cf94c473/src/transformation/visitors/modules/import.ts#L25-L28
7+
require("path").parse = (x: any) => x;
8+
require("path").format = (x: any) => x;
9+
510
const libContext = require.context(`raw-loader!typescript-to-lua/dist/lualib`, true, /(.+)(?<!lualib_bundle)\.lua$/);
611
const emitHost: tstl.EmitHost = {
712
getCurrentDirectory: () => "",
@@ -35,6 +40,7 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
3540
const program = this._languageService.getProgram()!;
3641

3742
const compilerOptions: tstl.CompilerOptions = program.getCompilerOptions();
43+
compilerOptions.rootDir = "inmemory://model/";
3844
compilerOptions.luaLibImport = tstl.LuaLibImportKind.Inline;
3945
compilerOptions.luaTarget = tstl.LuaTarget.Lua53;
4046

0 commit comments

Comments
 (0)