@observablehq/notebook-kit 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.4.0",
8
+ "version": "2.4.1",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",
@@ -20,7 +20,7 @@ function getImportAttributeKey(node) {
20
20
  export function renderObservableImport(source, node, inputs) {
21
21
  if (!inputs.includes("@variable"))
22
22
  inputs.push("@variable");
23
- return `(import(${JSON.stringify(source)}).then((_) => {
23
+ return `(import(${source}).then((_) => {
24
24
  const module = __variable._module._runtime.module(_.default)${"injections" in node ? `.derive([${renderObservableInjections(node)}], __variable._module)` : ""};
25
25
  const outputs = new Map(Array.from(__variable._outputs, (v) => [v._name, v]));${flatMapImportSpecifiers(node, (specifier) => {
26
26
  const i = dedollar(getImportedName(specifier));
@@ -93,16 +93,17 @@ export function rewriteImportDeclarations(output, body, inputs, { resolveImport
93
93
  });
94
94
  const specifiers = [];
95
95
  const imports = [];
96
- for (const [node, source] of declarations) {
96
+ for (const [node, literal] of declarations) {
97
97
  output.delete(node.start, node.end + +(output.input[node.end] === "\n"));
98
98
  specifiers.push(rewriteImportSpecifiers(node));
99
- const value = getStringLiteralValue(source);
99
+ const value = getStringLiteralValue(literal);
100
100
  const resolution = resolveImport(value);
101
+ const source = resolveLocalImports && isLocalImport(resolution)
102
+ ? `new URL(${JSON.stringify(resolution)}, document.baseURI)`
103
+ : JSON.stringify(resolution);
101
104
  imports.push(isObservableImport(node, value)
102
- ? renderObservableImport(resolution, node, inputs)
103
- : renderImport(resolveLocalImports && isLocalImport(resolution)
104
- ? `new URL(${JSON.stringify(resolution)}, document.baseURI)`
105
- : JSON.stringify(resolution), node, output.input));
105
+ ? renderObservableImport(source, node, inputs)
106
+ : renderImport(source, node, output.input));
106
107
  }
107
108
  if (declarations.length > 1) {
108
109
  output.insertLeft(0, `const [${specifiers.join(", ")}] = await Promise.all([${imports.join(", ")}]);\n`); // prettier-ignore
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.4.0",
8
+ "version": "2.4.1",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",