question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In --watch mode, have an option to compare "before" and "after" CONTENT of the changed file, not only the timestamp

See original GitHub issue

Feature request

Have an option in watchOptions which tells the watcher to additionally compare the changed file’s content and not trigger if the timestamp is changed, but the content is not.

Consider this command:

touch src/some-input.js

What is the expected behavior?

With this new option set to true, the above touch may not trigger the watch-mode build.

What is motivation or use case for adding/changing the behavior?

Sometimes timestamp of an input file might change, but the actual content would not. It would be great to have a hint to the watcher which ignores the file’s timestamp change if the content is unchanged.

When does it happen? Sometimes an input file refers another *.js file (possible from another monorepo package, something like shared/xyz.js) which is built by an external tool, like tsc. And tsc is known of changing the timestamps of the output even if the input is unchanged: https://github.com/microsoft/TypeScript/issues/35340 (I think they do it for some internal reasons, to detect incremental changes better). In this case, a no-op override of a dependent file (possibly from another monorepo package) causes webpack watch mode to trigger the build.

Using ts-loader here is not an option: it it’s a large monorepo with many package referring one another, we don’t want multiple webpack processes for each of these projects to recompile all the source *.ts files of all dependent packages. Instead, we want them to use tsc compiler output from packages/some-package/dist/*.{js,map} - which is way faster since TS compiles such files only once (i.e. O(n) as opposed to O(n^2) ts-loader compilation approximation if n is the number of packages which refer each other).

How should this be implemented in your opinion?

Something around Watchpack & recheck when the change arrives.

Are you willing to work on this yourself?

Yes, if the idea is approved, and also with some hints regarding the desired architecture.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sokracommented, Jul 16, 2021

The watcher doesn’t support that, but webpack can be changed to compare file content hashes instead of timestamps to check for module invalidation. It would still rebuild, but would just take all modules from the cache.

https://webpack.js.org/configuration/other-options/#snapshot

snapshot: {
    module: {
      timestamp: true,
      hash: true,
    },
}

This will compare file content hash, when timestamp has changed. Note that this makes the initial build slower as all files need to be read and hashed to have baselines to compare with.

0reactions
webpack-botcommented, Feb 14, 2022

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Watch for Files Changes in Node.js - thisDaveJ
In this article, we learn how to watch for file changes in Node.js (and take action when those file changes occur) using a...
Read more >
Review changes | PyCharm Documentation - JetBrains
Display all changed files in the current change set and navigate to them. This action is only available when you review changes to...
Read more >
Git status shows files as changed even though contents are ...
I have resolved this problem using following steps. Remove every file from Git's index. git rm --cached -r . Rewrite the Git index...
Read more >
Track changes using Change column types - AppSheet Help
AppSheet has a simple mechanism to track changes -- the Change column types. ... Mode setting controls how the counter increments when data...
Read more >
Cloud Firestore triggers | Cloud Functions for Firebase
When a function is triggered, you might want to get data from a document that was updated, or get the data prior to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found