-
Notifications
You must be signed in to change notification settings - Fork 147
should one disable cache during development? #746
Comments
Hi @dkebler! Our cache is generated by an If it preserves the original that could be the source of the problem. If it's a common enough issue I can see about also adding the package version of the module to the cache hash. |
This maybe be happening to me because when I am fixing an issue with an underlying package I use npm link (or an rsync if remote) to get the working package code in place. Seems like that would not invalidate the cache. Still in this case what file path does it use? the main from package json? Most of my packages use an index.js file for the main and load exported/imports from the actual source files. Would that not cause invalidation? So yea maybe package version is a good idea to add in as well although sometimes in development I force push on the same version for small bug fixes :- So per my question 1. If I set the env variable I won't have any of these issues. No caches, every run starts from scratch? |
If you could create a small repro repo of this scenario I can investigate and possibly add it to our test suite.
Disabling the cache disables the cache 🙃 |
I'm trying to complete a project but this issue is important to me as well as I am a bit confused about where the cache(s) are made. It is only supposed to be in the main node_modules/.cache/esm? Or does esm create one for each dependency? because that's what I notice. It's the later that causes the problem. i.e. If I do an |
Caches are made at package boundaries where |
Hi @jdalton, cc/ @dkebler I just found myself in a very similar cache invalidation problem. My development workflow is
The package I'm developing is intended to be installed globally so that's why this particular workflow. Anyway problem is after step 4 After making code changes, repacking and reinstalling globally, test runs do not always reflect changes in the code. It was only after 2 days of frustration that I discovered that the cache files where not being removed by
(My global node lib is in my home folder) Aside from this tearing-my-hair-out episode, I fully appreciate the enormous amount of work you have put into esm so thank you very much! Oh, also when you say as above
do |
Thanks @indiescripter! It looks like
Nope. Update: Update:
Update: Welp, touching files broke people (#771) so I had to revert that. Looks like for your scenario disabling the cache with the environment variable or through config is the way to go 😄 Update:
|
Thanks for trying that fix @jdalton . Sorry it didn't pan out. |
caches still being made. Docs do not indicate value for this env var. |
Any truthy value should do. See Line 185 in 91a154b
|
ok so the cache should be disabled per the env variable I set but it's not. Even if I delete all the So either
wish I could track down why as it's making it hard to work on a dependency. |
The |
The { ...
"atimeMs": 1563058196864.3647,
"mtimeMs": 499162500000,
"ctimeMs": 1562991851221.0933,
"birthtimeMs": 499162500000,
"atime": "2019-07-13T22:49:56.864Z",
"mtime": "1985-10-26T08:15:00.000Z",
"ctime": "2019-07-13T04:24:11.221Z",
"birthtime": "1985-10-26T08:15:00.000Z"
...
} Could you maybe use the following heuristic? const aLongTimeAgoMs = new Date('1999-01-01T00:00Z').getTime();
const stat = fs.statSync(moduleFile);
const cacheTime = stat.mtimeMs > aLongTimeAgoMs ? stat.mtimeMs : stat.ctimeMs; I'm having a hard time explaining to everyone on my team that we need to do Otherwise, thanks so much for esm, it's generally making my life easier, |
@michaelfig I'm up for trying it out. |
@jdalton, would you like a PR, or to do this your own way? |
@michaelfig A PR would be super helpful. Thank you! |
I have the same (or a related) issue in @lorena-ssi/wallet-lib which I work around with this pr; the problem can be seen in v1.1.0 of that repo. |
# 1.0.0 (2021-04-13) ### Bug Fixes * upadate dependencies. fix broken tests. ([696baf9](696baf9)) * **package:** update acorn to version 5.0.0 ([standard-things#97](https://github.com/qiwi-forks/esm/issues/97)) ([aefa703](aefa703)) ### Reverts * Revert "Switch from using mtime to ctime for cache validation. [closes standard-things#746]" ([376438c](376438c)), closes [standard-things#746](https://github.com/qiwi-forks/esm/issues/746) * Revert "Remove SafeJSON." ([5947eb4](5947eb4)) * Revert "Only hoist function declarations." ([55d92f8](55d92f8)) * Revert "Temporarily remove chakracore/latest from appveyor test matrix." ([6968f58](6968f58)) * Revert "Remove unneeded package options cloning." [closes standard-things#504] ([7c22f88](7c22f88)), closes [standard-things#504](https://github.com/qiwi-forks/esm/issues/504) * Revert "Remove ava from tips section." ([fbe713f](fbe713f)) * Revert "Remove refDestructuringErrors references from acorn plugins." ([c89e922](c89e922)) * Revert "Allow options.generateLegacyModuleImport to force legacy module.import." ([6bf5564](6bf5564)), closes [standard-things#116](https://github.com/qiwi-forks/esm/issues/116) * Revert "Revert ast-types/fork changes to reinstate JSX types." ([6d5d4fd](6d5d4fd)), closes [standard-things#87](https://github.com/qiwi-forks/esm/issues/87) * Revert "Move reify to peerDependencies of Babel plugin." ([428a632](428a632))
Found myself updating a package I'm working on in another project and then wondering why the new code (although there in the node_modules) is ignored only to find that the folder has a node_modules/esm cache in it as well. When I delete that then happily the new code is loaded instead of I assume the code that was in the cache.
So two questions:
I suppose if you could elaborate a bit on the cache and it use/purpose I'd understand better the implications of use. I saw some other issues about invalidating the cache(s) is that something that should happen automagically on dependency updates? Thx
The text was updated successfully, but these errors were encountered: