Skip to content

Bug: .d.ts amd-module directive hardcodes absolute build path, breaks CommonJS consumers #165

Description

@abretonc7s

Summary

Published @nktkas/hyperliquid (0.33.0, 0.33.1) ships its .d.ts files with a triple-slash directive hardcoding an absolute build-machine path:

/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/mod.ts" />

This appears in ~220 .d.ts files (entry esm/mod.d.ts names src/mod.ts). It's an artifact of the Deno→npm (dnt) build.

Impact

Any CommonJS build tool that derives the require() target from the amd-module name emits the absolute path into its .cjs output:

const hyperliquid_1 = require("file:///home/runner/work/hyperliquid/hyperliquid/src/mod.ts");

That path exists on no consumer machine, so CJS/bundler/Jest loads throw Cannot find module. ESM is unaffected. Consumers currently have to patch the shipped .d.ts to strip the directive.

Reproduce

  1. Install @nktkas/hyperliquid@0.33.1.
  2. grep -rl "amd-module" node_modules/@nktkas/hyperliquid → ~220 files with the file:///home/runner/... path.
  3. Build a CJS consumer with a tool that honors amd-module → the absolute path leaks into require().

Suggested fix

Strip (or don't emit) the amd-module directives in the dnt build so .d.ts files don't carry the build machine's absolute path. Last version without them was 0.32.2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions