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

fix: default watch_dir to src of project directory #646

Merged
merged 1 commit into from
Mar 20, 2022

Conversation

threepointone
Copy link
Contributor

Via wrangler 1, when using custom builds in wrangler dev, watch_dir should default to src of the "project directory" (i.e - wherever the wrangler.toml is defined if it exists, else in the cwd.

Fixes #631

@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2022

🦋 Changeset detected

Latest commit: 2fb8e48

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2010721608/npm-package-wrangler-646

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/646/npm-package-wrangler-646

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2010721608/npm-package-wrangler-646 dev path/to/script.js

@threepointone
Copy link
Contributor Author

I tested the prerelease build with https://github.com/jahands/wrangler-dev-example and it worked! Nice.

command
? configPath
? path.relative(
process.cwd(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally I think we need to be making these paths relative to the wrangler.toml. The reason is that otherwise the following would have different results:

wrangler -c path/to/wrangler.toml ...
cd path/to
wrangler -c wrangler.toml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I don't understand. what would be the difference with these two? they would both resolve a watch_dir config to the same path, unless I'm missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does resolve against wrangler.toml's path in the next line

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, so I see my confusion now. You are saying that the configPath is always, already, relative to the cwd() (or it is absolute).

In that case there is no need for the relative(process.cwd(), ...) bit then, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a personal preference, I don't like seeing absolute paths if and when I log this during development. Is that a problem?

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 exactly how we normalised paths for wasm_modules and text_blobs too

Copy link
Contributor

Choose a reason for hiding this comment

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

OK - it just really confused me, because if it is possible that configPath is not relative to src then this would break.
Happy to go with this for the timebeing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah of the wrangler.Tom isn't adjacent to a src directory then this won't work. Honestly I think there shouldn't have been a default for that field at all (much like upload.dir)

@threepointone
Copy link
Contributor Author

dammit forgot a changeset

Via wrangler 1, when using custom builds in `wrangler dev`, `watch_dir` should default to `src` of the "project directory" (i.e - wherever the `wrangler.toml` is defined if it exists, else in the cwd.

Fixes #631
command
? configPath
? path.relative(
process.cwd(),
Copy link
Contributor

Choose a reason for hiding this comment

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

OK - it just really confused me, because if it is possible that configPath is not relative to src then this would break.
Happy to go with this for the timebeing.

@threepointone threepointone merged commit c75cfb8 into main Mar 20, 2022
@threepointone threepointone deleted the default-watch-dir branch March 20, 2022 17:24
@github-actions github-actions bot mentioned this pull request Mar 20, 2022
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.

🐛 BUG: wrangler dev does not watch for source changes when using a custom build command
3 participants