less / less/less.js

Imports referenced more than once seem to be parsed multiple times

Open
#2,640 23 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

Hi guys,

I just notice the build for a somehow complex less file was taking about 4s. I did some debug and found that the imports are parsed several times. Even when they were already previously parsed.

I have made a simple change to the import-manager as a proof of concept

https://github.com/royriojas/less.js/commit/b84e7c6a51f3f6221eb31ac3e1639caaa7c1c57f

with that small change the build time was reduced to 1.5s, I guess because in my use case some files: (constants, mixins and others) were included several times from different files

The change I did is very naive, and we can make sure we create a cache for each instance of the less object created.

Also, if we store this cache to a local file in the users filesystem we can reuse it for the next run and this will a build be reduced to just milliseconds. Are there any plans of enabling something like that. Would be really nice to have.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the import-manager and the proof-of-concept commit linked in the issue, then reproduce the reported case of a complex Less file with repeated imports. Compare parsing counts and build times before and after; done means repeated imports are not parsed unnecessarily and the existing behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.