-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[Packager] Command or flag to clean cache #1924
Comments
+1 |
1 similar comment
👍 |
We use this quick and dirty gulp task: gulp.task('clear-cache', function () {
// Clear react-packager cache
var tempDir = os.tmpdir();
var cacheFiles = fs.readdirSync(tempDir).filter(function (fileName) {
return fileName.indexOf('react-packager-cache') === 0;
});
cacheFiles.forEach(function (cacheFile) {
var cacheFilePath = path.join(tempDir, cacheFile);
fs.unlinkSync(cacheFilePath);
console.log('Deleted cache: ', cacheFilePath);
});
if (!cacheFiles.length) {
console.log('No cache files found!');
}
}); |
Nice one @shlomiatar! Could you submit a pull request to add that command to the packager? |
+1 |
ideally the cache key would consider the current babel transforms |
+1 thanks for the tip, and yeh a clean command would be appreciated :) |
@martinbigio just shipped a diff that adds support for this. Should land soon. |
|
👍 this is such an annoying bug 🪲 where do we add the gulp task? |
@alejomendoza, you can run the task by typing |
For the time being you also can run |
|
I tried both, but |
Nevermind, resolved. |
hours_spent_here += 2;
|
Would it be possible not to rely on |
Ping @kittens :) |
+1 |
hours_spent_here += 3;
|
We recently added support to allow the transformer to specify a cache key (b5f8006). You should be able to make the key dependent on the plugins you're using (the preset + the specifics to your build if any). |
|
Now I think it is? watchman . watch-del-all |
It seems this problem still exists, but react no longer writes its cache to the tmp directory. Where is it hiding now? |
Let's not forget Windows. |
The command to clear the cache is |
The config this guy proposes is really good to handle this https://medium.com/komenco/useful-react-native-npm-scripts-6c07b04c3ac3#.63boty1oh |
These commands from Ignite are great too:
|
npm start -- --reset-cache works much better than npm start --reset-cache |
@lprhodes I see that EDIT: N/m, I RTFM :-)
|
thx@lprhodes |
Is there any way to clear the cache while the packager is still running? Or more to my ultimate goal, just tell the react-native packager to re-transpile a specific javascript file on some filesystem event? |
@j2kun Enabling live reload should work for everything except after changes to node_modules. |
@lprhodes This doesn't work for non-javascript file changes. What I have been doing (a really crappy workaround) is creating a watchman trigger for my specific file to run
But this doesn't even work because I have to restart the packager for it to pick up that these cache files got deleted. I would really love a way to say "Hey packager, when this file changes, please re-transpile this other JS file!" But I've been searching and experimenting for a week and can't figure out how to do this. |
This was the solution I was able to come up with. Would appreciate any suggestions for improvements, or better yet a principled way to do it |
As discussed in facebook#11983. The double dash is necessary to pass through the argument to node. Based on the comments [here](facebook#1924 (comment)), it looks like most people use the double dash; it's unclear whether it would do anything at all if the dashes were omitted. If anyone else has better insight, let me know! @hramos please review, thank you. This reverts commit f521e99.
As discussed in facebook#11983. The double dash is necessary to pass through the argument to node. Based on the comments [here](facebook#1924 (comment)), it looks like most people use the double dash; it's unclear whether it would do anything at all if the dashes were omitted. If anyone else has better insight, let me know! @hramos please review, thank you. This reverts commit f521e99.
Summary: As discussed in facebook/react-native#11983. The double dash is necessary to pass through the argument to node. Based on the comments [here](facebook/react-native#1924 (comment)), it looks like most people use the double dash; it's unclear whether it would do anything at all if the dashes were omitted. If anyone else has better insight, let me know! Closes facebook/react-native#13003 Differential Revision: D4731566 Pulled By: hramos fbshipit-source-id: 62562536db7589a03a511762117cbf0e36d3aafb
Summary: As discussed in #11983. The double dash is necessary to pass through the argument to node. Based on the comments [here](#1924 (comment)), it looks like most people use the double dash; it's unclear whether it would do anything at all if the dashes were omitted. If anyone else has better insight, let me know! Closes #13003 Differential Revision: D4731566 Pulled By: hramos fbshipit-source-id: 62562536db7589a03a511762117cbf0e36d3aafb
I had to remove both |
On windows, I made the mistake of renaming node_modules to node_modules.todelete in an effort to debug an issue. Something cached this and gave me an error P: error: bundling failed: ambiguous resolution: module [mymodule] tries to require 'react-native', but there are several files providing this module. You can delete or fix them:
The key for me was the haste removal tip by @david-a I am sharing this mainly so folks can find the error text I encountered |
https://gist.github.com/jarretmoses/c2e4786fd342b3444f3bc6beff32098d#gistcomment-2277722
|
When introducing a custom
.babelrc
, it's necessary to add the resetCache flag to the packager. This requires digging intonode_modules
and isn't the most developer friendly (DX anybody? :P)So we should either allow users to do:
./node_modules/react-native/packager/packager.sh clean
or
./node_modules/react-native/packager/packager.sh -root . -clean
Also open to other solutions! cc @amasad
The text was updated successfully, but these errors were encountered: