Avalander / yuki

1 stars 0 forks source link

Add `src` to `NODE_PATH` #17

Closed Avalander closed 3 years ago

Avalander commented 5 years ago

Currently we are importing project files with relative paths, which is annoying when we change the location of a file because then we have to update all the relative imports in that file, and nested files requiring modules from src have imports with too many ...

If we start the app with the env variable NODE_PATH=src then we don't need relative imports for the project files and we could for instance import the module in src/randtools.js with require('randtools') from a command module instead of `require('../randtools').

To get this changes to work we need to add NODE_PATH=src to the following scripts in package.json:

Also, to get nice autocomplete in VS Code, we need to create a file jsconfig.json in the root of the project with the following configuration:

{
  "compilerOptions": {
    "baseUrl": "./src"
  },
  "exclude": [
    "node_modules"
  ]
}
arturjzapater commented 3 years ago

I see that this hasn't been done yet. If you want, I could get it done some time this weekend.

Avalander commented 3 years ago

Sure, I might have some local branch somewhere with part of the changes but it isn't much work anyway.