@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
|
@@ -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(${
|
|
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,
|
|
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(
|
|
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(
|
|
103
|
-
: renderImport(
|
|
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
|