How to configure import alias

Open
#327 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
32/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript, webpack
Domain
build-system, cli

Research direction

Start with the README section describing aliases and the package.json alias configuration, then compare those instructions with the reported tsconfig.json paths and the failing @Components/MyComponent import. Confirm the supported alias setup and whether the documented configuration produces a resolvable import; done means the behavior or instructions clearly allow that import to resolve.

Written by the indexing model from the issue text.

Description

I wanted to add alias import in an Enact project: i configured the tsconfig.json like bellow:
{ "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", "paths": { "@App/*": ["./src/App/*"], "@Components/*": ["./src/Components/*"], "@Views/*": ["./src/Views/*"] }, }, "include": [ "src", "types" ] }

and i saw in readme that there is alias that can be added to the enact object in package.json:

"alias": { "@App/*": ["./src/App/*"], "@Components/*": ["./src/Components/*"], "@Views/*": ["./src/Views/*"] }

i don't if it's the right way to it or alias import is not available in Enact but when i make import like:
import MyComponent from '@Components/MyComponent
It said can't resolve @Components/MyComponent.

Dominant language
JavaScript
Stars
14
Forks
28
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from enactjs/cli

All issues in enactjs/cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.