Skip to content

Commit 7e7d7b3

Browse files
authored
fix elliptic import (#1262)
* fix elliptic import * silence tsc
1 parent 3c0b292 commit 7e7d7b3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@observablehq/inputs": "^0.10.6",
5858
"@observablehq/runtime": "^5.9.4",
5959
"@rollup/plugin-commonjs": "^25.0.7",
60+
"@rollup/plugin-json": "^6.1.0",
6061
"@rollup/plugin-node-resolve": "^15.2.3",
6162
"@rollup/plugin-virtual": "^3.0.2",
6263
"acorn": "^8.11.2",

src/node.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import op from "node:path";
55
import {extname, join} from "node:path/posix";
66
import {pathToFileURL} from "node:url";
77
import commonjs from "@rollup/plugin-commonjs";
8+
import json from "@rollup/plugin-json";
89
import {nodeResolve} from "@rollup/plugin-node-resolve";
910
import virtual from "@rollup/plugin-virtual";
1011
import {packageDirectory} from "pkg-dir";
@@ -101,7 +102,11 @@ async function bundle(
101102
...(isBadCommonJs(input) ? [(virtual as any)({"-": shimCommonJs(input, require)})] : []),
102103
importResolve(input, cacheRoot, packageRoot),
103104
nodeResolve({browser: true, rootDir: packageRoot}),
104-
(commonjs as any)({esmExternals: true}),
105+
(json as any)(),
106+
(commonjs as any)({
107+
esmExternals: true,
108+
requireReturnsDefault: "preferred"
109+
}),
105110
esbuild({
106111
format: "esm",
107112
platform: "browser",
@@ -133,7 +138,7 @@ function importResolve(input: string, cacheRoot: string, packageRoot: string): P
133138
return typeof specifier !== "string" || // AST node?
134139
isNodeBuiltin(specifier) || // node built-in, e.g., "node:fs" or "fs"
135140
isPathImport(specifier) || // relative path, e.g., ./foo.js
136-
/^\w+:/.test(specifier) || // windows file path, https: URL, etc.
141+
/^\0?[\w-]+:/.test(specifier) || // windows file path, https: URL, \x00node-resolve:, etc.
137142
specifier === input // entry point
138143
? null // don’t do any additional resolution
139144
: {id: await resolveNodeImportInternal(cacheRoot, packageRoot, specifier), external: true}; // resolve bare import

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,13 @@
422422
is-reference "1.2.1"
423423
magic-string "^0.30.3"
424424

425+
"@rollup/plugin-json@^6.1.0":
426+
version "6.1.0"
427+
resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-6.1.0.tgz#fbe784e29682e9bb6dee28ea75a1a83702e7b805"
428+
integrity sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==
429+
dependencies:
430+
"@rollup/pluginutils" "^5.1.0"
431+
425432
"@rollup/plugin-node-resolve@^15.2.3":
426433
version "15.2.3"
427434
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz#e5e0b059bd85ca57489492f295ce88c2d4b0daf9"
@@ -439,7 +446,7 @@
439446
resolved "https://registry.yarnpkg.com/@rollup/plugin-virtual/-/plugin-virtual-3.0.2.tgz#17e17eeecb4c9fa1c0a6e72c9e5f66382fddbb82"
440447
integrity sha512-10monEYsBp3scM4/ND4LNH5Rxvh3e/cVeL3jWTgZ2SrQ+BmUoQcopVQvnaMcOnykb1VkxUFuDAN+0FnpTFRy2A==
441448

442-
"@rollup/pluginutils@^5.0.1", "@rollup/pluginutils@^5.0.5":
449+
"@rollup/pluginutils@^5.0.1", "@rollup/pluginutils@^5.0.5", "@rollup/pluginutils@^5.1.0":
443450
version "5.1.0"
444451
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.1.0.tgz#7e53eddc8c7f483a4ad0b94afb1f7f5fd3c771e0"
445452
integrity sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==

0 commit comments

Comments
 (0)