Skip to content

Module lookup in ES6. #88

@franza

Description

@franza

I'm trying to understand the way modules are loaded in ES6. I was googling this question for like half of hour but never found the exact definition. See the example:

import * as smth from 'dir1/dir2/dir3/file'

You can see that it's different from relative path like ./dir1/dir2/dir3/file. I was messing with this in TypeScript + NodeJS and it's lookup strategy is different from the one I used to work with in NodeJS. What I found is that

  1. it will lookup for dir1 which is defined ABOVE the current file.
  2. If it finds dir1 it tries to find dir2/dir3/file there.
  3. if it fails it continues step 1-2 again and so on.

Is my assumption correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions