-
Notifications
You must be signed in to change notification settings - Fork 673
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
implement custom builds, for dev
and publish
#149
Conversation
🦋 Changeset detectedLatest commit: 4ae5c27 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -371,7 +424,7 @@ type EsbuildBundle = { | |||
}; | |||
|
|||
function useEsbuild(props: { | |||
entry: string; | |||
entry: void | string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC - what's the difference between void
and undefined
in this type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to revisit very void
and replace it with undefined
. I just got trigger happy and regret it now.
81717a7
to
a4c3ea8
Compare
I made some changes -
I'll edit the main PR description as well. |
Any thoughts on |
Pages dev has an additional requirement of 'detecting' what ports were opened and proxying them, etc, so I can see the requirement there. That said, I'd revisit the choice of the blank |
(That said, I'd like for |
@@ -30,7 +30,8 @@ | |||
"scripts": { | |||
"lint": "eslint packages/**", | |||
"check": "prettier packages/** --check && tsc && npm run lint", | |||
"prettify": "prettier packages/** --write" | |||
"prettify": "prettier packages/** --write", | |||
"test": "npm run test --workspace=wrangler" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is fine for now, we should think about a more generalised solution for when the other packages in this workspace have tests to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strongly agreed, just did this as a quick dx win for myself rn.
packages/wrangler/src/dev.tsx
Outdated
watch(watch_dir, { persistent: true, ignoreInitial: true }).on( | ||
"all", | ||
(_event, _path) => { | ||
console.log("Restarting build..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps log the path of the changed file that caused the rebuild?
Something like?
console.log(`The file ${path} changed`);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done and done
cmd = execa(commandPieces[0], commandPieces.slice(1), { | ||
...(cwd && { cwd }), | ||
stderr: "inherit", | ||
stdout: "inherit", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is now repeated - let's move it into its own function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just one statement, doesn't pass my threshold for a new abstraction yet imo
The code here is a bit jank, but we should probably refactor the way we pass arguments to dev and publish to 'fix' it properly. Anyway. This PR adds custom builds to wrangler2 (https://developers.cloudflare.com/workers/cli-wrangler/configuration#build). - In `wrangler.toml`, you can configure `build.command` and `build.cwd` and it'll be called before `publish` or `dev`. There's some discussion to be had whether we're going to deprecate this config commands, but we'll support it until then anyway. - We _don't_ support `build.watch_dir`. We could, and I'm happy to add it after we discuss; but the idea is that watching shouldn't be wrangler's responsibility (which we've already broken with plain `dev`, and `pages dev`, so maybe we're wrong) - You can pass the command after a last `--` in the cli (no support for `cwd` there). eg - `wrangler dev output/index.js -- some-build-command --out output/index.js`.
- removed the `--` option. We should have documentation showing how to do this with bash etc. - Added support for `watch_dir` - also added a definition for running tests from the root because it was annoying me to keep changing dirs to run tests
a4c3ea8
to
4ae5c27
Compare
The code here is a bit jank, but we should probably refactor the way we pass arguments to dev and publish to 'fix' it properly. Anyway.
This PR adds custom builds to wrangler2 (https://developers.cloudflare.com/workers/cli-wrangler/configuration#build).
wrangler.toml
, you can configurebuild.command
andbuild.cwd
and and it'll be called beforepublish
ordev
. We also optionally watchbuild.watch_dir
for changes during dev. There's some discussion to be had whether we're going to deprecate this config commands, but we'll support it until then anyway.I swear I'll start writing tests for
publish
before the year is over. Maybe evendev
.closes #120