less.js icon indicating copy to clipboard operation
less.js copied to clipboard

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

Open YourWildDad opened this issue 2 years ago • 4 comments

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:

YourWildDad avatar Apr 20 '22 08:04 YourWildDad

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?

RUSHIM24 avatar Apr 10 '23 09:04 RUSHIM24

@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

matthew-dean avatar Apr 10 '23 18:04 matthew-dean

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?

RUSHIM24 avatar Apr 14 '23 12:04 RUSHIM24

@matthew-dean can I be assigned this issue?

Cyddharth-Gupta avatar Jul 10 '23 11:07 Cyddharth-Gupta