Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gazelle extension for TypeScript #2

Closed
gregmagolan opened this issue Apr 28, 2022 · 4 comments
Closed

Gazelle extension for TypeScript #2

gregmagolan opened this issue Apr 28, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@gregmagolan
Copy link
Member

Replaces aspect-build/rules_js#20

@wtgtybhertgeghgtwtg
Copy link

I've been trying my hand at this, but it's fraught with speedbumps.

  • Gazelle requires extensions to be built in Go. There was talk about a plugin to support other languages, but it seems to have stalled.
  • Since esbuild doesn't expose its parser and I can't seem to find any other parser in Go-space, I've been statically linking a Rust binary that uses swc. Since swc has a library to grab dependencies, this part is surprisingly straightforward.
  • rules_go has issues with IDE support for cgo, so errors around the bindings on the Go side just have to be ignored.
  • The ecosystem does not have go-to rules for certain tasks like linting or formatting like other languages. I've mostly had to resolve to some internal macros for those, but they are not portable.
    Right now, I've got it far enough that it can spit out something like
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm_dependencies//:defs.bzl", "npm_link_all_packages")
load("//macros/eslint-test:eslint_test.bzl", "eslint_test")
load("//macros/transpile-typescript:transpile_typescript.bzl", "transpile_typescript")
 
npm_link_all_packages(name = "node_modules")

ts_config(
    name = "tsconfig",
    src = "tsconfig.json",
)

transpile_typescript(
    name = "typescript",
    srcs = ["source/render-package-json.ts"],
    package_json = "package.json",
    tsconfig = ":tsconfig",
    deps = [":node_modules/sort-keys"],
)

npm_package(
    name = "render-package-json",
    srcs = [":typescript"],
    visibility = ["//visibility:public"],
)

eslint_test(
    name = "eslint_test",
    srcs = ["source/render-package-json.ts"],
    eslintrc = ".eslintrc.cjs",
    package_json = "package.json",
    tsconfig = ":tsconfig",
    deps = [":node_modules/sort-keys"],
)

but it's hacky and nowhere near close enough for a PR. If the trade-offs above are acceptable for now, is there a design document I can conform to while cleaning it up and submit a proof of concept?

@alexeagle
Copy link
Member

Hi @wtgtybhertgeghgtwtg you made some good progress there!

I'm sorry we didn't update this issue sooner - right now we are planning to make the gazelle extension licensed differently from rules_ts so that we have some way to pay our engineers.

It does use esbuild's parser, with a little trick to get at the needed API.

We have that in a private repo, are you interested in collaborating on it despite that?

@wtgtybhertgeghgtwtg
Copy link

Most of the work I have has been with swc and linking side of things, so I doubt I'd be of much use if you've found an esbuild setup. Thank you for the offer, however.

@gregmagolan
Copy link
Member Author

We are close to releasing this feature with the Aspect CLI. Closing this issue as we are developing it closed source in our monorepo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants