Skip to content

Set up separate dev and prod builds with esbuild - #1334

Merged
aomarks merged 10 commits into
mainfrom
devprod
Sep 26, 2022
Merged

Set up separate dev and prod builds with esbuild#1334
aomarks merged 10 commits into
mainfrom
devprod

Conversation

@aomarks

@aomarks aomarks commented Sep 24, 2022

Copy link
Copy Markdown
Contributor

Note to reviewers: I first used tsc + Rollup in this PR, and then replaced it with esbuild, so you'll see those commits in the middle. You can ignore them, or read them if you're interested.

Sets up separate dev and prod eleventy builds for the new webcomponents.org. Both builds use esbuild.

Running npm run watch:dev or npm run watch:prod from the top-level will give you live refresh versions of either build.

The dev build is super fast because [1] it uses symlinks so that Eleventy doesn't need to rebuild when static assets or JS changes, and [2] it runs esbuild with no minification or bundling.

There is a separate check:types command in the client package which runs TypeScript in noEmit mode. This runs in parallel when you use either of the top-level watch:* commands. So the experience is that the browser updates immediately, and a few moments later you also get any type errors.

This design lets us use identical <script> tags in both dev and prod mode, which is nice. On lit.dev we needed to generate different script tags for each mode.

Also addresses the post-merge comments from #1333

@aomarks
aomarks requested a review from rictic September 24, 2022 19:50
@aomarks aomarks mentioned this pull request Sep 24, 2022
@aomarks aomarks changed the title Set up separate dev and prod builds Set up separate dev and prod builds with esbuild Sep 24, 2022
Comment thread packages/client/package.json
Comment thread packages/client/package.json
Comment thread packages/content/eleventy.config.dev.cjs
]
},
"build:dev": {
"command": "eleventy --config=eleventy.config.dev.cjs",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should this have a dependency on ../client:build:dev?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, because otherwise every time the client code changes, Eleventy will re-run unnecessarily, because in dev mode that's just a symlink.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm... seems like that leaves a situation where the client output could be stale. Is there a different type of dependency at play here. Like: when you run task A, ensure B is up to date, but when you run B, do not dirty A.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what google/wireit#238 would be -- but I got a lot of feedback that the API and naming is weird, so I've been sitting on that for ages. Maybe need to get back to it.

@aomarks
aomarks merged commit b7127f1 into main Sep 26, 2022
@aomarks
aomarks deleted the devprod branch September 26, 2022 17:09
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.

2 participants