PETER Flannery (2017-06-02T16:08:02.000Z)
Currently there isn't a way to import a module using an app root module
specifier.


I.E. `import * as Stuff from 'utils/someUtil.js'`


Relative paths suffices in the simplest applications but not being able to
resolve from the root of the app leads to a complex stack of relative path
entries I.E. `../../..`


One example of where these complex stacks arise is importing source modules from
within test modules where usually tests are defined in a test folder separated
from the source.


Another issue arises when moving a file to another location which then leads to
recalculating the relative path stack.


One idea I have is that each host has a default URL protocol. For now I will
call it **moduleSpecifierDefaultProtocol** that will resolve double front
slashes `//` to the default protocol


In a browser the default protocol already gets resolved and is based on the URL
of the document requested.  I.E.  '//utils/someUtil.js` resolves to
`https://utils/someUtil.js` when `https` is the protocol used in the requesting
 document


Hosts like NodeJS could interpret '**moduleSpecifierDefaultProtocol** to be the
root of the app allowing `import * as Stuff from '//utils/someUtil.js'`.


The other idea I have (and probably needs to be a separate but related solution
proposal) is to have custom alias mappings which would be defined in a place
where the host can find and resolve module specifier aliases I.E. an `.es` file
in the app root containing a json map of aliases. The maps could possibly be
auto generated using build tools when publishing an app.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170602/31912ea0/attachment.html>
flannery.peter at ntlworld.com (2017-06-02T16:29:26.551Z)
Currently there isn't a way to import a module using an app root module
specifier.


I.E. `import * as Stuff from 'utils/someUtil.js'`


Relative paths suffices in the simplest applications but not being able to
resolve from the root of the app leads to a complex stack of relative path
entries I.E. `../../..`


One example of where these complex stacks arise is importing source modules from
within test modules where usually tests are defined in a test folder separated
from the source.


Another issue arises when moving a file to another location which then leads to
recalculating the relative path stack.

The idea I have is to have custom alias mappings which would be defined in a place
where the host can find and resolve module specifier aliases I.E. an `.es` file
in the app root containing a json map of aliases. The maps could possibly be
auto generated using build tools when publishing an app.