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

feat(labs): add esbuild_bundle build rule #2405

Closed
wants to merge 1 commit into from

Conversation

BobobUnicorn
Copy link

This is a wrapper around esbuild.

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x ] Tests for the changes have been added (for bug fixes / features)
  • [x ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • [ x] Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Adds a new labs package.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@mattem
Copy link
Collaborator

mattem commented Jan 18, 2021

This is great! 🚀 Perhaps we can work on converging the two implementations from this PR and here?
It's been a while since I've looked at it, and it needs a rebase (I'll do that now).

@BobobUnicorn
Copy link
Author

Oh, I didn't even realize there was one in progress! Yeah, I can try and merge them. Does this still belong in labs?

@mattem
Copy link
Collaborator

mattem commented Jan 25, 2021

I've rebased and greened up the original PR, and also merged some of what you've done here over. I think this should be fine outside labs.

Did you find the addition of workers gave a big improvement here? I haven't experimented with workers for esbuild yet.

I'm also in two minds about using the API over the CLI, ideally we could use the Go API to keep it native and fast, however that puts added dependencies on users for a Go toolchain and setup. Perhaps we can package that up nicely.

I'll try and get the other PR landed, and we can iterate on the implementation there perhaps?

Copy link
Collaborator

@mrmeku mrmeku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Sorry I took me 9 days to review the change. I'll be more responsive for the rest of the review process.

args.add_joined(["--platform", ctx.attr.platform], join_with = "=")
args.add_all(ctx.attr.loader, format_each = "--loader=%s")
args.add_all(ctx.attr.define, format_each = "--define=%s")
args.add_joined(["--target", "esnext"], join_with = "=")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the target be configurable? If not could you leave a comment saying why not?

default = [],
),
"tsconfig": attr.label(
doc = """The tsconfig file to use for the build.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does esbuild require a tsconfig? I didn't think it did but I could be wrong. If its not required, I don't think the rule should make it required

If you wish to use the default sourcemap behaviour, pass in "default".""",
default = "default",
),
"splitting": attr.bool(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you don't provide defaults to these boolean arguments they are considered required. Is that your intention? If not you might consider setting them to the esbuild defaults

"devDependencies": {
"esbuild": "0.8.32",
"minimist": "^1.2.5",
"protobufjs": "6.8.8"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these are all actual dependencies rather than dev dependencies.

@@ -0,0 +1,59 @@
load("//packages/jasmine:index.bzl", "jasmine_node_test")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great initial test. If possible, making an integration test within the examples directory will test that the actual npm packaging logic is correct. Not required for labs, but it gives me some piece of mind when I make one

@alexeagle
Copy link
Collaborator

Hi there, did you coordinate at all with authors of #2252 ? I think that one is close to landing, so maybe we can refactor some of your work into there?

@mattem
Copy link
Collaborator

mattem commented Feb 13, 2021

We released 3.2.0 with @bazel/esbuild package yesterday. I think the next extension there is supporting plugins or adding a worker, although esbuild is very fast, I'm not sure a worker is needed, but it would be a good extension anyway.

If you'd like to sync or pair on adding new features, let me know! 😄

@mattem mattem closed this Feb 13, 2021
@BobobUnicorn
Copy link
Author

Yeah, sorry about disappearing; it's been a busy month for me. I'd be happy to add worker/plugin support, but esbuild is definitely plenty fast.

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

Successfully merging this pull request may close these issues.

4 participants