Skip to content

Commit

Permalink
[Import Maps] Implement Import Maps v0.5 behind a flag
Browse files Browse the repository at this point in the history
Design doc: https://docs.google.com/document/d/1vFQzbmxg9ilpg8CT_P8roEYcpTfZ06Q5N4J9-ZQqqZo/edit

This CL implements an initial version of Import Maps that supports
- Inline import maps (i.e. no src attribute),
- Layered API/Built-in modules fallback, and
- Basic bare specifier mapping.

The import maps are behind the flag of LayeredAPI.

Bug: 848607
Change-Id: I31efa6f9ce470375a07592f627b525f48dc2d504
  • Loading branch information
hiroshige-g authored and chromium-wpt-export-bot committed Feb 13, 2019
1 parent 2647e1e commit 362ed35
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions import-maps/builtin-empty.tentative.html
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>

<script>
const importMap = `
{
"imports": {
"./resources/log.js?pipe=sub&name=empty": [ "@std/" ],
"./resources/log.js?pipe=sub&name=empty-fallback": [
"@std/",
"./resources/log.js?pipe=sub&name=empty-fallback"
]
}
}
`;

const tests = {
// Arrays of expected results for:
// - <script src type="module">,
// - <script src> (classic script),
// - static import, and
// - dynamic import.

// Discussions about notations are ongoing, e.g.
// https://github.com/tc39/proposal-javascript-standard-library/issues/12
// Currently the tests expects two notations are accepted.
// TODO: Once the discussions converge, update this and related tests.
"std:":
[Result.FETCH_ERROR, Result.FETCH_ERROR, Result.FETCH_ERROR, Result.FETCH_ERROR],
"@std/":
[Result.FETCH_ERROR, Result.PARSE_ERROR, Result.FETCH_ERROR, Result.FETCH_ERROR],

"./resources/log.js?pipe=sub&name=empty":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
"./resources/log.js?pipe=sub&name=empty-fallback":
[Result.URL, Result.URL, Result.URL, Result.URL],
};

doTests(importMap, null, tests);
</script>
<body>

0 comments on commit 362ed35

Please sign in to comment.