Skip to content

Instantly share code, notes, and snippets.

@imranariffin
Last active January 5, 2019 04:17
Show Gist options
  • Save imranariffin/04cf988eae962fe8c0189044b1fb7820 to your computer and use it in GitHub Desktop.
Save imranariffin/04cf988eae962fe8c0189044b1fb7820 to your computer and use it in GitHub Desktop.
Nodejs/Javascript Better import paths aka no more `import from '../../../'`
export default () => 'bar'
{
"name": "bar"
}
.
├── bar
│   ├── deeply
│   │   └── nested
│   │       └── index.js
│   └── package.json
├── foo
│   ├── deeply
│   │   └── nested
│   │       └── index.js
│   └── package.json
├── foobar
│   ├── deeply
│   │   └── nested
│   │       └── index.js
│   └── package.json
├── index.js
└── directory-structure.md
export default () => 'foo'
{
"name": "foo"
}
import foo from '@foo/deeply/nested'
import bar from '@bar/deeply/nested'
export default () => console.log(foo(), bar())
{
"name": "foobar"
}
import foobar from '@foobar/deeply/nested'
foobar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment