Import from project root
Invalid mailing list, you should fill issue in Node.js repository. nodejs/node/issues
An HTML attachment was scrubbed... URL: esdiscuss/attachments/20180329/05f7c7a9/attachment
On Thu, Mar 29, 2018 at 2:49 PM, Sebastian Malton <sebastian at malton.name> wrote:
No because this is something that I am proposing as an extension to es import/export
The ModuleSpecifier string of import
is entirely environment-specific,
not covered by the ECMAScript standard at all. From Runtime Semantics:
HostResolveImportedModule ( referencingModule, specifier ):
HostResolveImportedModule is an implementation-defined abstract operation that provides the concrete Module Record subclass instance that corresponds to the ModuleSpecifier String, specifier, occurring within the context of the module represented by the Module Record referencingModule.
Instead of the ECMAScript spec definining it, it's left to environments to
define it appropriately for the environment, since different environments
have different design constraints and criteria. For instance, this part of
the WHAT-WG HTML spec covers using modules on the web (drawing on
various underlying initiatives such as import()
and
import.meta
). (In this initial version, unsurprisingly, module
specifiers are essentially URLs, with the requirement [for now] that
relative URLs must start with /
, ./
, or ../
so that "bare" relative
URLs can be given meaning down-the-line.)
So if you want a special token for "root," that will be an environment-specific request, not something for TC39.
Of course, TC39 could define some syntax (outside the ModuleSpecifier) that says "work from the root" while still leaving it up to the environment what "the root" is, but there's no particular reason to do that rather than leaving it to environments to handle as part of the ModuleSpecifier.
-- T.J. Crowder
global.rootRequire
is quite bad (like user-added globals in general), I'd
just do that gist.github.com/branneman/8048520#gistcomment-2247189,
or use lerna, or use webpack resolvers
2018-03-29 17:37 GMT+02:00 T.J. Crowder <tj.crowder at farsightsoftware.com>:
An HTML attachment was scrubbed... URL: esdiscuss/attachments/20180328/c9321f39/attachment-0001