x-atlas-consortia / data-ingest-board

The UI App for HuBMAP and Sennet Data Publishing Dashboard
MIT License
1 stars 0 forks source link

Add '@' path alias for cleaner imports #222

Closed tjmadonna closed 2 months ago

tjmadonna commented 2 months ago

This shouldn't change anything. Path alias imports and relative imports can be used in the same project/file. I had to add the alias to the webpack config as well.

Changes

Example

import { AppProvider } from '@/context/AppContext'
yuanzhou commented 2 months ago

@tjmadonna I've seen usages of the path alias in Nodejs, different from yours:

import { something } from '#some/thing';

The above works corresponding to the imports field specified in package.json:

{
    "imports": {
        "#*": "./src/*"
    }
}

Can you help me understand why you chose @ over #?

tjmadonna commented 2 months ago

It's the convention that Next.js uses.

https://nextjs.org/docs/pages/building-your-application/configuring/absolute-imports-and-module-aliases