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

Add "watch" flag with auto-reload support #9

Closed
JulianFeinauer opened this issue Apr 28, 2022 · 2 comments
Closed

Add "watch" flag with auto-reload support #9

JulianFeinauer opened this issue Apr 28, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@JulianFeinauer
Copy link

Hey, first, awesome work!

I saw your todo list and would also like some kind of watch mode that keeps running and just rebuilds the .lock file in case of file changes (see e.g. here: https://stackoverflow.com/questions/6271719/reusing-django-code-auto-reload-functionality-for-custom-management-commands)

An alternative could be to have the template tag to refresh the .lock file IF in DEBUG mode (or any other flag set).
What do you think of that?

(I would love to do a PR for this)

@davegaeddert
Copy link
Member

davegaeddert commented Apr 28, 2022

Thanks!

A watch mode is an interesting idea. Can you say more about how you'd expect to use it in practice? Are you in "rapid dev" mode and adding/removing packages and not wanting to re-run the generate command?

If it were added, I'd definitely prefer it be an explicit option like manage.py importmap_generate --watch. I think it could throw people off it the lock file were refreshed "magically" — just like with package.json/yarn.lock, if you simply ask for "react" without a version range (not saying that is a great practice) then a lockfile update could easily bump you to a new major version and break some stuff.

Depending on what you have in mind, I would guess that a manage.py importmap_add react command is probably related (and maybe importmap_remove)? Would function just like yarn add where you don't have to edit the importmap.toml by hand (error prone, have to look up the available versions manually, etc.) and it would update the lockfile automatically all in one command. Does that relate to what you're thinking?

@davegaeddert davegaeddert added the enhancement New feature or request label Apr 28, 2022
@davegaeddert
Copy link
Member

Realized a little bit ago that I was the one who suggested "Automatically rebuild importmap.lock during runserver / on config modification" and I'm assuming that's what you were referring to! Sorry!

After having been away from it for a little bit (obviously!), I would definitely push for add/remove commands instead and think of it more along the lines of package.json/yarn.lock etc. Can't think of any package managers that have a "watch" mode and like I mentioned in the other comment, I'm not actually sure I want one here...

Anyway, I updated the list on the README (83ce7a6) and would definitely help with a PR for importmap_add!

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

No branches or pull requests

2 participants