Skip to content

Recommended strategy for packaging Ink applications with pkg #844

@Niladri2003

Description

@Niladri2003

Thank you for the ink package it is really awesome ! :)
I am trying to distribute an Ink-based CLI as a single standalone binary using pkg (or @yao-pkg/pkg).

The Problem

Packaging Ink has become difficult for me due to the transition to ESM and the inclusion of Top-Level Await (TLA) in dependencies like yoga-layout. Specifically:

Top-Level Await: Modern versions of Ink/Yoga trigger ERR_REQUIRE_ASYNC_MODULE when bundled into a CommonJS format for pkg.

Resolution Errors: Even when using import(), pkg often fails to resolve internal Ink files (like render.js) from within its virtual snapshot filesystem.

What I've Tried

  • Bundling with Rollup/NCC/esbuild: Attempted to flatten everything into a single .cjs file, but this is blocked by the Top-Level Await in the dependency tree.
  • pkg with ESM: Attempted to point pkg to an ESM entry point, but it fails to handle dynamic imports/resolution within the snapshot.

Is there any recommended way to package and distribute clis build using ink and packaged using pkg ?

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