-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
download npm imports; parser & resolver improvements #843
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@@ -8,7 +8,7 @@ const resultsContainer = document.querySelector("#observablehq-search-results"); | |||
const activeClass = "observablehq-link-active"; | |||
let currentValue; | |||
|
|||
const index = await fetch(import.meta.resolve("./minisearch.json")) | |||
const index = await fetch(import.meta.resolve(global.__minisearch)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use the importMetaResolve
Rollup plugin to say import.meta.resolve("observablehq:minisearch.json")
here, but that’s just polish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike /_observablehq/client.js
which changes only when we update framework, the contents of /_observablehq/search.js
change about each time we build the site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit implements import.meta.resolve
resolution so you can now say fetch(import.meta.resolve("observablehq:minisearch.json"))
. 🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great!
} | ||
width: 640, | ||
height: 400, | ||
data: {url: await FileAttachment("gistemp.csv").url(), format: {type: "csv"}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the file url /_file/lib/gistemp.08e51068.csv
is ending in .csv
again, so all is well with both versions of the code.
@@ -22,7 +22,7 @@ | |||
<label id="observablehq-sidebar-close" for="observablehq-sidebar-toggle"></label> | |||
<li class="observablehq-link"><a href="./">Home</a></li> | |||
</ol> | |||
<div id="observablehq-search" data-root="./"><input type="search" placeholder="Search"></div> | |||
<div id="observablehq-search"><input type="search" placeholder="Search"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
import.meta.resolve doesn't seem to work for minisearch.json: ```js
import.meta.resolve("observablehq:minisearch.json");
``` results in:
UPDATE: when a random file exists under the path |
I tested it and it worked fine, so I dunno @Fil. Can you isolate a reproduction and file a bug if it doesn’t work? Thank you. |
filed under #948 |
npm:
imports to a local cache (instead of hot-linking from jsDelivr)npm:
imports to a local cache (e.g., Mermaid plugins)npm:
specifier versions against the local npm cache (for consistency & performance)/_npm/
to jsDelivr during previewnpm:
imports based onFileAttachment
method or file extensionnpm:
imports based on unbound references (e.g.,d3
orPlot
)npm:
stylesheets (e.g., for Leaflet and Observable Inputs)npm:
imports intranspileModule
This also includes some fairly major re-architecting of parsing, transpiling, and rendering. Notes to come.