Skip to content

Commit 71b5090

Browse files
authored
Merge branch 'main' into mbostock/normalize-file-paths
2 parents 618c5ad + 4721feb commit 71b5090

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Next, `cd` into your new project folder.
209209

210210
Framework’s local development server lets you preview your site in the browser as you make rapid changes. The preview server generates pages on-the-fly: as you edit files in your editor, changes are instantly streamed to your browser.
211211

212-
<div class="tip">You can work offline with the preview server, but you must be connected to the internet to <a href="./javascript/imports">import libraries</a> from npm. In the future, we intend to support self-hosting imported libraries; please upvote <a href="https://github.com/observablehq/framework/issues/20">#20</a> and <a href="https://github.com/observablehq/framework/issues/360">#360</a> if you are interested in this feature.</div>
212+
<div class="tip">You can develop offline, but you must connect to the internet to <a href="./javascript/imports">import new libraries</a> from npm. Framework self-hosts imports: modules are downloaded from npm and stored in a local cache the first time you import them, and are included in <code>dist</code> when you build your project. In the future, we also plan to support importing from <code>node_modules</code>; please upvote <a href="https://github.com/observablehq/framework/issues/360">#360</a> if you are interested in this feature.</div>
213213

214214
To start the preview server using npm:
215215

docs/javascript/imports.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ In addition to resolving versions of directly-imported modules, Observable Frame
108108
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/[email protected]/+esm">
109109
```
110110
111-
<div class="note">We’d also like to download imported modules from the CDN during build, making the built site entirely self-contained; see <a href="https://github.com/observablehq/framework/issues/20">#20</a>. This would further enable subresource integrity hashes; see <a href="https://github.com/observablehq/framework/issues/306">#306</a>.</div>
111+
<div class="note">Framework automatically downloads <code>npm:</code> imports from npm during preview and build, making the built site entirely self-contained. If you prefer not to self-host a module, and instead load it from an external server at runtime, import a full URL instead of using the <code>npm:</code> protocol.</div>
112112
113113
## Implicit imports
114114

docs/routing.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ The resulting output root is:
157157
.
158158
├─ dist
159159
│ ├─ _import
160-
│ │ └─ chart.js
160+
│ │ └─ chart.c79c2048.js
161161
│ ├─ _observablehq
162162
│ │ └─ ... # additional assets for serving the site
163163
│ └─ index.html
164164
└─ ...
165165
```
166166

167-
The import declaration is automatically rewritten during build to point to `./_import/chart.js` instead of `./chart.js`. (In the future [#260](https://github.com/observablehq/framework/issues/260), Observable Framework will add a content hash to the imported module name for cache-breaking.)
167+
The import declaration is automatically rewritten during build to point to `./_import/chart.c79c2048.js` instead of `./chart.js`. The content hash `c79c2048` ensures cache-breaking during deploy, and allows assets to be marked as `cache-control: immutable` to improve performance.
168168

169169
Use a leading slash to denote paths relative to the source root, such as `/chart.js` instead of `./chart.js`. This allows you to use the same path to import a module from anywhere, even in nested folders. Observable Framework always generates relative links so that the generated site can be served under a base path.
170170

@@ -186,18 +186,18 @@ Any files referenced by `FileAttachment` will automatically be copied to the `_f
186186
.
187187
├─ dist
188188
│ ├─ _file
189-
│ │ └─ quakes.csv
189+
│ │ └─ quakes.e5f2eb94.csv
190190
│ ├─ _observablehq
191191
│ │ └─ ... # additional assets for serving the site
192192
│ └─ index.html
193193
└─ ...
194194
```
195195

196-
`FileAttachment` references are automatically rewritten during build; for example, a reference to `quakes.csv` might be replaced with `_file/quakes.csv`. (In the future [#260](https://github.com/observablehq/framework/issues/260), Observable Framework will add a content hash to the attached file name for cache-breaking.) Only the files you reference statically are copied to the output root (`dist`), so nothing extra or unused is included in the built site.
196+
`FileAttachment` references are automatically rewritten during build; for example, a reference to `quakes.csv` might be replaced with `_file/quakes.e5f2eb94.csv`. (As with imports, file names are given a content hash, here `e5f2eb94`, to improve performance.) Only the files you reference statically are copied to the output root (`dist`), so nothing extra or unused is included in the built site.
197197

198198
[Imported modules](#imports) can use `FileAttachment`, too. In this case, the path to the file is _relative to the importing module_ in the same fashion as `import`; this is accomplished by resolving relative paths at runtime with [`import.meta.url`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta).
199199

200-
Some additional assets are automatically promoted to file attachments and copied to `_file`. For example, if you have a `<link rel="stylesheet" href="style.css">` declared statically in a Markdown page, the `style.css` file will be copied to `_file`, too. The HTML elements eligible for file attachments are `audio`, `img`, `link`, `picture`, and `video`.
200+
Some additional assets are automatically promoted to file attachments and copied to `_file`. For example, if you have a `<link rel="stylesheet" href="style.css">` declared statically in a Markdown page, the `style.css` file will be copied to `_file`, too (and the file name given a content hash). The HTML elements eligible for file attachments are `audio`, `img`, `link`, `picture`, and `video`.
201201

202202
## Data loaders
203203

@@ -223,7 +223,7 @@ This will produce the following output root:
223223
.
224224
├─ dist
225225
│ ├─ _file
226-
│ │ └─ quakes.json
226+
│ │ └─ quakes.99da78d9.json
227227
│ ├─ _observablehq
228228
│ │ └─ ... # additional assets for serving the site
229229
│ └─ index.html
@@ -240,7 +240,7 @@ File attachments can be also be pulled from archives. The following archive exte
240240
- `.tar` - for [tarballs](<https://en.wikipedia.org/wiki/Tar_(computing)>)
241241
- `.tar.gz` and `.tgz` - for [compressed tarballs](https://en.wikipedia.org/wiki/Gzip)
242242

243-
For example, say you have a `quakes.zip` archive that includes yearly files for observed earthquakes. If you reference `FileAttachment("quakes/2021.csv")` in code, Observable Framework will pull the `2021.csv` from `quakes.zip`. So this source root:
243+
For example, say you have a `quakes.zip` archive that includes yearly files for observed earthquakes. If you reference `FileAttachment("quakes/2021.csv")`, Framework will pull the `2021.csv` from `quakes.zip`. So this source root:
244244

245245
```ini
246246
.
@@ -257,7 +257,7 @@ Becomes this output:
257257
├─ dist
258258
│ ├─ _file
259259
│ │ └─ quakes
260-
│ │ └─ 2021.csv
260+
│ │ └─ 2021.e5f2eb94.csv
261261
│ ├─ _observablehq
262262
│ │ └─ ... # additional assets for serving the site
263263
│ └─ index.html

0 commit comments

Comments
 (0)