Skip to content

Commit 775c752

Browse files
authored
Upgrade ts and tstl (#101)
* Upgrade ts and tstl * Fix prettier
1 parent dcd9c4b commit 775c752

File tree

3 files changed

+45
-18
lines changed

3 files changed

+45
-18
lines changed

package-lock.json

Lines changed: 32 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"react-json-tree": "^0.15.0",
3636
"react-monaco-editor": "^0.43.0",
3737
"stream-browserify": "^3.0.0",
38-
"typescript-to-lua": "1.3.3"
38+
"typescript-to-lua": "1.4.0"
3939
},
4040
"devDependencies": {
4141
"@ark120202/typescript-config": "^2.2.0",
@@ -49,7 +49,7 @@
4949
"raw-loader": "^4.0.2",
5050
"sass": "^1.27.0",
5151
"sass-loader": "^12.1.0",
52-
"typescript": "^4.3.4",
52+
"typescript": "~4.6.2",
5353
"worker-loader": "^3.0.8"
5454
},
5555
"browserslist": [

src/pages/play/ts.worker.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ import * as tstl from "typescript-to-lua";
88
require("path").parse = (x: any) => x;
99
require("path").format = (x: any) => x;
1010

11-
const libContext = require.context(`raw-loader!typescript-to-lua/dist/lualib`, true, /(.+)(?<!lualib_bundle)\.lua$/);
11+
const libContext = require.context(
12+
`raw-loader!typescript-to-lua/dist/lualib`,
13+
true,
14+
/(.+)(?<!lualib_bundle)\.(lua|json)$/,
15+
);
1216
const emitHost: tstl.EmitHost = {
1317
directoryExists: () => false,
1418
fileExists: (fileName) => ts.sys.fileExists(fileName),
1519
getCurrentDirectory: () => "",
1620
readFile: (fileName: string) => {
21+
if (fileName.endsWith("lualib_module_info.json")) {
22+
// Make sure this json is read as ra wfile and not as ESM JSON module.
23+
return require("typescript-to-lua/dist/lualib/lualib_module_info.json.raw!=!raw-loader!typescript-to-lua/dist/lualib/lualib_module_info.json")
24+
.default;
25+
}
26+
1727
const [, featureName] = fileName.match(/\/dist\/lualib\/(.+)\.lua$/) || [];
1828
if (featureName === undefined) {
1929
throw new Error(`Unexpected file to read: ${fileName}`);

0 commit comments

Comments
 (0)