Skip to content

Issue: svg-components with absolute imports not working #7117

@paul-vd

Description

@paul-vd

Examples bug report

Example name

custom-server-typescript
svg-components
with-absolute-imports

Describe the bug

with the svg-components and absolute import the svg's are not found

[ error ] ./components/cowsay.tsx
Error: Cannot find module 'svg/cat.svg' from '/Users/Projects/Playground/next/components' 

with tslint it does not see .jpg, .svg or any images as paths but instead as modules

Absolute Paths:
Cannot find module 'svg/cat.svg.ts(2307)
Cannot find module 'images/pexels-photo.jpg'.ts(2307)

Relative Paths:
Cannot find module '../assets/svg/cat.svg'.ts(2307)
Cannot find module '../assets/images/pexels-photo.jpg'.ts(2307)

( as i side note i added paths to my tsconfig )

    "paths": {
      "images/*": ["assets/images/*"],
      "svg/*": ["assets/svg/*"]
    },

To Reproduce

https://github.com/PaulPCIO/next.js-issues-svg-absolute-imports-tslint

uncomment lines in components/ImageExamples.tsx

Expected behavior

  1. Expect SVG's to import from absolute paths
  2. Expect tslint to recognise image importations

Screenshots

#issue 1:

import Absolute_CatSVG from 'svg/cat.svg'

image

#issue 2: RESOLVED
image

System information

  • OS: macOS
  • Version of Next.js: 8.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueEasy to fix issues, good for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions