girder / viime

https://viime.org
Apache License 2.0
8 stars 3 forks source link

Switch relative imports to absolute imports where possible #307

Open waxlamp opened 4 years ago

waxlamp commented 4 years ago

For a given file, when importing a file that isn't "bundled" with it, prefer to use an import like

import { foo } from '@/a/b/c/foo';

rather than

import { foo } from '../../a/b/c/foo';
sgratzl commented 4 years ago

how have you configured your editor, that it still is able to resolve these files? In my case (Visual Studio Code) without any jsconfig.json or tsconfig.json having a path mapping, it is not able to do that.

subdavis commented 4 years ago

@sgratzl what's in your jsconfig? I tried adding one and I still couldn't get these aliases to work.

Here's mine:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": false,
    "baseUrl": "./",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "exclude": ["node_modules", "dist"]
}
waxlamp commented 4 years ago

I use vim, so I don't rely on this editor feature at all (I get the functionality by using plugins like CtrlP).

I am really surprised the modern editors don't handle this, so if that's truly the case, I'll stop tilting at windmills. If someone can definitively determine that this won't work, I'll mark this wontfix and close it.

subdavis commented 4 years ago

I'm in favor of this change from a style perspective. I agree with your motivation. I just want editor support before we make it.

sgratzl commented 4 years ago

modern editors don't handle this

they do with the proper config. e.g. https://github.com/ImageMarkup/isic-challenge-lineup/ tyepscript + vue + mix of absolute and relative imports