clarkmcc / go-typescript

Compile and run Typescript code natively in Go
GNU General Public License v3.0
104 stars 11 forks source link

typescriptServices.js was removed... #9

Closed bubbajoe closed 1 year ago

bubbajoe commented 1 year ago

https://github.com/microsoft/TypeScript/pull/51387

It mentions that typescriptServices.js has been removed; this file was identical to typescript.js, the entrypoint for our npm package.

when i use the 'typescript.js' it doesnt seem to work. Any clue?

clarkmcc commented 1 year ago

Can you clarify what error you're getting? When running with v4.9.3 I got the following error

panic: compiling registered source for tag 'v4.9.3': SyntaxError: (anonymous): Line 174482:39 Could not load source map: open typescript.js.map: no such file or directory

I was able to resolve the issue by removing this line from the end of the file:

//# sourceMappingURL=typescript.js.map

I've bumped the default Typescript version to 4.9.3 in #10. I'll probably merge that soon barring any other issues that are discovered from the change you cited https://github.com/microsoft/TypeScript/pull/51387.

bubbajoe commented 1 year ago

Can you clarify what error you're getting? When running with v4.9.3 I got the following error


panic: compiling registered source for tag 'v4.9.3': SyntaxError: (anonymous): Line 174482:39 Could not load source map: open typescript.js.map: no such file or directory

I was able to resolve the issue by removing this line from the end of the file:


//# sourceMappingURL=typescript.js.map

I've bumped the default Typescript version to 4.9.3 in #10. I'll probably merge that soon barring any other issues that are discovered from the change you cited https://github.com/microsoft/TypeScript/pull/51387.

I don't remember it was a bunch of errors. Let me try it again later.

bubbajoe commented 1 year ago

even when removing the map file (and the initial comment), it still didnt work.

I am using this btw: https://raw.githubusercontent.com/microsoft/TypeScript/main/lib/typescript.js

panic: SyntaxError: (anonymous): Line 54:9 Unexpected token * (and 373 more errors)

goroutine 9 [running]:
github.com/dop251/goja.MustCompile({0x0?, 0x10119e6b0?}, {0x1400a31e000?, 0x100c2157c?}, 0x20?)
        /Users/joe/go/pkg/mod/github.com/dop251/goja@v0.0.0-20230121114657-2e4cbb985272/runtime.go:1330 +0x5c
github.com/clarkmcc/go-typescript.WithTypescriptSource.func1(0x14006822050)
        /Users/joe/go/pkg/mod/github.com/clarkmcc/go-typescript@v0.6.0/config.go:80 +0x34
github.com/clarkmcc/go-typescript.TranspileCtx({0x101e76dd0?, 0x140000360f0}, {0x101e718e0, 0x14006b67b80}, {0x14000fe1dd8, 0x2, 0x0?})
        /Users/joe/go/pkg/mod/github.com/clarkmcc/go-typescript@v0.6.0/transpiler.go:29 +0x70
github.com/clarkmcc/go-typescript.TranspileString({0x14006b15c00, 0x3e3}, {0x14000adcdd8, 0x2, 0x2})
        /Users/joe/go/pkg/mod/github.com/clarkmcc/go-typescript@v0.6.0/transpiler.go:21 +0xac
github.com/bubbajoe/rkx/pkg/typescript.Transpile({0x14006b15c00, 0x3e3})
        /Users/joe/Documents/go/rkx/pkg/typescript/typescript.go:22 +0x140
github.com/bubbajoe/rkx/internal/proxy.(*ProxyState).setupModules(0x140063a93b0, 0x60?)
        /Users/joe/Documents/go/rkx/internal/proxy/dynamic_proxy.go:66 +0x1ac
github.com/bubbajoe/rkx/internal/proxy.StartDynamicProxy.func1()
        /Users/joe/Documents/go/rkx/internal/proxy/dynamic_proxy.go:241 +0x140
created by github.com/bubbajoe/rkx/internal/proxy.StartDynamicProxy
        /Users/joe/Documents/go/rkx/internal/proxy/dynamic_proxy.go:224 +0x9bc
exit status 2
jakebailey commented 1 year ago

So a few things:

Please don't use lib on main; it's just a random version we use to bootstrap the compiler and should not be used. We're going to remove it in the near future. If you want to test a new version of TS, I would build it (and use built/local) or grab a nightly from npm.

The reason for the above error is that we bumped TypeScript to emit ES2018 (so, we have native generator functions), which is newer than what goja supports. If you want to use typescript with an even lower target, you can run it through another downleveling step; easiest just to call esbuild without --bundle and then target ES2015 or ES5 or something.