Comments (9)
@gdborton cache-loader
!= babel-loader
(cache). Why?
cache-loader
caching information which need to speedup webpack build (see https://github.com/webpack-contrib/cache-loader/blob/master/src/index.js#L25, includingtranspile
code frombabel-loader
)babel-loader
with cache only cachingtranspile
code (https://github.com/babel/babel-loader/blob/master/src/index.js#L156)
What contain cache-loader
in cache (https://github.com/webpack-contrib/cache-loader/blob/master/src/index.js#L36)
remainingRequest
/path/to/node_modules/babel-loader/lib/index.js??ref--0-1!/path/to/src/containers/app/app.js
dependencies
[ { path: '/path/to/src/containers/app/app.js',
mtime: 1493382032000 },
{ path: '/path/to/node_modules/cache-loader/dist/cjs.js',
mtime: 1493198456000 },
{ path: 'path/to/node_modules/babel-loader/lib/index.js',
mtime: 1493381646000 } ]
contextDependencies
(It makes no sense with onlybabel-loader
but makes sense if you use loaders which addcontext
dependencies beforebabel-loader
, let's see who it do https://github.com/webpack-contrib/cache-loader/blob/master/src/index.js#L36)result
-transpile
code and options forcache-loader
[ '\'use strict\';\n\nconsole.log(\'Cache here\');', null ] // instead `null` your can have options here for `cache-loader`
Hm, what does it make sense to use together cache-loader
and babel-loader
(for most use case, where one babel-loader
for scripts)?
- Yes, if your don't use
cacheDirectory
option forbabel-loader
(cache-loader
caching alltranspile
code and other own stuff see above). - Rather Yes Than No, if your use
cacheDirectory
option forbabel-loader
,pitch
loader (https://webpack.github.io/docs/loaders.html#pitching-loader) some faster then standard (sync/async
) loader.
If you have any comments I'll be happy to hear, if you want to know how to use it together style-loader/css-loader
just put +1.
from cache-loader.
FYI, cache-loader decreased our build times from 100 seconds to 33 seconds @ trivago.
Edit: I'll put more context here. We use babel-loader, some combination of css, sass, style, file, raw loaders for some static assets, custom loaders for loading in-house templating engines etc. I've tested each of them one by one. cache-loader
helps for all of them. Number of seconds depends on how much work loaders before cache-loader
do. I've tested this on a Macbook (in case SSD and OS makes a difference). We have thousands of JS modules, using cache-loader
infront of babel-loader
decreases build time by 50 seconds.
from cache-loader.
I'm definitely not sokra, but one difference is that happypack is parallelized. This looks to be a much smaller configuration for easy perf wins.
Keep in mind that babel-loader (which is likely processing the most files in your code) has a built in cache as well.
from cache-loader.
And the existing https://github.com/jsdf/cached-loader.
from cache-loader.
Did it have some data test between cache-loader and happypack ? Or can I use both of them ?
from cache-loader.
As I read about happypack
the creator said:
I just assumed webpack 2 has a higher overhead and never investigated since I don't have much time for this anymore.
Here is the thread: amireh/happypack#144
And if you read their issues you will see there's more problems with webpack 2.
So I think better use cache-loader
since it's from webpack creators and it will be maintained as well.
P.S. I tested cache-loader
with babel-loader
so for me the rebuild time was the same, no difference if I use babel-loader
with cacheDirectory
or cache-loader
without cacheDirectory
or with cacheDirectory
enabled.
from cache-loader.
So I think better use cache-loader since it's from webpack creators and it will be maintained as well.
That sums it up pretty well :) Feel free to reopen if still any questions
from cache-loader.
Not sure why there is a "vs."? It looks like I can use them together and get ~3s wins on re-runs. Or are there any caveats I don't know?
from cache-loader.
@donaldpipowitch Well as far as I know they both do the same thing = caching of built files. The main difference would be happy adds parallel compilation support to webpack, but to be honest I never noticed a difference on my other cores while running it. In a test bench I did for my project it even took longer for the initial build to complete.
I'm not sure using both of them is wise as they might start fighting each other...
from cache-loader.
Related Issues (20)
- memory leak when using different splitchunks optimizations options HOT 3
- optimize cache-loader performance
- Should I remove cache-loader in webpack5 HOT 1
- file do not emit at the first build when using cache-loader with file-loader HOT 1
- Exception: Cannot read property 'stat' of undefined HOT 10
- bug report of 1.2.4 HOT 12
- custom write and read are much slower than the default HOT 3
- Module build failed: TypeError: Cannot read property 'async' of undefined at react-app-dashboard/node_modules/babel-loader/lib/index.js:50:27 HOT 1
- Change default cache directory HOT 1
- Should source maps be cached? HOT 1
- Should cache-loader use `module.exports.raw = true` to handle binary file ? HOT 6
- Using relative paths - sources still contains absolute paths HOT 5
- usage with eslint-loader, warnings/errors are swallowed after successful compilation HOT 5
- Can you describe when user should invalidate cache via setup custom cache dir, identity, etc? HOT 2
- using with file-loader, files are not builded if in cache, even if dist folder is empty HOT 5
- Use relative path on this.fs.stat returns stale metadata
- Control `cacheDirectory` with env variable HOT 3
- invalidate with cache HOT 3
- Cache TTL to assests HOT 1
- No files emitted with responsive-loader HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cache-loader.