Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
YourWildDad opened this issue Apr 20, 2022 · 4 comments
Open

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

YourWildDad opened this issue Apr 20, 2022 · 4 comments

Comments

@YourWildDad
Copy link

YourWildDad commented Apr 20, 2022

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:

  • less@4.1.2
  • less-loader@10.2.0
  • webpack@5.68.0
  • enhanced-resolve@5.9.2
@YourWildDad YourWildDad changed the title Can't use package.json imports property to import subpath module. Can't use package.json property imports to import subpath module. Apr 20, 2022
@RUSHIM24
Copy link

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
Copy link
Member

@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
Copy link

RUSHIM24 commented Apr 14, 2023

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
Copy link

@matthew-dean can I be assigned this issue?

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants