@ricsam/isolate 0.1.7 → 0.1.10

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.
@@ -103,7 +103,9 @@ function isNodeBuiltin(source) {
103
103
  return nodeBuiltins.has(topLevel);
104
104
  }
105
105
  var NODE_BUILTIN_SHIM_PREFIX = "\x00node-builtin-shim:";
106
+ var BROWSER_EMPTY_MODULE_PREFIX = "\x00browser-empty:";
106
107
  var HOST_ASYNC_WRAP_PROVIDERS_JSON = JSON.stringify(import_node_async_hooks.asyncWrapProviders);
108
+ var BROWSER_MAPPING_EXTENSIONS = [".tsx", ".jsx", ".ts", ".mjs", ".js", ".cjs", ".json"];
107
109
  function getNodeBuiltinShimCode(source) {
108
110
  if (source === "ws" || source === "node:ws") {
109
111
  return `
@@ -541,6 +543,130 @@ function pickImportTarget(value, wildcardMatch) {
541
543
  }
542
544
  return null;
543
545
  }
546
+ var browserMappingsByPackageRoot = new Map;
547
+ function packageBrowserMappingsPlugin() {
548
+ return {
549
+ name: "package-browser-mappings",
550
+ resolveId(source, importer) {
551
+ if (!importer || importer.startsWith("\x00")) {
552
+ return null;
553
+ }
554
+ const browserMappings = getBrowserMappingsForImporter(importer);
555
+ if (!browserMappings) {
556
+ return null;
557
+ }
558
+ const mappedTarget = resolveBrowserMapping(source, importer, browserMappings);
559
+ if (mappedTarget === undefined) {
560
+ return null;
561
+ }
562
+ if (mappedTarget === false) {
563
+ return `${BROWSER_EMPTY_MODULE_PREFIX}${browserMappings.packageRoot}\x00${source}`;
564
+ }
565
+ if (import_resolve.isBareSpecifier(mappedTarget) || mappedTarget.startsWith("node:")) {
566
+ return this.resolve(mappedTarget, importer, { skipSelf: true }).then((resolved) => resolved ?? { id: mappedTarget });
567
+ }
568
+ return mappedTarget;
569
+ },
570
+ load(id) {
571
+ if (id.startsWith(BROWSER_EMPTY_MODULE_PREFIX)) {
572
+ return `export default {};
573
+ `;
574
+ }
575
+ return null;
576
+ }
577
+ };
578
+ }
579
+ function getBrowserMappingsForImporter(importer) {
580
+ const packageJsonPath = findNearestPackageJsonPath(importer);
581
+ if (!packageJsonPath) {
582
+ return null;
583
+ }
584
+ const packageRoot = import_node_path.default.dirname(packageJsonPath);
585
+ let cachedMappings = browserMappingsByPackageRoot.get(packageRoot);
586
+ if (cachedMappings === undefined) {
587
+ try {
588
+ const packageJson = JSON.parse(import_node_fs.default.readFileSync(packageJsonPath, "utf-8"));
589
+ const browserField = packageJson.browser;
590
+ cachedMappings = typeof browserField === "object" && browserField !== null && !Array.isArray(browserField) ? Object.fromEntries(Object.entries(browserField).filter((entry) => typeof entry[1] === "string" || entry[1] === false)) : null;
591
+ } catch {
592
+ cachedMappings = null;
593
+ }
594
+ browserMappingsByPackageRoot.set(packageRoot, cachedMappings);
595
+ }
596
+ if (!cachedMappings) {
597
+ return null;
598
+ }
599
+ return { packageRoot, mappings: cachedMappings };
600
+ }
601
+ function resolveBrowserMapping(source, importer, browserMappings) {
602
+ const keysToTry = [];
603
+ if (import_resolve.isBareSpecifier(source) || source.startsWith("node:")) {
604
+ keysToTry.push(source);
605
+ if (source.startsWith("node:")) {
606
+ keysToTry.push(source.slice(5));
607
+ }
608
+ } else {
609
+ const importerDir = import_node_path.default.dirname(importer);
610
+ const unresolvedTarget = source.startsWith("/") ? source : import_node_path.default.resolve(importerDir, source);
611
+ if (unresolvedTarget !== browserMappings.packageRoot && !unresolvedTarget.startsWith(browserMappings.packageRoot + import_node_path.default.sep)) {
612
+ return;
613
+ }
614
+ keysToTry.push(`./${toPosixPath(import_node_path.default.relative(browserMappings.packageRoot, unresolvedTarget))}`);
615
+ const resolvedTarget = import_resolve.resolveFilePath(unresolvedTarget);
616
+ if (resolvedTarget) {
617
+ keysToTry.push(`./${toPosixPath(import_node_path.default.relative(browserMappings.packageRoot, resolvedTarget))}`);
618
+ }
619
+ }
620
+ for (const key of keysToTry) {
621
+ const mappedTarget = browserMappings.mappings[key];
622
+ if (mappedTarget === undefined) {
623
+ continue;
624
+ }
625
+ if (mappedTarget === false) {
626
+ return false;
627
+ }
628
+ if (import_resolve.isBareSpecifier(mappedTarget) || mappedTarget.startsWith("node:")) {
629
+ return mappedTarget;
630
+ }
631
+ const absoluteTarget = mappedTarget.startsWith("/") ? mappedTarget : import_node_path.default.resolve(browserMappings.packageRoot, mappedTarget);
632
+ return resolveBrowserMappingTargetPath(absoluteTarget) ?? absoluteTarget;
633
+ }
634
+ return;
635
+ }
636
+ function findNearestPackageJsonPath(filePath) {
637
+ let currentDir = import_node_path.default.dirname(filePath);
638
+ while (true) {
639
+ const packageJsonPath = import_node_path.default.join(currentDir, "package.json");
640
+ if (import_node_fs.default.existsSync(packageJsonPath)) {
641
+ return packageJsonPath;
642
+ }
643
+ const parentDir = import_node_path.default.dirname(currentDir);
644
+ if (parentDir === currentDir) {
645
+ return null;
646
+ }
647
+ currentDir = parentDir;
648
+ }
649
+ }
650
+ function toPosixPath(filePath) {
651
+ return filePath.split(import_node_path.default.sep).join("/");
652
+ }
653
+ function resolveBrowserMappingTargetPath(basePath) {
654
+ const resolved = import_resolve.resolveFilePath(basePath);
655
+ if (resolved) {
656
+ return resolved;
657
+ }
658
+ if (import_node_path.default.extname(basePath) === ".browser") {
659
+ for (const extension of BROWSER_MAPPING_EXTENSIONS) {
660
+ const candidate = `${basePath}${extension}`;
661
+ try {
662
+ if (import_node_fs.default.statSync(candidate).isFile()) {
663
+ return candidate;
664
+ }
665
+ } catch {}
666
+ }
667
+ }
668
+ return null;
669
+ }
544
670
  function getCommonJsNamedExports(specifier, rootDir) {
545
671
  const resolvedHostPath = resolvePackageImportPath(specifier, rootDir);
546
672
  if (!resolvedHostPath) {
@@ -651,6 +777,7 @@ async function doBundleSpecifier(specifier, rootDir) {
651
777
  plugins: [
652
778
  packageEntryWrapperPlugin(specifier, namedExports),
653
779
  externalizeDepsPlugin(packageName),
780
+ packageBrowserMappingsPlugin(),
654
781
  nodeResolve({
655
782
  rootDir,
656
783
  browser: false,
@@ -781,4 +908,4 @@ function clearBundleCache() {
781
908
  bundleCache.clear();
782
909
  }
783
910
 
784
- //# debugId=B044D886D7245FA164756E2164756E21
911
+ //# debugId=18A8EE3C3887536664756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/internal/module-loader/bundle.ts"],
4
4
  "sourcesContent": [
5
- "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { asyncWrapProviders as hostAsyncWrapProviders } from \"node:async_hooks\";\nimport { builtinModules, createRequire } from \"node:module\";\nimport { rollup, type Plugin } from \"rollup\";\nimport * as nodeResolveModule from \"@rollup/plugin-node-resolve\";\nimport * as commonjsModule from \"@rollup/plugin-commonjs\";\nimport * as jsonModule from \"@rollup/plugin-json\";\nimport * as replaceModule from \"@rollup/plugin-replace\";\nimport { detectFormat, parseSpecifier } from \"./resolve.cjs\";\nimport { processTypeScript, isTypeScriptFile } from \"./strip-types.cjs\";\nimport type { RollupCommonJSOptions } from \"@rollup/plugin-commonjs\";\nimport type { RollupJsonOptions } from \"@rollup/plugin-json\";\nimport type { RollupReplaceOptions } from \"@rollup/plugin-replace\";\n\n// Handle CJS default exports\nconst nodeResolve = ((nodeResolveModule as any).default ||\n nodeResolveModule) as (typeof nodeResolveModule)[\"nodeResolve\"];\nconst commonjs = ((commonjsModule as any).default || commonjsModule) as (\n options?: RollupCommonJSOptions\n) => Plugin;\nconst json = ((jsonModule as any).default || jsonModule) as (\n options?: RollupJsonOptions\n) => Plugin;\nconst replace = ((replaceModule as any).default || replaceModule) as (\n options?: RollupReplaceOptions\n) => Plugin;\n\nconst commonjsInteropOptions = {\n // External package imports are resolved by later loader calls as ESM bundles,\n // so CommonJS requires need ESM-aware interop instead of default-import assumptions.\n esmExternals: true,\n requireReturnsDefault: \"auto\",\n} satisfies RollupCommonJSOptions;\n\nconst PACKAGE_ENTRY_WRAPPER_PREFIX = \"\\0package-entry-wrapper:\";\nconst INVALID_FUNCTION_EXPORT_NAMES = new Set([\n \"arguments\",\n \"caller\",\n \"length\",\n \"name\",\n \"prototype\",\n]);\n\n/**\n * Set of Node.js built-in module names (e.g. \"fs\", \"path\", \"crypto\").\n */\nconst nodeBuiltins = new Set(builtinModules);\n\n/**\n * Check if a specifier refers to a Node.js built-in module.\n * Handles bare names (\"fs\"), subpaths (\"fs/promises\"), and node: prefix (\"node:fs\").\n */\nfunction isNodeBuiltin(source: string): boolean {\n const name = source.startsWith(\"node:\") ? source.slice(5) : source;\n const topLevel = name.split(\"/\")[0]!;\n return nodeBuiltins.has(topLevel);\n}\n\nconst NODE_BUILTIN_SHIM_PREFIX = \"\\0node-builtin-shim:\";\nconst HOST_ASYNC_WRAP_PROVIDERS_JSON = JSON.stringify(hostAsyncWrapProviders);\n\nexport function getNodeBuiltinShimCode(source: string): string {\n if (source === \"ws\" || source === \"node:ws\") {\n return `\nconst WebSocketShim = globalThis.WebSocket;\n\nif (!WebSocketShim) {\n throw new Error(\"The isolate runtime does not provide a global WebSocket implementation.\");\n}\n\nexport { WebSocketShim as WebSocket };\nexport default WebSocketShim;\n`;\n }\n\n if (source === \"async_hooks\" || source === \"node:async_hooks\") {\n return `\nconst AsyncContextShim = globalThis.AsyncContext;\nconst asyncInternals = globalThis.__isolateAsyncContextInternals;\n\nif (\n !AsyncContextShim\n || !asyncInternals?.AsyncContextFrame\n || typeof asyncInternals.createResource !== \"function\"\n || typeof asyncInternals.runWithResource !== \"function\"\n || typeof asyncInternals.destroyResource !== \"function\"\n || typeof asyncInternals.enableHook !== \"function\"\n || typeof asyncInternals.disableHook !== \"function\"\n) {\n throw new Error(\n \"node:async_hooks requires AsyncContext support in the isolate engine.\"\n );\n}\n\nconst { AsyncContextFrame } = asyncInternals;\nconst NO_STORE = Symbol(\"AsyncLocalStorage.noStore\");\nconst asyncWrapProviders = Object.assign(\n Object.create(null),\n ${HOST_ASYNC_WRAP_PROVIDERS_JSON},\n);\n\nfunction validateHookCallback(name, value) {\n if (value !== undefined && typeof value !== \"function\") {\n throw new TypeError(\"hook.\" + name + \" must be a function\");\n }\n}\n\nclass AsyncHook {\n #callbacks;\n #enabled;\n\n constructor(callbacks) {\n this.#callbacks = callbacks;\n this.#enabled = false;\n }\n\n enable() {\n if (!this.#enabled) {\n this.#enabled = true;\n asyncInternals.enableHook(this, this.#callbacks);\n }\n return this;\n }\n\n disable() {\n if (this.#enabled) {\n this.#enabled = false;\n asyncInternals.disableHook(this);\n }\n return this;\n }\n}\n\nfunction createHook(callbacks) {\n const { init, before, after, destroy, promiseResolve } = callbacks;\n\n validateHookCallback(\"init\", init);\n validateHookCallback(\"before\", before);\n validateHookCallback(\"after\", after);\n validateHookCallback(\"destroy\", destroy);\n validateHookCallback(\"promiseResolve\", promiseResolve);\n\n return new AsyncHook({\n init,\n before,\n after,\n destroy,\n promiseResolve,\n });\n}\n\nfunction executionAsyncId() {\n return asyncInternals.executionAsyncId();\n}\n\nfunction triggerAsyncId() {\n return asyncInternals.triggerAsyncId();\n}\n\nfunction executionAsyncResource() {\n return asyncInternals.executionAsyncResource();\n}\n\nclass AsyncResource {\n #snapshot;\n #resourceState;\n\n constructor(type, options = {}) {\n const normalizedOptions =\n options && typeof options === \"object\" ? options : {};\n\n this.#snapshot = new AsyncContextShim.Snapshot();\n this.#resourceState = asyncInternals.createResource(\n String(type),\n this,\n {\n triggerAsyncId: normalizedOptions.triggerAsyncId,\n },\n );\n }\n\n runInAsyncScope(fn, thisArg, ...args) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"AsyncResource.runInAsyncScope requires a function\");\n }\n return this.#snapshot.run(\n () => asyncInternals.runWithResource(\n this.#resourceState,\n fn,\n thisArg,\n args,\n ),\n );\n }\n\n bind(fn, thisArg) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"AsyncResource.bind requires a function\");\n }\n const resource = this;\n return function bound(...args) {\n return resource.runInAsyncScope(\n fn,\n thisArg === undefined ? this : thisArg,\n ...args,\n );\n };\n }\n\n emitDestroy() {\n if (!asyncInternals.destroyResource(this.#resourceState)) {\n throw new Error(\"AsyncResource.emitDestroy() must only be called once\");\n }\n return this;\n }\n\n asyncId() {\n return this.#resourceState.asyncId;\n }\n\n triggerAsyncId() {\n return this.#resourceState.triggerAsyncId;\n }\n\n static bind(fn, type, thisArg) {\n return new AsyncResource(type).bind(fn, thisArg);\n }\n}\n\nclass AsyncLocalStorage {\n #variable;\n #defaultValue;\n #token;\n #disabled;\n\n constructor(options = {}) {\n const normalizedOptions =\n options && typeof options === \"object\" ? options : {};\n\n this.#defaultValue = normalizedOptions.defaultValue;\n this.#token = Symbol(\"AsyncLocalStorage.token\");\n this.#disabled = false;\n this.#variable = new AsyncContextShim.Variable({\n defaultValue: NO_STORE,\n name: normalizedOptions.name,\n });\n }\n\n get name() {\n return this.#variable.name;\n }\n\n disable() {\n this.#token = Symbol(\"AsyncLocalStorage.token\");\n this.#disabled = true;\n AsyncContextFrame.disable(this.#variable);\n }\n\n enterWith(store) {\n this.#disabled = false;\n AsyncContextFrame.set(\n new AsyncContextFrame(this.#variable, {\n token: this.#token,\n hasValue: true,\n store,\n }),\n );\n }\n\n run(store, callback, ...args) {\n if (typeof callback !== \"function\") {\n throw new TypeError(\"AsyncLocalStorage.run requires a function\");\n }\n this.#disabled = false;\n return this.#variable.run(\n {\n token: this.#token,\n hasValue: true,\n store,\n },\n callback,\n ...args,\n );\n }\n\n exit(callback, ...args) {\n if (typeof callback !== \"function\") {\n throw new TypeError(\"AsyncLocalStorage.exit requires a function\");\n }\n return this.#variable.run(\n {\n token: this.#token,\n hasValue: false,\n store: undefined,\n },\n callback,\n ...args,\n );\n }\n\n getStore() {\n const entry = this.#variable.get();\n if (entry === NO_STORE) {\n return this.#disabled ? undefined : this.#defaultValue;\n }\n if (!entry || entry.token !== this.#token) {\n return undefined;\n }\n if (!entry.hasValue) {\n return undefined;\n }\n return entry.store;\n }\n\n static bind(fn) {\n return AsyncResource.bind(fn, \"AsyncLocalStorage.bind\");\n }\n\n static snapshot() {\n const snapshot = new AsyncContextShim.Snapshot();\n return function runInAsyncScope(fn, ...args) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"AsyncLocalStorage.snapshot requires a function\");\n }\n return snapshot.run(fn, ...args);\n };\n }\n}\n\nexport {\n AsyncLocalStorage,\n AsyncResource,\n asyncWrapProviders,\n createHook,\n executionAsyncId,\n executionAsyncResource,\n triggerAsyncId,\n};\nexport default {\n AsyncLocalStorage,\n AsyncResource,\n asyncWrapProviders,\n createHook,\n executionAsyncId,\n executionAsyncResource,\n triggerAsyncId,\n};\n`;\n }\n\n return \"export default {};\\n\";\n}\n\n/**\n * Rollup plugin that provides empty shims for Node.js built-in modules.\n * Place after nodeResolve — acts as a catch-all for builtins that the\n * package's browser field didn't map to false.\n */\nfunction shimNodeBuiltinsPlugin(): Plugin {\n return {\n name: \"shim-node-builtins\",\n resolveId(source) {\n if (isNodeBuiltin(source)) {\n return { id: `${NODE_BUILTIN_SHIM_PREFIX}${source}`, moduleSideEffects: false };\n }\n return null;\n },\n load(id) {\n if (id.startsWith(NODE_BUILTIN_SHIM_PREFIX)) {\n return getNodeBuiltinShimCode(id.slice(NODE_BUILTIN_SHIM_PREFIX.length));\n }\n return null;\n },\n };\n}\n\nfunction isValidEsmIdentifier(name: string): boolean {\n return /^[$A-Z_a-z][$\\w]*$/.test(name);\n}\n\nfunction resolvePackageImportPath(specifier: string, rootDir: string): string | null {\n const resolver = createRequire(path.join(rootDir, \"__isolate_module_loader__.js\"));\n\n let resolvedRequirePath: string;\n try {\n resolvedRequirePath = resolver.resolve(specifier);\n } catch {\n return null;\n }\n\n const { packageName, subpath } = parseSpecifier(specifier);\n const packageJsonPath = findPackageJsonPath(resolvedRequirePath, packageName);\n if (!packageJsonPath) {\n return resolvedRequirePath;\n }\n\n let packageJson: Record<string, unknown>;\n try {\n packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\")) as Record<string, unknown>;\n } catch {\n return resolvedRequirePath;\n }\n\n const packageRoot = path.dirname(packageJsonPath);\n const exportPath = resolveImportEntryFromPackageJson(packageJson, subpath);\n\n if (exportPath) {\n return path.resolve(packageRoot, exportPath);\n }\n\n if (!subpath) {\n const moduleEntry = packageJson.module;\n if (typeof moduleEntry === \"string\") {\n return path.resolve(packageRoot, moduleEntry);\n }\n\n const browserEntry = packageJson.browser;\n if (typeof browserEntry === \"string\") {\n return path.resolve(packageRoot, browserEntry);\n }\n }\n\n return resolvedRequirePath;\n}\n\nfunction findPackageJsonPath(resolvedPath: string, packageName: string): string | null {\n let currentDir = path.dirname(resolvedPath);\n let matchedPackageJsonPath: string | null = null;\n\n while (true) {\n const packageJsonPath = path.join(currentDir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\")) as { name?: string };\n if (packageJson.name === packageName) {\n // Keep walking upward: published packages often include nested\n // dist/cjs or dist/mjs package.json files with the same name, but the\n // real package root higher up contains the export map we need.\n matchedPackageJsonPath = packageJsonPath;\n }\n } catch {\n // Keep walking upward if a parent package.json is malformed.\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return matchedPackageJsonPath;\n }\n currentDir = parentDir;\n }\n}\n\nfunction resolveImportEntryFromPackageJson(\n packageJson: Record<string, unknown>,\n subpath: string\n): string | null {\n const exportsField = packageJson.exports;\n if (exportsField === undefined) {\n return null;\n }\n\n const exportKey = subpath ? `.${subpath}` : \".\";\n\n if (isConditionalExportsObject(exportsField)) {\n if (exportKey !== \".\") {\n return null;\n }\n return pickImportTarget(exportsField);\n }\n\n if (typeof exportsField === \"object\" && exportsField !== null && !Array.isArray(exportsField)) {\n const exportsRecord = exportsField as Record<string, unknown>;\n const directTarget = exportsRecord[exportKey];\n if (directTarget !== undefined) {\n return pickImportTarget(directTarget);\n }\n\n for (const [pattern, target] of Object.entries(exportsRecord)) {\n if (!pattern.includes(\"*\")) {\n continue;\n }\n\n const starIndex = pattern.indexOf(\"*\");\n const prefix = pattern.slice(0, starIndex);\n const suffix = pattern.slice(starIndex + 1);\n\n if (!exportKey.startsWith(prefix) || !exportKey.endsWith(suffix)) {\n continue;\n }\n\n const wildcardMatch = exportKey.slice(\n prefix.length,\n suffix.length > 0 ? -suffix.length : undefined,\n );\n\n return pickImportTarget(target, wildcardMatch);\n }\n\n return null;\n }\n\n return exportKey === \".\" ? pickImportTarget(exportsField) : null;\n}\n\nfunction isConditionalExportsObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\"\n && value !== null\n && !Array.isArray(value)\n && Object.keys(value).every((key) => !key.startsWith(\".\"));\n}\n\nfunction pickImportTarget(value: unknown, wildcardMatch?: string): string | null {\n if (typeof value === \"string\") {\n return wildcardMatch === undefined ? value : value.replaceAll(\"*\", wildcardMatch);\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n const target = pickImportTarget(item, wildcardMatch);\n if (target) {\n return target;\n }\n }\n return null;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n\n const record = value as Record<string, unknown>;\n\n for (const key of [\"workerd\", \"worker\", \"edge-light\", \"import\", \"module\", \"default\", \"browser\"]) {\n if (key in record) {\n const target = pickImportTarget(record[key], wildcardMatch);\n if (target) {\n return target;\n }\n }\n }\n\n for (const nestedValue of Object.values(record)) {\n const target = pickImportTarget(nestedValue, wildcardMatch);\n if (target) {\n return target;\n }\n }\n\n return null;\n}\n\nfunction getCommonJsNamedExports(specifier: string, rootDir: string): string[] {\n const resolvedHostPath = resolvePackageImportPath(specifier, rootDir);\n if (!resolvedHostPath) {\n return [];\n }\n\n let code: string;\n try {\n code = fs.readFileSync(resolvedHostPath, \"utf-8\");\n } catch {\n return [];\n }\n\n if (detectFormat(resolvedHostPath, code) !== \"cjs\") {\n return [];\n }\n\n let moduleExports: unknown;\n try {\n moduleExports = createRequire(resolvedHostPath)(resolvedHostPath);\n } catch {\n return [];\n }\n\n if (moduleExports == null || (typeof moduleExports !== \"object\" && typeof moduleExports !== \"function\")) {\n return [];\n }\n\n const names = new Set([\n ...Object.keys(moduleExports),\n ...Object.getOwnPropertyNames(moduleExports),\n ]);\n\n names.delete(\"default\");\n names.delete(\"__esModule\");\n\n if (typeof moduleExports === \"function\") {\n for (const name of INVALID_FUNCTION_EXPORT_NAMES) {\n names.delete(name);\n }\n }\n\n return [...names].filter(isValidEsmIdentifier).sort();\n}\n\nfunction packageEntryWrapperPlugin(specifier: string, namedExports: string[]): Plugin {\n const wrapperId = `${PACKAGE_ENTRY_WRAPPER_PREFIX}${specifier}`;\n\n return {\n name: \"package-entry-wrapper\",\n resolveId(source) {\n if (source === wrapperId) {\n return wrapperId;\n }\n return null;\n },\n load(id) {\n if (id !== wrapperId) {\n return null;\n }\n\n const namedExportLines = namedExports.map(\n (name) => `export const ${name} = __packageDefault.${name};`\n );\n\n return [\n `import __packageDefault from ${JSON.stringify(specifier)};`,\n \"export default __packageDefault;\",\n ...namedExportLines,\n ].join(\"\\n\");\n },\n };\n}\n\n/**\n * Cache for bundled npm packages. Key includes specifier + resolution root.\n */\nconst bundleCache = new Map<string, { code: string }>();\n\n/**\n * In-flight bundle promises to avoid duplicate concurrent bundles.\n */\nconst bundlesInFlight = new Map<string, Promise<{ code: string }>>();\n\n/**\n * Create a Rollup plugin that externalizes all bare specifiers that don't\n * belong to the current package. Internal files of the package are inlined;\n * other npm packages remain as import statements.\n */\nfunction externalizeDepsPlugin(currentPackageName: string): Plugin {\n return {\n name: \"externalize-deps\",\n resolveId(source, importer) {\n // Don't externalize the entry point\n if (!importer) return null;\n\n // Don't externalize relative imports (internal to the package)\n if (source.startsWith(\".\") || source.startsWith(\"/\")) return null;\n\n // Keep package-private imports inside the current bundle so Rollup can\n // resolve them through the importing package's `imports` map.\n if (source.startsWith(\"#\")) return null;\n\n // Don't externalize Node.js builtins — let nodeResolve handle them\n // via the package's browser field (e.g. \"fs\": false → empty module)\n if (isNodeBuiltin(source)) return null;\n\n // Check if this is a different npm package\n const { packageName } = parseSpecifier(source);\n if (packageName !== currentPackageName) {\n return { id: source, external: true };\n }\n\n // Same package — let Rollup resolve it normally\n return null;\n },\n };\n}\n\n/**\n * Bundle a bare specifier (npm package) using Rollup.\n *\n * Each unique bare specifier gets its own bundle with:\n * - node-resolve with worker/server-safe export conditions\n * - commonjs conversion\n * - json support\n * - process.env.NODE_ENV replacement\n * - External deps (other npm packages) left as import statements\n *\n * Results are cached permanently (npm packages are static).\n */\nexport async function bundleSpecifier(\n specifier: string,\n rootDir: string\n): Promise<{ code: string }> {\n const cacheKey = `${specifier}\\0${rootDir}`;\n\n // Check cache\n const cached = bundleCache.get(cacheKey);\n if (cached) return cached;\n\n // Check in-flight\n const inFlight = bundlesInFlight.get(cacheKey);\n if (inFlight) return inFlight;\n\n const promise = doBundleSpecifier(specifier, rootDir);\n bundlesInFlight.set(cacheKey, promise);\n\n try {\n const result = await promise;\n bundleCache.set(cacheKey, result);\n return result;\n } finally {\n bundlesInFlight.delete(cacheKey);\n }\n}\n\nasync function doBundleSpecifier(\n specifier: string,\n rootDir: string\n): Promise<{ code: string }> {\n const { packageName } = parseSpecifier(specifier);\n const namedExports = getCommonJsNamedExports(specifier, rootDir);\n const input = namedExports.length > 0\n ? `${PACKAGE_ENTRY_WRAPPER_PREFIX}${specifier}`\n : specifier;\n\n const bundle = await rollup({\n input,\n // Disable tree-shaking: we're creating a virtual module that must faithfully\n // expose all package exports. We can't predict which ones user code will import.\n // Without this, exports like AWS SDK's ConverseStreamOutput (a namespace with\n // a visit() helper that nothing inside the bundle references) get dropped.\n treeshake: false,\n plugins: [\n packageEntryWrapperPlugin(specifier, namedExports),\n externalizeDepsPlugin(packageName),\n nodeResolve({\n rootDir,\n browser: false,\n exportConditions: [\"workerd\", \"worker\", \"edge-light\"],\n }),\n shimNodeBuiltinsPlugin(),\n commonjs(commonjsInteropOptions),\n json(),\n replace({\n preventAssignment: true,\n values: { \"process.env.NODE_ENV\": JSON.stringify(\"development\") },\n }),\n ],\n onwarn: (warning, warn) => {\n if (warning.code === \"CIRCULAR_DEPENDENCY\") return;\n if (warning.code === \"THIS_IS_UNDEFINED\") return;\n if (warning.code === \"UNUSED_EXTERNAL_IMPORT\") return;\n if (warning.code === \"EMPTY_BUNDLE\") return;\n // Suppress warnings about named imports from shimmed Node.js builtins\n if (warning.code === \"MISSING_EXPORT\" && warning.exporter?.startsWith(NODE_BUILTIN_SHIM_PREFIX)) return;\n warn(warning);\n },\n });\n\n const { output } = await bundle.generate({\n format: \"es\",\n sourcemap: \"inline\",\n inlineDynamicImports: true,\n });\n await bundle.close();\n\n const code = output[0]!.code;\n return { code };\n}\n\n/**\n * Create a Rollup plugin that externalizes ALL bare specifiers.\n * Used for module aliases where the host file's relative imports are bundled\n * but npm package dependencies are left as external imports.\n */\nfunction externalizeAllBareSpecifiersPlugin(): Plugin {\n return {\n name: \"externalize-all-bare-specifiers\",\n resolveId(source, importer) {\n if (!importer) return null;\n if (source.startsWith(\".\") || source.startsWith(\"/\")) return null;\n if (source.startsWith(\"#\")) return null;\n // Don't externalize Node.js builtins — let nodeResolve/shim handle them\n if (isNodeBuiltin(source)) return null;\n return { id: source, external: true };\n },\n };\n}\n\n/**\n * Create a Rollup transform plugin that strips TypeScript types.\n */\nfunction stripTypeScriptPlugin(): Plugin {\n return {\n name: \"strip-typescript\",\n transform(code, id) {\n if (isTypeScriptFile(id)) {\n return { code: processTypeScript(code, id), map: null };\n }\n return null;\n },\n };\n}\n\nconst TS_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".cts\"];\n\n/**\n * Bundle a host file using Rollup, inlining its relative imports.\n *\n * - Uses the host file path as Rollup input\n * - Externalizes ALL bare specifiers (npm packages)\n * - Strips TypeScript via processTypeScript\n * - Shares the bundleCache/bundlesInFlight (no key collision since file paths start with `/`)\n *\n * Results are cached permanently.\n */\nexport async function bundleHostFile(\n hostFilePath: string,\n): Promise<{ code: string }> {\n const cached = bundleCache.get(hostFilePath);\n if (cached) return cached;\n\n const inFlight = bundlesInFlight.get(hostFilePath);\n if (inFlight) return inFlight;\n\n const promise = doBundleHostFile(hostFilePath);\n bundlesInFlight.set(hostFilePath, promise);\n\n try {\n const result = await promise;\n bundleCache.set(hostFilePath, result);\n return result;\n } finally {\n bundlesInFlight.delete(hostFilePath);\n }\n}\n\nasync function doBundleHostFile(\n hostFilePath: string,\n): Promise<{ code: string }> {\n const rootDir = path.dirname(hostFilePath);\n\n const bundle = await rollup({\n input: hostFilePath,\n treeshake: false,\n plugins: [\n externalizeAllBareSpecifiersPlugin(),\n stripTypeScriptPlugin(),\n nodeResolve({\n rootDir,\n browser: false,\n exportConditions: [\"workerd\", \"worker\", \"edge-light\"],\n extensions: [\".mjs\", \".js\", \".json\", \".node\", ...TS_EXTENSIONS],\n }),\n shimNodeBuiltinsPlugin(),\n commonjs(commonjsInteropOptions),\n json(),\n replace({\n preventAssignment: true,\n values: { \"process.env.NODE_ENV\": JSON.stringify(\"development\") },\n }),\n ],\n onwarn: (warning, warn) => {\n if (warning.code === \"CIRCULAR_DEPENDENCY\") return;\n if (warning.code === \"THIS_IS_UNDEFINED\") return;\n if (warning.code === \"UNUSED_EXTERNAL_IMPORT\") return;\n if (warning.code === \"EMPTY_BUNDLE\") return;\n // Suppress warnings about named imports from shimmed Node.js builtins\n if (warning.code === \"MISSING_EXPORT\" && warning.exporter?.startsWith(NODE_BUILTIN_SHIM_PREFIX)) return;\n warn(warning);\n },\n });\n\n const { output } = await bundle.generate({\n format: \"es\",\n sourcemap: \"inline\",\n inlineDynamicImports: true,\n });\n await bundle.close();\n\n const code = output[0]!.code;\n return { code };\n}\n\n/**\n * Clear the bundle cache. Useful for testing.\n */\nexport function clearBundleCache(): void {\n bundleCache.clear();\n}\n"
5
+ "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { asyncWrapProviders as hostAsyncWrapProviders } from \"node:async_hooks\";\nimport { builtinModules, createRequire } from \"node:module\";\nimport { rollup, type Plugin } from \"rollup\";\nimport * as nodeResolveModule from \"@rollup/plugin-node-resolve\";\nimport * as commonjsModule from \"@rollup/plugin-commonjs\";\nimport * as jsonModule from \"@rollup/plugin-json\";\nimport * as replaceModule from \"@rollup/plugin-replace\";\nimport { detectFormat, parseSpecifier, isBareSpecifier, resolveFilePath } from \"./resolve.cjs\";\nimport { processTypeScript, isTypeScriptFile } from \"./strip-types.cjs\";\nimport type { RollupCommonJSOptions } from \"@rollup/plugin-commonjs\";\nimport type { RollupJsonOptions } from \"@rollup/plugin-json\";\nimport type { RollupReplaceOptions } from \"@rollup/plugin-replace\";\n\n// Handle CJS default exports\nconst nodeResolve = ((nodeResolveModule as any).default ||\n nodeResolveModule) as (typeof nodeResolveModule)[\"nodeResolve\"];\nconst commonjs = ((commonjsModule as any).default || commonjsModule) as (\n options?: RollupCommonJSOptions\n) => Plugin;\nconst json = ((jsonModule as any).default || jsonModule) as (\n options?: RollupJsonOptions\n) => Plugin;\nconst replace = ((replaceModule as any).default || replaceModule) as (\n options?: RollupReplaceOptions\n) => Plugin;\n\nconst commonjsInteropOptions = {\n // External package imports are resolved by later loader calls as ESM bundles,\n // so CommonJS requires need ESM-aware interop instead of default-import assumptions.\n esmExternals: true,\n requireReturnsDefault: \"auto\",\n} satisfies RollupCommonJSOptions;\n\nconst PACKAGE_ENTRY_WRAPPER_PREFIX = \"\\0package-entry-wrapper:\";\nconst INVALID_FUNCTION_EXPORT_NAMES = new Set([\n \"arguments\",\n \"caller\",\n \"length\",\n \"name\",\n \"prototype\",\n]);\n\n/**\n * Set of Node.js built-in module names (e.g. \"fs\", \"path\", \"crypto\").\n */\nconst nodeBuiltins = new Set(builtinModules);\n\n/**\n * Check if a specifier refers to a Node.js built-in module.\n * Handles bare names (\"fs\"), subpaths (\"fs/promises\"), and node: prefix (\"node:fs\").\n */\nfunction isNodeBuiltin(source: string): boolean {\n const name = source.startsWith(\"node:\") ? source.slice(5) : source;\n const topLevel = name.split(\"/\")[0]!;\n return nodeBuiltins.has(topLevel);\n}\n\nconst NODE_BUILTIN_SHIM_PREFIX = \"\\0node-builtin-shim:\";\nconst BROWSER_EMPTY_MODULE_PREFIX = \"\\0browser-empty:\";\nconst HOST_ASYNC_WRAP_PROVIDERS_JSON = JSON.stringify(hostAsyncWrapProviders);\nconst BROWSER_MAPPING_EXTENSIONS = [\".tsx\", \".jsx\", \".ts\", \".mjs\", \".js\", \".cjs\", \".json\"];\n\nexport function getNodeBuiltinShimCode(source: string): string {\n if (source === \"ws\" || source === \"node:ws\") {\n return `\nconst WebSocketShim = globalThis.WebSocket;\n\nif (!WebSocketShim) {\n throw new Error(\"The isolate runtime does not provide a global WebSocket implementation.\");\n}\n\nexport { WebSocketShim as WebSocket };\nexport default WebSocketShim;\n`;\n }\n\n if (source === \"async_hooks\" || source === \"node:async_hooks\") {\n return `\nconst AsyncContextShim = globalThis.AsyncContext;\nconst asyncInternals = globalThis.__isolateAsyncContextInternals;\n\nif (\n !AsyncContextShim\n || !asyncInternals?.AsyncContextFrame\n || typeof asyncInternals.createResource !== \"function\"\n || typeof asyncInternals.runWithResource !== \"function\"\n || typeof asyncInternals.destroyResource !== \"function\"\n || typeof asyncInternals.enableHook !== \"function\"\n || typeof asyncInternals.disableHook !== \"function\"\n) {\n throw new Error(\n \"node:async_hooks requires AsyncContext support in the isolate engine.\"\n );\n}\n\nconst { AsyncContextFrame } = asyncInternals;\nconst NO_STORE = Symbol(\"AsyncLocalStorage.noStore\");\nconst asyncWrapProviders = Object.assign(\n Object.create(null),\n ${HOST_ASYNC_WRAP_PROVIDERS_JSON},\n);\n\nfunction validateHookCallback(name, value) {\n if (value !== undefined && typeof value !== \"function\") {\n throw new TypeError(\"hook.\" + name + \" must be a function\");\n }\n}\n\nclass AsyncHook {\n #callbacks;\n #enabled;\n\n constructor(callbacks) {\n this.#callbacks = callbacks;\n this.#enabled = false;\n }\n\n enable() {\n if (!this.#enabled) {\n this.#enabled = true;\n asyncInternals.enableHook(this, this.#callbacks);\n }\n return this;\n }\n\n disable() {\n if (this.#enabled) {\n this.#enabled = false;\n asyncInternals.disableHook(this);\n }\n return this;\n }\n}\n\nfunction createHook(callbacks) {\n const { init, before, after, destroy, promiseResolve } = callbacks;\n\n validateHookCallback(\"init\", init);\n validateHookCallback(\"before\", before);\n validateHookCallback(\"after\", after);\n validateHookCallback(\"destroy\", destroy);\n validateHookCallback(\"promiseResolve\", promiseResolve);\n\n return new AsyncHook({\n init,\n before,\n after,\n destroy,\n promiseResolve,\n });\n}\n\nfunction executionAsyncId() {\n return asyncInternals.executionAsyncId();\n}\n\nfunction triggerAsyncId() {\n return asyncInternals.triggerAsyncId();\n}\n\nfunction executionAsyncResource() {\n return asyncInternals.executionAsyncResource();\n}\n\nclass AsyncResource {\n #snapshot;\n #resourceState;\n\n constructor(type, options = {}) {\n const normalizedOptions =\n options && typeof options === \"object\" ? options : {};\n\n this.#snapshot = new AsyncContextShim.Snapshot();\n this.#resourceState = asyncInternals.createResource(\n String(type),\n this,\n {\n triggerAsyncId: normalizedOptions.triggerAsyncId,\n },\n );\n }\n\n runInAsyncScope(fn, thisArg, ...args) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"AsyncResource.runInAsyncScope requires a function\");\n }\n return this.#snapshot.run(\n () => asyncInternals.runWithResource(\n this.#resourceState,\n fn,\n thisArg,\n args,\n ),\n );\n }\n\n bind(fn, thisArg) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"AsyncResource.bind requires a function\");\n }\n const resource = this;\n return function bound(...args) {\n return resource.runInAsyncScope(\n fn,\n thisArg === undefined ? this : thisArg,\n ...args,\n );\n };\n }\n\n emitDestroy() {\n if (!asyncInternals.destroyResource(this.#resourceState)) {\n throw new Error(\"AsyncResource.emitDestroy() must only be called once\");\n }\n return this;\n }\n\n asyncId() {\n return this.#resourceState.asyncId;\n }\n\n triggerAsyncId() {\n return this.#resourceState.triggerAsyncId;\n }\n\n static bind(fn, type, thisArg) {\n return new AsyncResource(type).bind(fn, thisArg);\n }\n}\n\nclass AsyncLocalStorage {\n #variable;\n #defaultValue;\n #token;\n #disabled;\n\n constructor(options = {}) {\n const normalizedOptions =\n options && typeof options === \"object\" ? options : {};\n\n this.#defaultValue = normalizedOptions.defaultValue;\n this.#token = Symbol(\"AsyncLocalStorage.token\");\n this.#disabled = false;\n this.#variable = new AsyncContextShim.Variable({\n defaultValue: NO_STORE,\n name: normalizedOptions.name,\n });\n }\n\n get name() {\n return this.#variable.name;\n }\n\n disable() {\n this.#token = Symbol(\"AsyncLocalStorage.token\");\n this.#disabled = true;\n AsyncContextFrame.disable(this.#variable);\n }\n\n enterWith(store) {\n this.#disabled = false;\n AsyncContextFrame.set(\n new AsyncContextFrame(this.#variable, {\n token: this.#token,\n hasValue: true,\n store,\n }),\n );\n }\n\n run(store, callback, ...args) {\n if (typeof callback !== \"function\") {\n throw new TypeError(\"AsyncLocalStorage.run requires a function\");\n }\n this.#disabled = false;\n return this.#variable.run(\n {\n token: this.#token,\n hasValue: true,\n store,\n },\n callback,\n ...args,\n );\n }\n\n exit(callback, ...args) {\n if (typeof callback !== \"function\") {\n throw new TypeError(\"AsyncLocalStorage.exit requires a function\");\n }\n return this.#variable.run(\n {\n token: this.#token,\n hasValue: false,\n store: undefined,\n },\n callback,\n ...args,\n );\n }\n\n getStore() {\n const entry = this.#variable.get();\n if (entry === NO_STORE) {\n return this.#disabled ? undefined : this.#defaultValue;\n }\n if (!entry || entry.token !== this.#token) {\n return undefined;\n }\n if (!entry.hasValue) {\n return undefined;\n }\n return entry.store;\n }\n\n static bind(fn) {\n return AsyncResource.bind(fn, \"AsyncLocalStorage.bind\");\n }\n\n static snapshot() {\n const snapshot = new AsyncContextShim.Snapshot();\n return function runInAsyncScope(fn, ...args) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"AsyncLocalStorage.snapshot requires a function\");\n }\n return snapshot.run(fn, ...args);\n };\n }\n}\n\nexport {\n AsyncLocalStorage,\n AsyncResource,\n asyncWrapProviders,\n createHook,\n executionAsyncId,\n executionAsyncResource,\n triggerAsyncId,\n};\nexport default {\n AsyncLocalStorage,\n AsyncResource,\n asyncWrapProviders,\n createHook,\n executionAsyncId,\n executionAsyncResource,\n triggerAsyncId,\n};\n`;\n }\n\n return \"export default {};\\n\";\n}\n\n/**\n * Rollup plugin that provides empty shims for Node.js built-in modules.\n * Place after nodeResolve — acts as a catch-all for builtins that the\n * package's browser field didn't map to false.\n */\nfunction shimNodeBuiltinsPlugin(): Plugin {\n return {\n name: \"shim-node-builtins\",\n resolveId(source) {\n if (isNodeBuiltin(source)) {\n return { id: `${NODE_BUILTIN_SHIM_PREFIX}${source}`, moduleSideEffects: false };\n }\n return null;\n },\n load(id) {\n if (id.startsWith(NODE_BUILTIN_SHIM_PREFIX)) {\n return getNodeBuiltinShimCode(id.slice(NODE_BUILTIN_SHIM_PREFIX.length));\n }\n return null;\n },\n };\n}\n\nfunction isValidEsmIdentifier(name: string): boolean {\n return /^[$A-Z_a-z][$\\w]*$/.test(name);\n}\n\nfunction resolvePackageImportPath(specifier: string, rootDir: string): string | null {\n const resolver = createRequire(path.join(rootDir, \"__isolate_module_loader__.js\"));\n\n let resolvedRequirePath: string;\n try {\n resolvedRequirePath = resolver.resolve(specifier);\n } catch {\n return null;\n }\n\n const { packageName, subpath } = parseSpecifier(specifier);\n const packageJsonPath = findPackageJsonPath(resolvedRequirePath, packageName);\n if (!packageJsonPath) {\n return resolvedRequirePath;\n }\n\n let packageJson: Record<string, unknown>;\n try {\n packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\")) as Record<string, unknown>;\n } catch {\n return resolvedRequirePath;\n }\n\n const packageRoot = path.dirname(packageJsonPath);\n const exportPath = resolveImportEntryFromPackageJson(packageJson, subpath);\n\n if (exportPath) {\n return path.resolve(packageRoot, exportPath);\n }\n\n if (!subpath) {\n const moduleEntry = packageJson.module;\n if (typeof moduleEntry === \"string\") {\n return path.resolve(packageRoot, moduleEntry);\n }\n\n const browserEntry = packageJson.browser;\n if (typeof browserEntry === \"string\") {\n return path.resolve(packageRoot, browserEntry);\n }\n }\n\n return resolvedRequirePath;\n}\n\nfunction findPackageJsonPath(resolvedPath: string, packageName: string): string | null {\n let currentDir = path.dirname(resolvedPath);\n let matchedPackageJsonPath: string | null = null;\n\n while (true) {\n const packageJsonPath = path.join(currentDir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\")) as { name?: string };\n if (packageJson.name === packageName) {\n // Keep walking upward: published packages often include nested\n // dist/cjs or dist/mjs package.json files with the same name, but the\n // real package root higher up contains the export map we need.\n matchedPackageJsonPath = packageJsonPath;\n }\n } catch {\n // Keep walking upward if a parent package.json is malformed.\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return matchedPackageJsonPath;\n }\n currentDir = parentDir;\n }\n}\n\nfunction resolveImportEntryFromPackageJson(\n packageJson: Record<string, unknown>,\n subpath: string\n): string | null {\n const exportsField = packageJson.exports;\n if (exportsField === undefined) {\n return null;\n }\n\n const exportKey = subpath ? `.${subpath}` : \".\";\n\n if (isConditionalExportsObject(exportsField)) {\n if (exportKey !== \".\") {\n return null;\n }\n return pickImportTarget(exportsField);\n }\n\n if (typeof exportsField === \"object\" && exportsField !== null && !Array.isArray(exportsField)) {\n const exportsRecord = exportsField as Record<string, unknown>;\n const directTarget = exportsRecord[exportKey];\n if (directTarget !== undefined) {\n return pickImportTarget(directTarget);\n }\n\n for (const [pattern, target] of Object.entries(exportsRecord)) {\n if (!pattern.includes(\"*\")) {\n continue;\n }\n\n const starIndex = pattern.indexOf(\"*\");\n const prefix = pattern.slice(0, starIndex);\n const suffix = pattern.slice(starIndex + 1);\n\n if (!exportKey.startsWith(prefix) || !exportKey.endsWith(suffix)) {\n continue;\n }\n\n const wildcardMatch = exportKey.slice(\n prefix.length,\n suffix.length > 0 ? -suffix.length : undefined,\n );\n\n return pickImportTarget(target, wildcardMatch);\n }\n\n return null;\n }\n\n return exportKey === \".\" ? pickImportTarget(exportsField) : null;\n}\n\nfunction isConditionalExportsObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\"\n && value !== null\n && !Array.isArray(value)\n && Object.keys(value).every((key) => !key.startsWith(\".\"));\n}\n\nfunction pickImportTarget(value: unknown, wildcardMatch?: string): string | null {\n if (typeof value === \"string\") {\n return wildcardMatch === undefined ? value : value.replaceAll(\"*\", wildcardMatch);\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n const target = pickImportTarget(item, wildcardMatch);\n if (target) {\n return target;\n }\n }\n return null;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n\n const record = value as Record<string, unknown>;\n\n for (const key of [\"workerd\", \"worker\", \"edge-light\", \"import\", \"module\", \"default\", \"browser\"]) {\n if (key in record) {\n const target = pickImportTarget(record[key], wildcardMatch);\n if (target) {\n return target;\n }\n }\n }\n\n for (const nestedValue of Object.values(record)) {\n const target = pickImportTarget(nestedValue, wildcardMatch);\n if (target) {\n return target;\n }\n }\n\n return null;\n}\n\nconst browserMappingsByPackageRoot = new Map<string, Record<string, string | false> | null>();\n\nfunction packageBrowserMappingsPlugin(): Plugin {\n return {\n name: \"package-browser-mappings\",\n resolveId(source, importer) {\n if (!importer || importer.startsWith(\"\\0\")) {\n return null;\n }\n\n const browserMappings = getBrowserMappingsForImporter(importer);\n if (!browserMappings) {\n return null;\n }\n\n const mappedTarget = resolveBrowserMapping(source, importer, browserMappings);\n if (mappedTarget === undefined) {\n return null;\n }\n\n if (mappedTarget === false) {\n return `${BROWSER_EMPTY_MODULE_PREFIX}${browserMappings.packageRoot}\\0${source}`;\n }\n\n if (isBareSpecifier(mappedTarget) || mappedTarget.startsWith(\"node:\")) {\n return this.resolve(mappedTarget, importer, { skipSelf: true }).then(\n (resolved) => resolved ?? { id: mappedTarget },\n );\n }\n\n return mappedTarget;\n },\n load(id) {\n if (id.startsWith(BROWSER_EMPTY_MODULE_PREFIX)) {\n return \"export default {};\\n\";\n }\n return null;\n },\n };\n}\n\nfunction getBrowserMappingsForImporter(importer: string): {\n packageRoot: string;\n mappings: Record<string, string | false>;\n} | null {\n const packageJsonPath = findNearestPackageJsonPath(importer);\n if (!packageJsonPath) {\n return null;\n }\n\n const packageRoot = path.dirname(packageJsonPath);\n let cachedMappings = browserMappingsByPackageRoot.get(packageRoot);\n if (cachedMappings === undefined) {\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\")) as { browser?: unknown };\n const browserField = packageJson.browser;\n cachedMappings = typeof browserField === \"object\" && browserField !== null && !Array.isArray(browserField)\n ? Object.fromEntries(\n Object.entries(browserField)\n .filter((entry): entry is [string, string | false] => typeof entry[1] === \"string\" || entry[1] === false),\n )\n : null;\n } catch {\n cachedMappings = null;\n }\n browserMappingsByPackageRoot.set(packageRoot, cachedMappings);\n }\n\n if (!cachedMappings) {\n return null;\n }\n\n return { packageRoot, mappings: cachedMappings };\n}\n\nfunction resolveBrowserMapping(\n source: string,\n importer: string,\n browserMappings: { packageRoot: string; mappings: Record<string, string | false> },\n): string | false | undefined {\n const keysToTry: string[] = [];\n\n if (isBareSpecifier(source) || source.startsWith(\"node:\")) {\n keysToTry.push(source);\n if (source.startsWith(\"node:\")) {\n keysToTry.push(source.slice(5));\n }\n } else {\n const importerDir = path.dirname(importer);\n const unresolvedTarget = source.startsWith(\"/\")\n ? source\n : path.resolve(importerDir, source);\n\n if (unresolvedTarget !== browserMappings.packageRoot\n && !unresolvedTarget.startsWith(browserMappings.packageRoot + path.sep)) {\n return undefined;\n }\n\n keysToTry.push(`./${toPosixPath(path.relative(browserMappings.packageRoot, unresolvedTarget))}`);\n\n const resolvedTarget = resolveFilePath(unresolvedTarget);\n if (resolvedTarget) {\n keysToTry.push(`./${toPosixPath(path.relative(browserMappings.packageRoot, resolvedTarget))}`);\n }\n }\n\n for (const key of keysToTry) {\n const mappedTarget = browserMappings.mappings[key];\n if (mappedTarget === undefined) {\n continue;\n }\n\n if (mappedTarget === false) {\n return false;\n }\n\n if (isBareSpecifier(mappedTarget) || mappedTarget.startsWith(\"node:\")) {\n return mappedTarget;\n }\n\n const absoluteTarget = mappedTarget.startsWith(\"/\")\n ? mappedTarget\n : path.resolve(browserMappings.packageRoot, mappedTarget);\n return resolveBrowserMappingTargetPath(absoluteTarget) ?? absoluteTarget;\n }\n\n return undefined;\n}\n\nfunction findNearestPackageJsonPath(filePath: string): string | null {\n let currentDir = path.dirname(filePath);\n\n while (true) {\n const packageJsonPath = path.join(currentDir, \"package.json\");\n if (fs.existsSync(packageJsonPath)) {\n return packageJsonPath;\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return null;\n }\n currentDir = parentDir;\n }\n}\n\nfunction toPosixPath(filePath: string): string {\n return filePath.split(path.sep).join(\"/\");\n}\n\nfunction resolveBrowserMappingTargetPath(basePath: string): string | null {\n const resolved = resolveFilePath(basePath);\n if (resolved) {\n return resolved;\n }\n\n if (path.extname(basePath) === \".browser\") {\n for (const extension of BROWSER_MAPPING_EXTENSIONS) {\n const candidate = `${basePath}${extension}`;\n try {\n if (fs.statSync(candidate).isFile()) {\n return candidate;\n }\n } catch {\n // Try the next extension.\n }\n }\n }\n\n return null;\n}\n\nfunction getCommonJsNamedExports(specifier: string, rootDir: string): string[] {\n const resolvedHostPath = resolvePackageImportPath(specifier, rootDir);\n if (!resolvedHostPath) {\n return [];\n }\n\n let code: string;\n try {\n code = fs.readFileSync(resolvedHostPath, \"utf-8\");\n } catch {\n return [];\n }\n\n if (detectFormat(resolvedHostPath, code) !== \"cjs\") {\n return [];\n }\n\n let moduleExports: unknown;\n try {\n moduleExports = createRequire(resolvedHostPath)(resolvedHostPath);\n } catch {\n return [];\n }\n\n if (moduleExports == null || (typeof moduleExports !== \"object\" && typeof moduleExports !== \"function\")) {\n return [];\n }\n\n const names = new Set([\n ...Object.keys(moduleExports),\n ...Object.getOwnPropertyNames(moduleExports),\n ]);\n\n names.delete(\"default\");\n names.delete(\"__esModule\");\n\n if (typeof moduleExports === \"function\") {\n for (const name of INVALID_FUNCTION_EXPORT_NAMES) {\n names.delete(name);\n }\n }\n\n return [...names].filter(isValidEsmIdentifier).sort();\n}\n\nfunction packageEntryWrapperPlugin(specifier: string, namedExports: string[]): Plugin {\n const wrapperId = `${PACKAGE_ENTRY_WRAPPER_PREFIX}${specifier}`;\n\n return {\n name: \"package-entry-wrapper\",\n resolveId(source) {\n if (source === wrapperId) {\n return wrapperId;\n }\n return null;\n },\n load(id) {\n if (id !== wrapperId) {\n return null;\n }\n\n const namedExportLines = namedExports.map(\n (name) => `export const ${name} = __packageDefault.${name};`\n );\n\n return [\n `import __packageDefault from ${JSON.stringify(specifier)};`,\n \"export default __packageDefault;\",\n ...namedExportLines,\n ].join(\"\\n\");\n },\n };\n}\n\n/**\n * Cache for bundled npm packages. Key includes specifier + resolution root.\n */\nconst bundleCache = new Map<string, { code: string }>();\n\n/**\n * In-flight bundle promises to avoid duplicate concurrent bundles.\n */\nconst bundlesInFlight = new Map<string, Promise<{ code: string }>>();\n\n/**\n * Create a Rollup plugin that externalizes all bare specifiers that don't\n * belong to the current package. Internal files of the package are inlined;\n * other npm packages remain as import statements.\n */\nfunction externalizeDepsPlugin(currentPackageName: string): Plugin {\n return {\n name: \"externalize-deps\",\n resolveId(source, importer) {\n // Don't externalize the entry point\n if (!importer) return null;\n\n // Don't externalize relative imports (internal to the package)\n if (source.startsWith(\".\") || source.startsWith(\"/\")) return null;\n\n // Keep package-private imports inside the current bundle so Rollup can\n // resolve them through the importing package's `imports` map.\n if (source.startsWith(\"#\")) return null;\n\n // Don't externalize Node.js builtins — let nodeResolve handle them\n // via the package's browser field (e.g. \"fs\": false → empty module)\n if (isNodeBuiltin(source)) return null;\n\n // Check if this is a different npm package\n const { packageName } = parseSpecifier(source);\n if (packageName !== currentPackageName) {\n return { id: source, external: true };\n }\n\n // Same package — let Rollup resolve it normally\n return null;\n },\n };\n}\n\n/**\n * Bundle a bare specifier (npm package) using Rollup.\n *\n * Each unique bare specifier gets its own bundle with:\n * - node-resolve with worker/server-safe export conditions\n * - commonjs conversion\n * - json support\n * - process.env.NODE_ENV replacement\n * - External deps (other npm packages) left as import statements\n *\n * Results are cached permanently (npm packages are static).\n */\nexport async function bundleSpecifier(\n specifier: string,\n rootDir: string\n): Promise<{ code: string }> {\n const cacheKey = `${specifier}\\0${rootDir}`;\n\n // Check cache\n const cached = bundleCache.get(cacheKey);\n if (cached) return cached;\n\n // Check in-flight\n const inFlight = bundlesInFlight.get(cacheKey);\n if (inFlight) return inFlight;\n\n const promise = doBundleSpecifier(specifier, rootDir);\n bundlesInFlight.set(cacheKey, promise);\n\n try {\n const result = await promise;\n bundleCache.set(cacheKey, result);\n return result;\n } finally {\n bundlesInFlight.delete(cacheKey);\n }\n}\n\nasync function doBundleSpecifier(\n specifier: string,\n rootDir: string\n): Promise<{ code: string }> {\n const { packageName } = parseSpecifier(specifier);\n const namedExports = getCommonJsNamedExports(specifier, rootDir);\n const input = namedExports.length > 0\n ? `${PACKAGE_ENTRY_WRAPPER_PREFIX}${specifier}`\n : specifier;\n\n const bundle = await rollup({\n input,\n // Disable tree-shaking: we're creating a virtual module that must faithfully\n // expose all package exports. We can't predict which ones user code will import.\n // Without this, exports like AWS SDK's ConverseStreamOutput (a namespace with\n // a visit() helper that nothing inside the bundle references) get dropped.\n treeshake: false,\n plugins: [\n packageEntryWrapperPlugin(specifier, namedExports),\n externalizeDepsPlugin(packageName),\n packageBrowserMappingsPlugin(),\n nodeResolve({\n rootDir,\n browser: false,\n exportConditions: [\"workerd\", \"worker\", \"edge-light\"],\n }),\n shimNodeBuiltinsPlugin(),\n commonjs(commonjsInteropOptions),\n json(),\n replace({\n preventAssignment: true,\n values: { \"process.env.NODE_ENV\": JSON.stringify(\"development\") },\n }),\n ],\n onwarn: (warning, warn) => {\n if (warning.code === \"CIRCULAR_DEPENDENCY\") return;\n if (warning.code === \"THIS_IS_UNDEFINED\") return;\n if (warning.code === \"UNUSED_EXTERNAL_IMPORT\") return;\n if (warning.code === \"EMPTY_BUNDLE\") return;\n // Suppress warnings about named imports from shimmed Node.js builtins\n if (warning.code === \"MISSING_EXPORT\" && warning.exporter?.startsWith(NODE_BUILTIN_SHIM_PREFIX)) return;\n warn(warning);\n },\n });\n\n const { output } = await bundle.generate({\n format: \"es\",\n sourcemap: \"inline\",\n inlineDynamicImports: true,\n });\n await bundle.close();\n\n const code = output[0]!.code;\n return { code };\n}\n\n/**\n * Create a Rollup plugin that externalizes ALL bare specifiers.\n * Used for module aliases where the host file's relative imports are bundled\n * but npm package dependencies are left as external imports.\n */\nfunction externalizeAllBareSpecifiersPlugin(): Plugin {\n return {\n name: \"externalize-all-bare-specifiers\",\n resolveId(source, importer) {\n if (!importer) return null;\n if (source.startsWith(\".\") || source.startsWith(\"/\")) return null;\n if (source.startsWith(\"#\")) return null;\n // Don't externalize Node.js builtins — let nodeResolve/shim handle them\n if (isNodeBuiltin(source)) return null;\n return { id: source, external: true };\n },\n };\n}\n\n/**\n * Create a Rollup transform plugin that strips TypeScript types.\n */\nfunction stripTypeScriptPlugin(): Plugin {\n return {\n name: \"strip-typescript\",\n transform(code, id) {\n if (isTypeScriptFile(id)) {\n return { code: processTypeScript(code, id), map: null };\n }\n return null;\n },\n };\n}\n\nconst TS_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".cts\"];\n\n/**\n * Bundle a host file using Rollup, inlining its relative imports.\n *\n * - Uses the host file path as Rollup input\n * - Externalizes ALL bare specifiers (npm packages)\n * - Strips TypeScript via processTypeScript\n * - Shares the bundleCache/bundlesInFlight (no key collision since file paths start with `/`)\n *\n * Results are cached permanently.\n */\nexport async function bundleHostFile(\n hostFilePath: string,\n): Promise<{ code: string }> {\n const cached = bundleCache.get(hostFilePath);\n if (cached) return cached;\n\n const inFlight = bundlesInFlight.get(hostFilePath);\n if (inFlight) return inFlight;\n\n const promise = doBundleHostFile(hostFilePath);\n bundlesInFlight.set(hostFilePath, promise);\n\n try {\n const result = await promise;\n bundleCache.set(hostFilePath, result);\n return result;\n } finally {\n bundlesInFlight.delete(hostFilePath);\n }\n}\n\nasync function doBundleHostFile(\n hostFilePath: string,\n): Promise<{ code: string }> {\n const rootDir = path.dirname(hostFilePath);\n\n const bundle = await rollup({\n input: hostFilePath,\n treeshake: false,\n plugins: [\n externalizeAllBareSpecifiersPlugin(),\n stripTypeScriptPlugin(),\n nodeResolve({\n rootDir,\n browser: false,\n exportConditions: [\"workerd\", \"worker\", \"edge-light\"],\n extensions: [\".mjs\", \".js\", \".json\", \".node\", ...TS_EXTENSIONS],\n }),\n shimNodeBuiltinsPlugin(),\n commonjs(commonjsInteropOptions),\n json(),\n replace({\n preventAssignment: true,\n values: { \"process.env.NODE_ENV\": JSON.stringify(\"development\") },\n }),\n ],\n onwarn: (warning, warn) => {\n if (warning.code === \"CIRCULAR_DEPENDENCY\") return;\n if (warning.code === \"THIS_IS_UNDEFINED\") return;\n if (warning.code === \"UNUSED_EXTERNAL_IMPORT\") return;\n if (warning.code === \"EMPTY_BUNDLE\") return;\n // Suppress warnings about named imports from shimmed Node.js builtins\n if (warning.code === \"MISSING_EXPORT\" && warning.exporter?.startsWith(NODE_BUILTIN_SHIM_PREFIX)) return;\n warn(warning);\n },\n });\n\n const { output } = await bundle.generate({\n format: \"es\",\n sourcemap: \"inline\",\n inlineDynamicImports: true,\n });\n await bundle.close();\n\n const code = output[0]!.code;\n return { code };\n}\n\n/**\n * Clear the bundle cache. Useful for testing.\n */\nexport function clearBundleCache(): void {\n bundleCache.clear();\n}\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAe,IAAf;AACiB,IAAjB;AAC6D,IAA7D;AAC8C,IAA9C;AACoC,IAApC;AACmC,IAAnC;AACgC,IAAhC;AAC4B,IAA5B;AAC+B,IAA/B;AAC6C,IAA7C;AACoD,IAApD;AAMA,IAAM,cAA0C,6BAC9C;AACF,IAAM,WAAoC,0BAAW;AAGrD,IAAM,OAA4B,sBAAW;AAG7C,IAAM,UAAkC,yBAAW;AAInD,IAAM,yBAAyB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EhB,CAAC;AAAA,EAED,QAAQ,WAAW,MAAM,OAAO,SAAS;AAAA,IACvC,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,sBAAsB;AAAA,EACxB,CAAC;AAAA,EACD,MAAM,OAAO,MAAM;AAAA,EAEnB,MAAM,OAAO,OAAO,GAAI;AAAA,EACxB,OAAO,EAAE,KAAK;AAAA;AAMT,SAAS,gBAAgB,GAAS;AAAA,EACvC,YAAY,MAAM;AAAA;",
8
+ "debugId": "18A8EE3C3887536664756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -100,6 +100,7 @@ class ModuleResolverBuilder {
100
100
  return this;
101
101
  }
102
102
  async resolve(specifier, importer, context) {
103
+ let nodeModulesError;
103
104
  const explicit = this.virtualEntries.get(specifier);
104
105
  if (explicit) {
105
106
  const raw = typeof explicit.source === "function" ? await explicit.source() : await explicit.source;
@@ -140,6 +141,7 @@ class ModuleResolverBuilder {
140
141
  try {
141
142
  return await this.getNodeModulesLoader()(specifier, importer);
142
143
  } catch (error) {
144
+ nodeModulesError = error;
143
145
  if (!this.fallbackLoader) {
144
146
  throw error;
145
147
  }
@@ -151,6 +153,9 @@ class ModuleResolverBuilder {
151
153
  return normalized;
152
154
  }
153
155
  }
156
+ if (nodeModulesError) {
157
+ throw nodeModulesError;
158
+ }
154
159
  throw new Error(`Unable to resolve module: ${specifier}`);
155
160
  }
156
161
  getNodeModulesLoader() {
@@ -164,4 +169,4 @@ function createModuleResolver() {
164
169
  return new ModuleResolverBuilder;
165
170
  }
166
171
 
167
- //# debugId=363B95C4D202910564756E2164756E21
172
+ //# debugId=F4C37D8B8A6E243564756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/index.ts"],
4
4
  "sourcesContent": [
5
- "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { defaultModuleLoader } from \"../internal/module-loader/index.cjs\";\nimport { normalizeExplicitModuleResult } from \"../bridge/legacy-adapters.cjs\";\nimport type { HostCallContext, ModuleResolveResult, ModuleResolver, ModuleResolverFallback, ModuleResolverSourceLoader, ModuleSource } from \"../types.cjs\";\n\nclass ModuleResolverBuilder implements ModuleResolver {\n private readonly nodeModuleMappings: Array<{ from: string; to: string }> = [];\n private readonly virtualEntries = new Map<string, { source: ModuleResolveResult | (() => ModuleResolveResult); options?: Partial<ModuleSource> }>();\n private readonly virtualFiles = new Map<string, { filePath: string; options?: Partial<ModuleSource> }>();\n private readonly sourceTrees: Array<{ prefix: string; loader: ModuleResolverSourceLoader }> = [];\n private fallbackLoader?: ModuleResolverFallback;\n private nodeModulesLoader?: ReturnType<typeof defaultModuleLoader>;\n\n mountNodeModules(virtualMount: string, hostPath: string): ModuleResolver {\n this.nodeModuleMappings.push({ from: hostPath, to: virtualMount });\n this.nodeModulesLoader = undefined;\n return this;\n }\n\n virtual(specifier: string, source: ModuleResolveResult | (() => ModuleResolveResult), options?: Partial<ModuleSource>): ModuleResolver {\n this.virtualEntries.set(specifier, { source, options });\n return this;\n }\n\n virtualFile(specifier: string, filePath: string, options?: Partial<ModuleSource>): ModuleResolver {\n this.virtualFiles.set(specifier, { filePath, options });\n return this;\n }\n\n sourceTree(prefix: string, loader: ModuleResolverSourceLoader): ModuleResolver {\n this.sourceTrees.push({ prefix, loader });\n return this;\n }\n\n fallback(loader: ModuleResolverFallback): ModuleResolver {\n this.fallbackLoader = loader;\n return this;\n }\n\n async resolve(specifier: string, importer: { path: string; resolveDir: string }, context: HostCallContext): Promise<ModuleSource> {\n const explicit = this.virtualEntries.get(specifier);\n if (explicit) {\n const raw = typeof explicit.source === \"function\" ? await explicit.source() : await explicit.source;\n const normalized = await normalizeExplicitModuleResult(specifier, raw, importer.resolveDir);\n if (!normalized) {\n throw new Error(`Virtual module ${specifier} returned no source.`);\n }\n return {\n ...normalized,\n ...explicit.options,\n };\n }\n\n const virtualFile = this.virtualFiles.get(specifier);\n if (virtualFile) {\n const code = fs.readFileSync(virtualFile.filePath, \"utf-8\");\n const fallback = await normalizeExplicitModuleResult(\n specifier,\n {\n code,\n filename: virtualFile.options?.filename ?? path.basename(virtualFile.filePath),\n resolveDir: virtualFile.options?.resolveDir ?? path.posix.dirname(specifier.startsWith(\"/\") ? specifier : `/${specifier}`),\n static: virtualFile.options?.static,\n },\n importer.resolveDir,\n );\n if (!fallback) {\n throw new Error(`Virtual file module ${specifier} returned no source.`);\n }\n return fallback;\n }\n\n for (const sourceTree of this.sourceTrees) {\n if (!specifier.startsWith(sourceTree.prefix)) {\n continue;\n }\n const relativePath = specifier.slice(sourceTree.prefix.length);\n const normalized = await normalizeExplicitModuleResult(specifier, sourceTree.loader(relativePath, context), importer.resolveDir);\n if (normalized) {\n return normalized;\n }\n }\n\n if (this.nodeModuleMappings.length > 0) {\n try {\n return await this.getNodeModulesLoader()(specifier, importer);\n } catch (error) {\n if (!this.fallbackLoader) {\n throw error;\n }\n }\n }\n\n if (this.fallbackLoader) {\n const normalized = await normalizeExplicitModuleResult(specifier, this.fallbackLoader(specifier, importer, context), importer.resolveDir);\n if (normalized) {\n return normalized;\n }\n }\n\n throw new Error(`Unable to resolve module: ${specifier}`);\n }\n\n private getNodeModulesLoader(): ReturnType<typeof defaultModuleLoader> {\n if (!this.nodeModulesLoader) {\n this.nodeModulesLoader = defaultModuleLoader(...this.nodeModuleMappings);\n }\n return this.nodeModulesLoader;\n }\n}\n\nexport function createModuleResolver(): ModuleResolver {\n return new ModuleResolverBuilder();\n}\n"
5
+ "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { defaultModuleLoader } from \"../internal/module-loader/index.cjs\";\nimport { normalizeExplicitModuleResult } from \"../bridge/legacy-adapters.cjs\";\nimport type { HostCallContext, ModuleResolveResult, ModuleResolver, ModuleResolverFallback, ModuleResolverSourceLoader, ModuleSource } from \"../types.cjs\";\n\nclass ModuleResolverBuilder implements ModuleResolver {\n private readonly nodeModuleMappings: Array<{ from: string; to: string }> = [];\n private readonly virtualEntries = new Map<string, { source: ModuleResolveResult | (() => ModuleResolveResult); options?: Partial<ModuleSource> }>();\n private readonly virtualFiles = new Map<string, { filePath: string; options?: Partial<ModuleSource> }>();\n private readonly sourceTrees: Array<{ prefix: string; loader: ModuleResolverSourceLoader }> = [];\n private fallbackLoader?: ModuleResolverFallback;\n private nodeModulesLoader?: ReturnType<typeof defaultModuleLoader>;\n\n mountNodeModules(virtualMount: string, hostPath: string): ModuleResolver {\n this.nodeModuleMappings.push({ from: hostPath, to: virtualMount });\n this.nodeModulesLoader = undefined;\n return this;\n }\n\n virtual(specifier: string, source: ModuleResolveResult | (() => ModuleResolveResult), options?: Partial<ModuleSource>): ModuleResolver {\n this.virtualEntries.set(specifier, { source, options });\n return this;\n }\n\n virtualFile(specifier: string, filePath: string, options?: Partial<ModuleSource>): ModuleResolver {\n this.virtualFiles.set(specifier, { filePath, options });\n return this;\n }\n\n sourceTree(prefix: string, loader: ModuleResolverSourceLoader): ModuleResolver {\n this.sourceTrees.push({ prefix, loader });\n return this;\n }\n\n fallback(loader: ModuleResolverFallback): ModuleResolver {\n this.fallbackLoader = loader;\n return this;\n }\n\n async resolve(specifier: string, importer: { path: string; resolveDir: string }, context: HostCallContext): Promise<ModuleSource> {\n let nodeModulesError: unknown;\n\n const explicit = this.virtualEntries.get(specifier);\n if (explicit) {\n const raw = typeof explicit.source === \"function\" ? await explicit.source() : await explicit.source;\n const normalized = await normalizeExplicitModuleResult(specifier, raw, importer.resolveDir);\n if (!normalized) {\n throw new Error(`Virtual module ${specifier} returned no source.`);\n }\n return {\n ...normalized,\n ...explicit.options,\n };\n }\n\n const virtualFile = this.virtualFiles.get(specifier);\n if (virtualFile) {\n const code = fs.readFileSync(virtualFile.filePath, \"utf-8\");\n const fallback = await normalizeExplicitModuleResult(\n specifier,\n {\n code,\n filename: virtualFile.options?.filename ?? path.basename(virtualFile.filePath),\n resolveDir: virtualFile.options?.resolveDir ?? path.posix.dirname(specifier.startsWith(\"/\") ? specifier : `/${specifier}`),\n static: virtualFile.options?.static,\n },\n importer.resolveDir,\n );\n if (!fallback) {\n throw new Error(`Virtual file module ${specifier} returned no source.`);\n }\n return fallback;\n }\n\n for (const sourceTree of this.sourceTrees) {\n if (!specifier.startsWith(sourceTree.prefix)) {\n continue;\n }\n const relativePath = specifier.slice(sourceTree.prefix.length);\n const normalized = await normalizeExplicitModuleResult(specifier, sourceTree.loader(relativePath, context), importer.resolveDir);\n if (normalized) {\n return normalized;\n }\n }\n\n if (this.nodeModuleMappings.length > 0) {\n try {\n return await this.getNodeModulesLoader()(specifier, importer);\n } catch (error) {\n nodeModulesError = error;\n if (!this.fallbackLoader) {\n throw error;\n }\n }\n }\n\n if (this.fallbackLoader) {\n const normalized = await normalizeExplicitModuleResult(specifier, this.fallbackLoader(specifier, importer, context), importer.resolveDir);\n if (normalized) {\n return normalized;\n }\n }\n\n if (nodeModulesError) {\n throw nodeModulesError;\n }\n\n throw new Error(`Unable to resolve module: ${specifier}`);\n }\n\n private getNodeModulesLoader(): ReturnType<typeof defaultModuleLoader> {\n if (!this.nodeModulesLoader) {\n this.nodeModulesLoader = defaultModuleLoader(...this.nodeModuleMappings);\n }\n return this.nodeModulesLoader;\n }\n}\n\nexport function createModuleResolver(): ModuleResolver {\n return new ModuleResolverBuilder();\n}\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAe,IAAf;AACiB,IAAjB;AACoC,IAApC;AAC8C,IAA9C;AAAA;AAGA,MAAM,sBAAgD;AAAA,EACnC,qBAA0D,CAAC;AAAA,EAC3D,iBAAiB,IAAI;AAAA,EACrB,eAAe,IAAI;AAAA,EACnB,cAA6E,CAAC;AAAA,EACvF;AAAA,EACA;AAAA,EAER,gBAAgB,CAAC,cAAsB,UAAkC;AAAA,IACvE,KAAK,mBAAmB,KAAK,EAAE,MAAM,UAAU,IAAI,aAAa,CAAC;AAAA,IACjE,KAAK,oBAAoB;AAAA,IACzB,OAAO;AAAA;AAAA,EAGT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A,MACvB,MAAM,aAAa,MAAM,qDAA8B,WAAW,KAAK,eAAe,WAAW,UAAU,OAAO,GAAG,SAAS,UAAU;AAAA,MACxI,IAAI,YAAY;AAAA,QACd,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,IAAI,kBAAkB;AAAA,MACpB,MAAM;AAAA,IACR;AAAA,IAEA,MAAM,IAAI,MAAM,6BAA6B,WAAW;AAAA;AAAA,EAGlD,oBAAoB,GAA2C;AAAA,IACrE,IAAI,CAAC,KAAK,mBAAmB;AAAA,MAC3B,KAAK,oBAAoB,yCAAoB,GAAG,KAAK,kBAAkB;AAAA,IACzE;AAAA,IACA,OAAO,KAAK;AAAA;AAEhB;AAEO,SAAS,oBAAoB,GAAmB;AAAA,EACrD,OAAO,IAAI;AAAA;",
8
+ "debugId": "F4C37D8B8A6E243564756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/isolate",
3
- "version": "0.1.7",
3
+ "version": "0.1.10",
4
4
  "type": "commonjs"
5
5
  }
@@ -287,6 +287,45 @@ function logRuntimeLifecycle(state, event, instance, reason, level = "log") {
287
287
  const reasonSuffix = reason ? `: ${reason}` : "";
288
288
  logger(`[isolate-daemon] ${event} runtime ${formatRuntimeLabel(instance)}${poisonedSuffix}${reasonSuffix}; ${formatRuntimePoolSnapshot(collectRuntimePoolSnapshot(state))}`);
289
289
  }
290
+ function formatDebugValue(value) {
291
+ if (typeof value === "string") {
292
+ return JSON.stringify(value);
293
+ }
294
+ if (typeof value === "number" || typeof value === "boolean" || value === null) {
295
+ return String(value);
296
+ }
297
+ try {
298
+ return JSON.stringify(value);
299
+ } catch {
300
+ return JSON.stringify(String(value));
301
+ }
302
+ }
303
+ function formatDebugFields(fields) {
304
+ return Object.entries(fields).filter(([, value]) => value !== undefined).map(([key, value]) => `${key}=${formatDebugValue(value)}`).join(" ");
305
+ }
306
+ function isDisposedOperationError(error) {
307
+ const text = getErrorText(error).toLowerCase();
308
+ return text.includes("disposed");
309
+ }
310
+ function buildRuntimeDebugFields(instance, connection, extras = {}) {
311
+ return {
312
+ isolateId: instance.isolateId,
313
+ namespaceId: instance.namespaceId ?? null,
314
+ pooled: instance.isDisposed,
315
+ ownerMatches: instance.ownerConnection === connection.socket,
316
+ connectionOwnsIsolate: connection.isolates.has(instance.isolateId),
317
+ runtimeAbortAborted: instance.runtimeAbortController?.signal.aborted ?? null,
318
+ disposedForMs: instance.disposedAt !== undefined ? Date.now() - instance.disposedAt : null,
319
+ callbackConnectionPresent: !!instance.callbackContext?.connection,
320
+ reconnectPending: !!instance.callbackContext?.reconnectionPromise,
321
+ callbackRegistrations: instance.callbacks.size,
322
+ ...extras
323
+ };
324
+ }
325
+ function logSuspiciousRuntimeOperation(state, operation, instance, connection, extras = {}, level = "warn") {
326
+ const logger = level === "warn" ? console.warn : console.log;
327
+ logger(`[isolate-daemon] ${operation} runtime ${formatRuntimeLabel(instance)}; ${formatRuntimePoolSnapshot(collectRuntimePoolSnapshot(state))} ${formatDebugFields(buildRuntimeDebugFields(instance, connection, extras))}`);
328
+ }
290
329
  async function hardDeleteRuntime(instance, state, reason) {
291
330
  const wasPooled = instance.isDisposed;
292
331
  try {
@@ -319,6 +358,8 @@ async function hardDeleteRuntime(instance, state, reason) {
319
358
  }
320
359
  var RECONNECTION_TIMEOUT_MS = 30000;
321
360
  function softDeleteRuntime(instance, state, reason) {
361
+ const runtimeAbortWasAborted = instance.runtimeAbortController?.signal.aborted ?? false;
362
+ const hadCallbackConnection = !!instance.callbackContext?.connection;
322
363
  if (instance.runtimeAbortController && !instance.runtimeAbortController.signal.aborted) {
323
364
  instance.runtimeAbortController.abort(new Error(reason ?? "Runtime was soft-disposed"));
324
365
  }
@@ -356,8 +397,19 @@ function softDeleteRuntime(instance, state, reason) {
356
397
  instance.returnedIterators?.clear();
357
398
  instance.runtime.clearModuleCache();
358
399
  logRuntimeLifecycle(state, "soft-disposed", instance, reason);
400
+ console.warn(`[isolate-daemon] soft-dispose state runtime ${formatRuntimeLabel(instance)}; ${formatRuntimePoolSnapshot(collectRuntimePoolSnapshot(state))} ${formatDebugFields({
401
+ runtimeAbortWasAborted,
402
+ runtimeAbortAborted: instance.runtimeAbortController?.signal.aborted ?? null,
403
+ hadCallbackConnection,
404
+ callbackConnectionPresent: !!instance.callbackContext?.connection,
405
+ reconnectPending: !!instance.callbackContext?.reconnectionPromise,
406
+ callbackRegistrations: instance.callbacks.size
407
+ })}`);
359
408
  }
360
409
  function reuseNamespacedRuntime(instance, connection, message, state) {
410
+ const disposedForMs = instance.disposedAt !== undefined ? Date.now() - instance.disposedAt : null;
411
+ const runtimeAbortWasAborted = instance.runtimeAbortController?.signal.aborted ?? false;
412
+ const reconnectWasPending = !!instance.callbackContext?.reconnectionPromise;
361
413
  instance.ownerConnection = connection.socket;
362
414
  instance.isDisposed = false;
363
415
  instance.isPoisoned = false;
@@ -468,6 +520,11 @@ function reuseNamespacedRuntime(instance, connection, message, state) {
468
520
  instance.returnedIterators = new Map;
469
521
  instance.nextLocalCallbackId = 1e6;
470
522
  logRuntimeLifecycle(state, "reused pooled", instance);
523
+ logSuspiciousRuntimeOperation(state, "reuse state", instance, connection, {
524
+ disposedForMs,
525
+ runtimeAbortWasAborted,
526
+ reconnectWasPending
527
+ }, "log");
471
528
  }
472
529
  async function waitForConnection(callbackContext) {
473
530
  if (callbackContext.connection) {
@@ -1138,6 +1195,12 @@ async function handleDispatchRequest(message, connection, state) {
1138
1195
  sendError(connection.socket, message.requestId, ErrorCode.ISOLATE_NOT_FOUND, `Isolate not found: ${message.isolateId}`);
1139
1196
  return;
1140
1197
  }
1198
+ if (instance.isDisposed) {
1199
+ logSuspiciousRuntimeOperation(state, "dispatchRequest received for pooled", instance, connection, {
1200
+ method: message.request.method,
1201
+ url: message.request.url
1202
+ });
1203
+ }
1141
1204
  instance.lastActivity = Date.now();
1142
1205
  const dispatchAbortController = new AbortController;
1143
1206
  connection.dispatchAbortControllers.set(message.requestId, dispatchAbortController);
@@ -1183,6 +1246,13 @@ async function handleDispatchRequest(message, connection, state) {
1183
1246
  }
1184
1247
  } catch (err) {
1185
1248
  const error = err;
1249
+ if (instance.isDisposed || isDisposedOperationError(error)) {
1250
+ logSuspiciousRuntimeOperation(state, "dispatchRequest failed", instance, connection, {
1251
+ method: message.request.method,
1252
+ url: message.request.url,
1253
+ error: error.message
1254
+ });
1255
+ }
1186
1256
  sendError(connection.socket, message.requestId, ErrorCode.SCRIPT_ERROR, error.message, { name: error.name, stack: error.stack });
1187
1257
  } finally {
1188
1258
  connection.dispatchAbortControllers.delete(message.requestId);
@@ -1301,12 +1371,20 @@ async function handleFetchGetUpgradeRequest(message, connection, state) {
1301
1371
  sendError(connection.socket, message.requestId, ErrorCode.ISOLATE_NOT_FOUND, `Isolate not found: ${message.isolateId}`);
1302
1372
  return;
1303
1373
  }
1374
+ if (instance.isDisposed) {
1375
+ logSuspiciousRuntimeOperation(state, "getUpgradeRequest received for pooled", instance, connection);
1376
+ }
1304
1377
  instance.lastActivity = Date.now();
1305
1378
  try {
1306
1379
  const upgradeRequest = instance.runtime.fetch.getUpgradeRequest();
1307
1380
  sendOk(connection.socket, message.requestId, upgradeRequest);
1308
1381
  } catch (err) {
1309
1382
  const error = err;
1383
+ if (instance.isDisposed || isDisposedOperationError(error)) {
1384
+ logSuspiciousRuntimeOperation(state, "getUpgradeRequest failed", instance, connection, {
1385
+ error: error.message
1386
+ });
1387
+ }
1310
1388
  sendError(connection.socket, message.requestId, ErrorCode.SCRIPT_ERROR, error.message, { name: error.name, stack: error.stack });
1311
1389
  }
1312
1390
  }
@@ -1316,12 +1394,20 @@ async function handleFetchHasServeHandler(message, connection, state) {
1316
1394
  sendError(connection.socket, message.requestId, ErrorCode.ISOLATE_NOT_FOUND, `Isolate not found: ${message.isolateId}`);
1317
1395
  return;
1318
1396
  }
1397
+ if (instance.isDisposed) {
1398
+ logSuspiciousRuntimeOperation(state, "hasServeHandler received for pooled", instance, connection);
1399
+ }
1319
1400
  instance.lastActivity = Date.now();
1320
1401
  try {
1321
1402
  const hasHandler = instance.runtime.fetch.hasServeHandler();
1322
1403
  sendOk(connection.socket, message.requestId, hasHandler);
1323
1404
  } catch (err) {
1324
1405
  const error = err;
1406
+ if (instance.isDisposed || isDisposedOperationError(error)) {
1407
+ logSuspiciousRuntimeOperation(state, "hasServeHandler failed", instance, connection, {
1408
+ error: error.message
1409
+ });
1410
+ }
1325
1411
  sendError(connection.socket, message.requestId, ErrorCode.SCRIPT_ERROR, error.message, { name: error.name, stack: error.stack });
1326
1412
  }
1327
1413
  }
@@ -1331,12 +1417,20 @@ async function handleFetchHasActiveConnections(message, connection, state) {
1331
1417
  sendError(connection.socket, message.requestId, ErrorCode.ISOLATE_NOT_FOUND, `Isolate not found: ${message.isolateId}`);
1332
1418
  return;
1333
1419
  }
1420
+ if (instance.isDisposed) {
1421
+ logSuspiciousRuntimeOperation(state, "hasActiveConnections received for pooled", instance, connection);
1422
+ }
1334
1423
  instance.lastActivity = Date.now();
1335
1424
  try {
1336
1425
  const hasConnections = instance.runtime.fetch.hasActiveConnections();
1337
1426
  sendOk(connection.socket, message.requestId, hasConnections);
1338
1427
  } catch (err) {
1339
1428
  const error = err;
1429
+ if (instance.isDisposed || isDisposedOperationError(error)) {
1430
+ logSuspiciousRuntimeOperation(state, "hasActiveConnections failed", instance, connection, {
1431
+ error: error.message
1432
+ });
1433
+ }
1340
1434
  sendError(connection.socket, message.requestId, ErrorCode.SCRIPT_ERROR, error.message, { name: error.name, stack: error.stack });
1341
1435
  }
1342
1436
  }
@@ -1993,4 +2087,4 @@ export {
1993
2087
  handleConnection
1994
2088
  };
1995
2089
 
1996
- //# debugId=665A564AAE317D3264756E2164756E21
2090
+ //# debugId=46DF7C47935922C664756E2164756E21