Skip to content

Commit

Permalink
Rename top level key: "modules" → "imports"
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Nov 2, 2018
1 parent 1f70cea commit dd79707
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Today, this throws, as such bare specifiers [are explicitly reserved](https://ht

```json
{
"modules": {
"imports": {
"moment": "/node_modules/moment/src/moment.js",
"lodash": "/node_modules/lodash-es/lodash.js"
}
Expand Down Expand Up @@ -164,7 +164,7 @@ As mentioned in the introduction,

```json
{
"modules": {
"imports": {
"moment": "/node_modules/moment/src/moment.js",
"lodash": "/node_modules/lodash-es/lodash.js"
}
Expand Down Expand Up @@ -192,7 +192,7 @@ Because `import:` URLs can be used anywhere, they aren't only applicable to Java

```json
{
"modules": {
"imports": {
"widget": "/node_modules/widget/index.mjs",
"widget-light": "/node_modules/widget/themes/light.css",
"widget-back-button": "/node_modules/widget/assets/back.svg"
Expand Down Expand Up @@ -227,7 +227,7 @@ Import maps do this by giving special meaning to mappings that end with a traili

```json
{
"modules": {
"imports": {
"moment": "/node_modules/moment/src/moment.js",
"moment/": "/node_modules/moment/src/",
"lodash": "/node_modules/lodash-es/lodash.js",
Expand Down Expand Up @@ -259,7 +259,7 @@ As usual, since the import map affects `import:` resolution generally, this pack

```json
{
"modules": {
"imports": {
"widget": "/node_modules/widget/index.mjs",
"widget/": "/node_modules/widget/"
}
Expand Down Expand Up @@ -288,7 +288,7 @@ To provide fallbacks, use an array instead of a string for the right-hand side o

```json
{
"modules": {
"imports": {
"jquery": [
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js",
"/node_modules/jquery/dist/jquery.js"
Expand All @@ -307,7 +307,7 @@ For example, consider the following package name map, which supplies a polyfill

```json
{
"modules": {
"imports": {
"@std/async-local-storage": [
"@std/async-local-storage",
"/node_modules/als-polyfill/index.mjs"
Expand Down Expand Up @@ -340,7 +340,7 @@ and then remapping the polyfill to the built-in module for module-import-map-sup

```json
{
"modules": {
"imports": {
"/node_modules/als-polyfill/index.mjs": [
"@std/async-local-storage",
"/node_modules/als-polyfill/index.mjs"
Expand Down Expand Up @@ -395,7 +395,7 @@ We support this use case in import maps by allowing you to change the meaning of

```json
{
"modules": {
"imports": {
"querystringify": "/node_modules/querystringify/index.js"
},
"scopes": {
Expand All @@ -418,7 +418,7 @@ Scopes "inherit" from each other in an intentionally-simple manner, merging but

```json
{
"modules": {
"imports": {
"a": "/a-1.mjs",
"b": "/b-1.mjs",
"c": "/c-1.mjs"
Expand Down Expand Up @@ -469,7 +469,7 @@ With import maps, you can restrict access by mapping a built-in module to the sp

```json
{
"modules": {
"imports": {
"@std/async-local-storage": "@std/blank"
}
}
Expand All @@ -489,7 +489,7 @@ You can use the scoping feature to restrict access to a built-in module to only

```json
{
"modules": {
"imports": {
"@std/async-local-storage": "@std/blank"
},
"scopes": {
Expand Down Expand Up @@ -518,7 +518,7 @@ It may be desirable to wrap a built-in module, e.g. to instrument it, and then e

```json
{
"modules": {
"imports": {
"@std/async-local-storage": "/js/als-wrapper.mjs"
},
"scopes": {
Expand Down Expand Up @@ -565,7 +565,7 @@ You can install an import map for your application using a `<script>` element, e
```html
<script type="importmap">
{
"modules": { ... },
"imports": { ... },
"scopes": { ... }
}
</script>
Expand Down
12 changes: 6 additions & 6 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A **specifier map** is a map of `import:` URLs to URLs.

An **import map** is a struct with two fields:

- **modules**: a specifier map
- **imports**: a specifier map
- **scopes**: a map of URLs to specifier maps

Getting from JSON to this structure will involve some URL parsing and type validation.
Expand All @@ -42,29 +42,29 @@ Getting from JSON to this structure will involve some URL parsing and type valid

We're looking to do the minimal thing that could work here. As such, I propose the following:

Given two import maps _A_ and _B_, the merged import map is a new import map whose modules are the result of merging _A_'s modules and _B_'s modules, and whose scopes are the result of merging _A_'s scopes and _B_'s scopes. Here, merging two maps means appending their entries to each other, with any conflicting keys from the first map removed.
Given two import maps _A_ and _B_, the merged import map is a new import map whose imports are the result of merging _A_'s imports and _B_'s imports, and whose scopes are the result of merging _A_'s scopes and _B_'s scopes. Here, merging two maps means appending their entries to each other, with any conflicting keys from the first map removed.

Example:

```json
{
"modules": { "a": "1", "b": "2" }
"imports": { "a": "1", "b": "2" }
}
```

+

```json
{
"modules": { "a": "3" }
"imports": { "a": "3" }
}
```

=

```json
{
"modules": { "b": "2", "a": "3" }
"imports": { "b": "2", "a": "3" }
}
```

Expand Down Expand Up @@ -114,7 +114,7 @@ This is also crucial for making import maps' scopes feature work as expected wit
```json
{
"modules": {
"imports": {
"lodash": "/node_modules/lodash-es/lodash.js"
},
"scopes": {
Expand Down

0 comments on commit dd79707

Please sign in to comment.