Augusto Moura (2019-01-17T00:16:13.000Z)
The module system is not filesystem based, but URL based, that's a lot
of differences between the two, URLs are designed to be unique and be
storage/protocol agnostic in most networks. Others languages are
following similar paths, Go for example even allows you to import
entire github projects directly in source code, Deno (a experimental
Node-like platform, made by the Node former creator) follows the same
direction. In a distributed world, URLs work really good as truly
Global Unique Identifiers

In my opinion there's no better way to uniquely identifying than
comparing it with the actual reference. But if you want a qualified
name so badly, the only way I know is writing them manually, maybe you
could use some external tool to automate this step, something like
jscodeshift or a babel plugin. You could use decorators for runtime
injection metadata (probably a parameterized namespace name)

``` js

const rootNamespace = 'com.foo'

const qualifiedName = (...namespaces) => (clazz) => {
  const namespacesJoined = namespaces.join('.');
  clazz.qualifiedName = rootNamespace + (namespacesJoined ? '.' +
namespacesJoined : '') + '.' + clazz.name;
};

@qualifiedName('domain', 'package')
class Foo {
}

console.assert(Foo.qualifiedName === 'com.foo.domain.package.Foo')
```
augusto.borgesm at gmail.com (2019-01-17T00:18:53.628Z)
The module system is not filesystem based, but URL based, that's a lot
of differences between the two, URLs are designed to be unique and be
storage/protocol agnostic in most networks. Others languages are
following similar paths, Go for example even allows you to import
entire github projects directly in source code, Deno (a experimental
Node-like platform, made by the Node former creator) follows the same
direction. In a distributed world, URLs work really good as truly
Global Unique Identifiers

In my opinion there's no better way to uniquely identifying than
comparing it with the actual reference. But if you want a qualified
name so badly, the only way I know is writing them manually, maybe you
could use some external tool to automate this step, something like
jscodeshift or a babel plugin. You could use decorators for runtime
injection metadata (probably a parameterized namespace name)

``` js

const rootNamespace = 'com.foo'

const qualifiedName = (...namespaces) => (clazz) => {
  const namespacesJoined = namespaces.join('.');
  clazz.qualifiedName = rootNamespace + (namespacesJoined ? '.' + namespacesJoined : '') + '.' + clazz.name;
};

@qualifiedName('domain', 'package')
class Foo {
}

console.assert(Foo.qualifiedName === 'com.foo.domain.package.Foo')
```