less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.04k stars 3.41k forks source link

Can't use package.json property `imports` to import subpath module. #3715

Open YourWildDad opened 2 years ago

YourWildDad commented 2 years ago

My package.json :

{
    ...,
    "imports": {
        "#style/*": "./src/style/*"
    }
    ...
}

when i use less-loader to load less file like:

@import (refrence) "#style/mixins"

i got error like:

'#style/mixins' wasn't found. Tried - .less
      Error in D:\Development\xxx\index.module.less (line 2, column 0)

I think less throws an error before using the FileManager to resolve the file, making it impossible to use the webpack resolver to resolve the real path.

When I change the code to the following, everything works fine:

@import (refrence) "~#style/mixins"

My packages version is:

RUSHIM24 commented 1 year ago

Hello , I am new to open source , I want to work on this issue can you please guide me on how I can get started?

matthew-dean commented 1 year ago

@RUSHIM24 If you want to take a look, great! You'd probably want to look at tracing the code here: https://github.com/less/less.js/blob/master/packages/less/src/less-node/file-manager.js#L62

RUSHIM24 commented 1 year ago

Hello , I found the bug and made the changes in local repository as well as when I ran the test , all test worked fine, My question is, how do I ensure that the error : #style/mixins' wasn't found , is resolved or not?

Cyddharth-Gupta commented 1 year ago

@matthew-dean can I be assigned this issue?