Multiple scoped imports via (reference) fail
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17k
- Forks
- 3.4k
- Avg merge
- 7h 42m
- Merged PRs (30d)
- 26
Description
To reproduce:
.foo {
@import (reference) "abc";
.one {
.two(); // defined in abc.less
}
}
in another file
.bar {
@import (reference) "abc";
.three {
.two(); // defined in abc.less
}
}
Current behavior:
The second use of .two() fails with "NameError: .two is undefined in ..."
Expected behavior:
Both references should work.
Environment information:
I don't think the env matters here, but...
lessversion: 3 and 4nodejsversion: 18operating system: Ubuntu 20.04
** Additional **
There is a workaround here by using:
@import (multiple, reference) "abc";
The right behavior seems to me to be that the second reference should work because:
- The first reference is scoped, and therefor abc.less is not actually getting included twice, in the sense that duplicate css is being produced.
- It's a reference, and doesn't generate duplicate code anyway. Why not make the default 'multiple' to avoid the issue I had?
- Treating references in the manner suggested here seems to be the more typical way that compilers treat libraries.
If a change isn't made to the code, it seems like it may be worthwhile to put this info into the documentation somewhere.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction showing two scoped (reference) imports of abc.less, and trace how import scope and duplicate-import handling are resolved. Add a regression test covering both .two() calls, then verify that both references compile successfully without requiring the (multiple, reference) workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100