This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 24848 - [imports]: ES6 module loader should be aware modules in HTML Imports
Summary: [imports]: ES6 module loader should be aware modules in HTML Imports
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 23278
  Show dependency treegraph
 
Reported: 2014-02-28 01:41 UTC by Morrita Hajime
Modified: 2015-07-06 08:06 UTC (History)
5 users (show)

See Also:


Attachments

Description Morrita Hajime 2014-02-28 01:41:06 UTC
As ES6 modules going to have a way to define a module using
<script> or <module> tag, such JS modules in an import should be able to
imported from another module in linking document.

import_a.html
<module name="a"></module>

import_b.html
<link rel=import href=import_a.html>
<module>
import _ from "a"; // This should work.
</module>

To make this possible, ES6 loader should aware of HTML Imports and
HTML Imports should publish readiness to its possible clients somehow.

One idea is to let these two standards share some commonplace  where the dependency management coordination happens. Such a place could be HTML, fetch, or somewhere else.
Comment 1 johnjbarton 2014-02-28 01:54:02 UTC
It's not clear that ES6 will even allow 
<module name="a"></module>
in normal HTML.  So far their model is that modules are in files or they are anonymous and not importable.

Within an import,
import "oof" from './oof';
may need some work on name normalization if the meaning is for the module 'oof' to be relative to the HTML import rather than the baseURL of the host document.
Comment 2 Morrita Hajime 2014-02-28 02:13:40 UTC
(In reply to johnjbarton from comment #1)
> It's not clear that ES6 will even allow 
> <module name="a"></module>
> in normal HTML.  So far their model is that modules are in files or they are
> anonymous and not importable.
> 
> Within an import,
> import "oof" from './oof';
> may need some work on name normalization if the meaning is for the module
> 'oof' to be relative to the HTML import rather than the baseURL of the host
> document.

Ah right. There is no way to define module name in plain ES6 module syntax
so <module> + ES6 loader for browser or HTML imports need to define the mapping 
of module names somehow.
Comment 3 Dave Herman 2014-02-28 19:14:23 UTC
Just to be clear:

- <module> is an HTML construct and out of scope for ES6.
- Instead, <module> (as well as the browser's default `System` loader) needs to be spec'ed as a web spec.
- The touch points for ES6 modules and HTML imports include at least the following requirements:
* HTML imports should be able to register ES modules in the system registry.
* While HTML imports want to be as concurrent as possible, the interaction with modules should avoid unnecessary races between multiple imports or imports and the main document deciding where to fetch modules' source from (since they can appear in <module>).

Dave
Comment 4 johnjbarton 2014-02-28 22:06:15 UTC
I think the normal solution here is like:
---
Base.js:
class Base ...

import_a.html:
<module>import {Base} from './Base'; ....</module>

Derived.js:
import {Base} from './Base';
class Derived extends Base { ...

import_b.html
<link rel=import href=import_a.html>
<module>import {Derived} from './Derived'; ....</module>
---

That is, developers use anonymous modules for non-reusable JS related to their HTML, they use HTML-Import for re-usbable HTML, and they use JS-import for reusable JS.
Comment 5 Hayato Ito 2015-07-06 08:06:51 UTC
Moved to https://github.com/w3c/webcomponents/issues/223