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

File watch mode. #2280

Closed
boldurean opened this issue Mar 15, 2023 · 8 comments · Fixed by #2316 or #2343
Closed

File watch mode. #2280

boldurean opened this issue Mar 15, 2023 · 8 comments · Fixed by #2316 or #2343
Assignees
Labels
feat New feature or request good first issue Good for newcomers

Comments

@boldurean
Copy link

What problem does this feature solve?

There is no way to turn on watch mode analogue to webpack --watch for just transpile jsx and output it to folder.

Imagine people are not running client dev server but they still need to transpile .jsx/.tsx files and output them to the dist directory. This problem happens when project is configured with other backend frameworks like ASP.NET which runs razor templates.

What does the proposed API of configuration look like?

rspack --watch - will just watch file changes and will translie&output to the "output" folder once files change.

@boldurean boldurean added the feat New feature or request label Mar 15, 2023
@hardfist hardfist added the good first issue Good for newcomers label Mar 15, 2023
@bekharsky
Copy link

There is more. Documentation states that Rspack provides watch mode: https://www.rspack.dev/config/watch.html#watch

But when I try to use that, I got an error:

$ yarn rs-dev      
yarn run v1.22.0
$ NODE_ENV=development rspack
(node:38802) DeprecationWarning: A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
(Use `node --trace-deprecation ...` to show where the warning was created)
Hash: 45a2d73d002b786a

@boldurean
Copy link
Author

boldurean commented Mar 17, 2023

@SoonIter I think what build --watch do is to rebuild including optimize and split chunks for production.
The actual issue is that rspack doesn't have a watch mode for development. All it's has to do is replicate webpack --watch command not build --watch otherwise it will rebuild entire app including dependencies after every file change which is overhead. Vite has something similar and it's redundant.

@SoonIter
Copy link
Member

I think I know what you mean. I don't use this command very often.
Do webpack watch , webpack --watch and wepack build --watch have the same behavior?

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Mar 17, 2023

@boldurean The status quo of Rspack does not align with webpack, which I think is a mistake. Webpack, by default, will respect the environment variables and mode, etc, however, it is hardcoded

.
Would you take a look at this again @SoonIter?

@boldurean
Copy link
Author

@h-a-n-a yep, I respect the targets and totally agree with them. I just find rspack very perspective and want as more people use it especially those like me who cannot shut down webpack from their production because non of the other current solutions provide same functionality.

Let me try to explain the problem that can be solved if this feature will be included.

Lots backend frameworks provide their dev server. As an example ASP.NET core has .cshtml embedded templates and run those in the memory. So you cannot point to the index.html file from the client side. All you have to do is to run the bundler on the client in --watch mode in order to watch for file changes and output them to the selected directory as per config file. This mode doesn't require any build optimizations it just need to input some .jsx/.tsx/js/ts files transpile -> output.
Webpack has this feaute built in. So we can write wepback --watch pointing to the dev config ant it will watch for file changes and output the changed one and all affected in the chain. Output files can be still configured like [name].[hash].ext but the main idea is that actually it outputs files to the destination.

@boldurean
Copy link
Author

I think I know what you mean. I don't use this command very often.

Do webpack watch , webpack --watch and wepack build --watch have the same behavior?

Not really. Looks like build --watch rebuilds project entirely for example if my build takes 10s after adding one line of the code it will take "production" config and will rebuild everything which is 10s again.
In the webpack --watch mode it will transpile all files and then once I chage one the only affected will be transpiled which takes 0.0n second's depending of machine capabilities.

@SoonIter
Copy link
Member

Thank you for your feedback.
We already have this feature config/cache.html,
However, the stdout is a little different, and then there are some problems with the "NODE_ENV" environment.
I would fix this.

image

image

@boldurean
Copy link
Author

@SoonIter thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request good first issue Good for newcomers
Projects
None yet
5 participants