Comments (10)
And changing
let unpack = require('caniuse-lite').feature
to
let unpack = require('caniuse-lite/dist/unpacker/feature');
results in total time of 100ms.
So without any caching, these two imports reduce startup time from ~300ms to ~100ms.
from autoprefixer.
in-memory cache to disk to avoid this
require()
should already have this cache. require()
the module next time took less time (if there is no hacks around require()
).
How do you plan to add better cache?
from autoprefixer.
i want the cache to be persisted between compilation runs. so restarting compilation process would be slightly faster. it can also thus be shared between different processes (like production webpack runs and storybook builds etc.)
from autoprefixer.
const started = Date.now();
let { agents } = require('caniuse-lite')
let dataPrefixes = require('../data/prefixes')
console.log("caniuse require took", (Date.now() - started), "ms");
Running node node_modules\autoprefixer\lib\autoprefixer.js
(node 16.19.0):
caniuse require took 423 ms
caniuse require took 327 ms
caniuse require took 324 ms
caniuse require took 320 ms
caniuse require took 331 ms
caniuse require took 334 ms
caniuse require took 338 ms
from autoprefixer.
Yes, I understand the problem (honestly, it mostly came from ts-node
because it parses all require
files, and Can I Use DB has a big JSONs).
What solution do you suggest?
from autoprefixer.
the times above are plain node, without ts-node.
The let autoprefixerData = { browsers: agents, prefixes: dataPrefixes }
object serialized to JSON takes around 285KB in my case. So I was thinking of writing this to disk (probably, just based on caniuse-lite/package.json version) and reading when available.
from autoprefixer.
First small thing - changing
let { agents } = require('caniuse-lite')
to
let { agents } = require('caniuse-lite/dist/unpacker/agents')
removes the big cost to load whole caniuse-lite for loading just browser stats - this same import is used by browserslist to calculate usage.
So that leaves only the feature require.
from autoprefixer.
So I was thinking of writing this to disk (probably, just based on caniuse-lite/package.json version) and reading when available
You need to think about cache invalidation on caniuse-lite
update. And about working in the environment without fs
(for instance, in the browser).
It could be much more complex, than you think.
let { agents } = require('caniuse-lite/dist/unpacker/agents')
Yes, we can change it. Send PR.
from autoprefixer.
PR incoming.
from autoprefixer.
The fix was released in 10.4.14.
from autoprefixer.
Related Issues (20)
- Not autoprefixing the files with webpack HOT 2
- `dvh` fallback HOT 1
- Remove incorrect warning: end value has mixed support, consider using flex-end instead HOT 17
- Rules duplicate when moz-placeholder prefix added HOT 3
- Autoprefixer changes value for mask-repeat HOT 4
- Tailwind CSS: Text color of form inputit isn't properly set on autofill (Chrome). May be solved with 'autoprefixer'? HOT 1
- 🐛 Media queries issue with older browsers HOT 1
- Avoid generating prefixes for browsers that don't support Gradient Midpoints HOT 1
- user-select: contain does not require the -webkit and -moz prefixes HOT 5
- 404 error HOT 1
- Prefix apparance: none HOT 1
- Support light-dark HOT 1
- Do not remove prefixes when using -webkit-line-clamp HOT 2
- Unexpected vendor prefix "::-moz-placeholder" HOT 1
- Threshold for dropping "mixed support" warnings? HOT 6
- 10.4.13 onwards - not using vendor prefix when Electron needs it? HOT 4
- Use `-webkit-linear-gradient` instead of `-webkit-gradient` when the `linear-gradient` contains `var(...)`. HOT 2
- [email protected]
- Consider adding overflow: clip -> overflow: hidden HOT 1
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 autoprefixer.