unimported icon indicating copy to clipboard operation
unimported copied to clipboard

Unable to import images

Open flixyudh opened this issue 2 years ago • 2 comments

This tools awesome to check all my unused files, but i have some import file that used package.json alias name with something like this:

let say i have this structure folder

assets (dir)
  welcome.webp
  splash_screen.png
  package.json
index.js (file)

where package.json inside assets folder has json :

{
    "name": "@images"
}

and my index.js contain some code like this :

const WelcomeImage = require('@images/welcome.webp')

when i run npx unimported --no-cache i got an error

Failed parsing ~/cwd/assets/welcome.webp

is there something wrong with my unimported config?

.unimportedrc.json

{
  "ignorePatterns": [
    "**/node_modules/**",
    "**/*.tests.{js,jsx,ts,tsx}",
    "**/*.test.{js,jsx,ts,tsx}",
    "**/*.spec.{js,jsx,ts,tsx}",
    "**/tests/**",
    "**/__tests__/**",
    "**/*.d.ts"
  ],
  "entry": ["index.js"],
  "aliases": {
    "@images/*": ["assets/", "assets/*"]
  },
  "extensions": [".js", ".jsx", ".ts", ".tsx", ".webp", ".jpg", ".png"],
  "ignoreUnimported": [],
  "ignoreUnused": [
    "react",
    "react-dom",
    "react-native"
  ],
  "ignoreUnresolved": []
}

flixyudh avatar Jun 28 '22 05:06 flixyudh

We can't parse images, and that's what you're trying to import with require('@images/welcome.web').

smeijer avatar Jun 28 '22 16:06 smeijer

will you add this feature @smeijer ?

flixyudh avatar Jun 30 '22 05:06 flixyudh

Closing, see #91

smeijer avatar Mar 02 '23 18:03 smeijer