Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

unresolved imports contains file imports with resourceQuery (e.g. 'filename.ext?query') #113

Closed
dzsodzso63 opened this issue Sep 21, 2022 · 7 comments
Labels

Comments

@dzsodzso63
Copy link

Consider the following import:

import ImgAsComponent from 'img/thing.svg?component';

As no alias or pattern ignore or wildcards apply for unresolved imports, these imports will be reported, and no configuration can help this

@smeijer
Copy link
Owner

smeijer commented Dec 7, 2022

Is that even valid? I'm curious, why would you want to import using a query? What's the use case of that?

Happy to add support if it's indeed a valid import pattern.

@smeijer
Copy link
Owner

smeijer commented May 10, 2023

Eslint simply strips the resource query, we should do the same:

https://github.com/import-js/eslint-plugin-import/blob/328064abc707d3289772a8a29da5783c6dc345f6/resolvers/webpack/index.js#L46-L50

@ahuet67
Copy link

ahuet67 commented Nov 15, 2023

@smeijer some lib recommands to call webpack loader in the code file. And sometimes, there are plugins in the query parameters of the import.

This is my case with this lib : https://github.com/jgranstrom/sass-extract-loader. It causes "unresolved imports".

@ngouy
Copy link

ngouy commented Nov 22, 2023

same issue with "something.service.ts" for example. Which is very valid no?

@AlexJDG
Copy link

AlexJDG commented Jan 3, 2024

This can be resolved using a path transform in .unimportedrc.json:

{
  "pathTransforms": {
    "(.*)\\?(?:.*)$": "$1"
  }
}

It seemingly only works after running npx unimported --clear-cache, though.

@ngouy
Copy link

ngouy commented Feb 2, 2024

I went back to it, bumping to node 20 fixed it??
All good on my end

@smeijer
Copy link
Owner

smeijer commented Mar 10, 2024

This project is being archived. Please check the readme for more info.

@smeijer smeijer closed this as completed Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants