-
Notifications
You must be signed in to change notification settings - Fork 11
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
Require takes a lot of time #76
Comments
For example, before: require(autoprefixer) = enb-autoprefixer: 378ms before: var autoprefixer = require('autoprefixer-core');
var browserslist = require('browserslist');
module.exports = require('enb/lib/build-flow').create()
.name('css-autoprefixer')
.defineRequiredOption('sourceTarget')
.optionAlias('sourceTarget', 'source')
.defineOption('destTarget')
.optionAlias('destTarget', 'target')
.defineOption('browserSupport')
.target('destTarget', '?.css')
.useSourceText('sourceTarget')
.builder(function (css) {
var prefixer = autoprefixer({
browsers: this._browserSupport || browserslist.defaults
});
try {
return prefixer.process(css).css;
} catch (e) {
throw new Error(e);
}
})
.createTech(); after: require(autoprefixer) = enb-autoprefixer: 8ms The changes. after: module.exports = require('enb/lib/build-flow').create()
.name('css-autoprefixer')
.defineRequiredOption('sourceTarget')
.optionAlias('sourceTarget', 'source')
.defineOption('destTarget')
.optionAlias('destTarget', 'target')
.defineOption('browserSupport')
.target('destTarget', '?.css')
.useSourceText('sourceTarget')
.builder(function (css) {
var autoprefixer = require('autoprefixer-core');
var browserslist = require('browserslist');
var prefixer = autoprefixer({
browsers: this._browserSupport || browserslist.defaults
});
try {
return prefixer.process(css).css;
} catch (e) {
throw new Error(e);
}
})
.createTech(); Now it will only takes a lot of time when we need to build/rebuild |
@sbmaxx So what will be the profit? In you pr |
Faster build if we didn't modify bemhtml files. 80% percentage of builds in If I need just to rebuild css file I don't want to wait 300ms for bemhtml вторник, 11 августа 2015 г. пользователь Sergey Belov написал:
wbr, |
@sbmaxx Are you using So this speed up on |
Why it be slow? Node.js has a good require cache ;) Once module was required in build action it will be cached.
Not in all project :/ Kind of legacy and not frendly infrastructure to run another http-server (one for each dev), change ports, links, etc. |
@arikon, I think that the performance does not suffer. If you write a simple benchmark: require('enb-xjst/techs/bemhtml');
console.time('bemhtml-100');
for (var i = 0; i < 100; ++i) {
require('enb-xjst/techs/bemhtml');
}
console.timeEnd('bemhtml-100'); You can see that speed of building project will suffer for 1ms.
In Before lazy load:
After :
But still long because require If you move require of
|
@sbmaxx I am not against such changes, but I do not like is that it will have to do in each package. Is it critical? Can we solve the problem differently? For example, think about how not to run an assembly via the CLI. |
@blond we're thinking about it, but in 90% of cases we use CLI :/ I did benchmarking for other techs that we're using. The most slow are |
Here's small test script:
And the results:
Requiring of
bemhtml-xjst
takes a lot of time each build. Maybe it's time to refactor it? :) The common pattern for solving issues like this — require dependencies only on build actionThe text was updated successfully, but these errors were encountered: