Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Port babel loader fs cache as the default caching engine #159

Merged
merged 4 commits into from
Mar 23, 2017

Conversation

viankakrisna
Copy link
Contributor

@viankakrisna viankakrisna commented Feb 27, 2017

This pr implements the tried and tested fs-cache from babel-loader. It still need to test some case though. The current implementation of caching is quite buggy based on the issue on facebook/create-react-app#1656 .

Todos:

  • Create an updated tests that watches *.gz files which generated by loader-fs-cache instead of data.json and other use cases..
  • Create benchmark and see the speed we gain by turning on cache Will do it another time
  • Pass the tests

For people who want to test this pr I've published an npm package in https://www.npmjs.com/package/eslint-loader-fs-cache

@viankakrisna viankakrisna changed the title port babel loader fs cache as the default caching engine [WIP] port babel loader fs cache as the default caching engine Feb 27, 2017
@gaearon
Copy link

gaearon commented Feb 27, 2017

Needs rebasing?

@viankakrisna
Copy link
Contributor Author

@gaearon done!

@MoOx
Copy link
Contributor

MoOx commented Feb 27, 2017

Can't we try to use a common module instead of copy/pasting/adapting?

@gaearon
Copy link

gaearon commented Feb 27, 2017

It would be nice but as a follow up work IMO :-) We're hoping to fix this asap, and extracting a module would require coordination between both packages and somebody willing to do the work.

@gaearon
Copy link

gaearon commented Feb 27, 2017

🤔

@viankakrisna
Copy link
Contributor Author

ah, should i coordinate first? @gaearon

@gaearon
Copy link

gaearon commented Feb 27, 2017

If you already published it, I guess it's fine! Can you send a PR to babel-loader later too?
Is this an exact copy?

@viankakrisna
Copy link
Contributor Author

@gaearon gladly! yes, essentially i just wrap the babel implementation with a function that takes the name for findCacheDir https://github.com/viankakrisna/loader-fs-cache/blob/master/index.js#L179

@viankakrisna
Copy link
Contributor Author

@gaearon @MoOx currently i'm stuck with writing an updated test for cache in this pr

@gaearon
Copy link

gaearon commented Feb 28, 2017

This is reported to work well.

@viankakrisna
Copy link
Contributor Author

viankakrisna commented Mar 3, 2017

@MoOx @gaearon do you guys have time to review the code? I've been stuck why the tests are failing in quiet mode

@gaearon
Copy link

gaearon commented Mar 3, 2017

Unfortunately I don't know anything about the test setup in this repo, @MoOx can you help?

@peternewnham
Copy link
Contributor

@viankakrisna if you're having trouble with the tests hanging it's because you have a bunch of test.cb() calls in the cache.js file which are never being ended so they are just waiting forever - https://github.com/avajs/ava#tend

@viankakrisna
Copy link
Contributor Author

@wrakky ah, haven't pushed the updated codes! 😢 I'm trying to figure out why all the tests would fail, even when the cache option is turned off 😭

index.js Outdated
}
printLinterOutput(lint(engine, input, resourcePath), config, this)
this.callback(input, map)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viankakrisna i think this is your problem - first argument to this.callback is an error so should be set to null like the other callback a couple of line above it.

@viankakrisna
Copy link
Contributor Author

viankakrisna commented Mar 6, 2017

@wrakky thank you! That works! I wonder why it's changed like that though 😅
I'll update the tests for caching tonight, so I can remove the [WIP] tag.

@viankakrisna
Copy link
Contributor Author

@MoOx I think it should be good now 👍

@viankakrisna viankakrisna changed the title [WIP] port babel loader fs cache as the default caching engine Port babel loader fs cache as the default caching engine Mar 6, 2017
@MoOx
Copy link
Contributor

MoOx commented Mar 7, 2017

It seems to be good for me, just one last question: I think by reading the tests that you are covering by tests things that should be taken care by the module that handle the cache (loader-fs-cache).
Am I correct? I think some tests are not really necessary in this repo and make more sense in loader-fs-cache). Tell me if I am wrong (which happen often in my life ^^).
We can merge this PR and move the tests after if you want this asap :)

@viankakrisna
Copy link
Contributor Author

@MoOx yeah, that's what I'm thinking too, do you have any particular line of the test that should be moved to loader-fs-cache? And how can we test the cache feature without leaking the implementation detail?

@viankakrisna
Copy link
Contributor Author

@MoOx I think right now it's not too much in a rush, because we've already reverted the changes to just not use the cache setting. But if we can ship this, we can surface the bugs early in CRA environment. I'm curious what @gaearon thinks about it though.

})
})

test.cb.serial("should output json.gz files to standard cache dir by default",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the kind of test that should live in the loader cache module.

@MoOx
Copy link
Contributor

MoOx commented Mar 23, 2017

Sorry my time is limited atm. Let's ship this as it is.

@MoOx MoOx merged commit 7367f41 into webpack-contrib:master Mar 23, 2017
@MoOx MoOx mentioned this pull request Mar 23, 2017
@MoOx
Copy link
Contributor

MoOx commented Mar 23, 2017

Published as 1.7.0

@kerrmarin
Copy link

Hi, this latest PR looks like it broke dependencies on mkdirp as per #166. Can we revert this and publish 1.7.1?

@MoOx
Copy link
Contributor

MoOx commented Mar 23, 2017

@kerrmarin #166 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants