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

chore: Introduce esbuild for project build #209

Closed
wants to merge 2 commits into from
Closed

Conversation

jonathonherbert
Copy link
Contributor

What does this change?

Adds esbuild to the repo, speeding up build startup and watch times considerably.

To ensure typechecking continues, we use tork-ts-checker-webpack-plugin, which runs in parallel with the main build and does not block module output in watch mode.

Unfortunately, esbuild doesn't support the new jsx runtime yet, which means we need to explicitly import React when using jsx. (We were inconsistent before.) I've added a linting rule via the react/recommended plugin to ensure this is the case, and fixed a couple of other things that this new linting config spotted, too.

How to test

Run yarn watch and yarn build. (Don't forget to run yarn in the project root beforehand, to install the new dependencies!) The build should work as before, and the tests should pass.

Both operations should be noticeably faster.

How can we measure success?

Faster watch and build operations.

@jonathonherbert jonathonherbert requested a review from a team February 28, 2022 10:32
@jonathonherbert jonathonherbert changed the title Introduce esbuild for project build chore: Introduce esbuild for project build Feb 28, 2022
overrides: [
{
files: ["*.ts", "*.tsx"],
extends: ["@guardian/eslint-config-typescript"],
rules: {
"@typescript-eslint/unbound-method": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-unused-vars": 2
"@typescript-eslint/no-unused-vars": 2,
"react/display-name": 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is nice to have, but makes it difficult to define private class methods that represent elements, so I've turned it off for now.

@jonathonherbert jonathonherbert marked this pull request as draft February 28, 2022 10:36
@twrichards
Copy link
Contributor

in watch mode, does this run tsc watch in parallel with the rebuilds, if not you might want to do that part manually?

@jonathonherbert
Copy link
Contributor Author

@twrichards IIUC that's the job of fork-ts-checker-webpack-plugin:

> runs in parallel with the main build and does not block module output in watch mode.

@jonathonherbert
Copy link
Contributor Author

(Incidentally AFAICS pinboard is not using esbuild for the client, but if you were and found a neat solution to jsxImportSource, I'd be interested to hear – at the moment, emotion components do not render correctly, I presume because they are not receiving their jsx function from emotion)

@jonathonherbert
Copy link
Contributor Author

Closing in favour of an eventual PR to use vite, which has worked well elsewhere.

@jonathonherbert jonathonherbert deleted the jsh/esbuild branch September 27, 2022 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants