Skip to content

Conversation

@oldium
Copy link

@oldium oldium commented Oct 28, 2025

New yargs version bundling is failing, because it is newly ESM-only module:

  • It is not included in esbuild and pkg does not patch ESM import paths.
  • If added into esbuild, the transpiled import.meta.url is empty and execution fails.

Fix this by letting esbuild transpile also yargs to CJS, but provide a sensible value for import.meta.url as mentioned in the esbuild bug report.

While at it, also update @yao-pkg/pkg to support newer Node.js runtime.

Supercedes: #1577

@oldium oldium force-pushed the feature/yargs-update branch 2 times, most recently from 4291322 to 9d91f95 Compare October 28, 2025 18:35
New `yargs` version bundling is failing, because it is newly ESM-only
module:

 * It is not included in `esbuild` and `pkg` does not patch [ESM import
   paths][1].
 * If added into `esbuild`, the transpiled `import.meta.url` is empty and
   execution fails.

Fix this by letting `esbuild` transpile also `yargs` to CJS, but provide a
sensible value for `import.meta.url` as mentioned in the `esbuild` [bug
report][2].

While at it, also update `@yao-pkg/pkg` to support newer Node.js runtime.

[1]: yao-pkg/pkg#16 (comment)
[2]: evanw/esbuild#2441 (comment)

Signed-off-by: Oldřich Jedlička <[email protected]>
@oldium oldium force-pushed the feature/yargs-update branch from 9d91f95 to 2e077a7 Compare October 28, 2025 18:36
@oldium
Copy link
Author

oldium commented Oct 28, 2025

Ha! The yargs locales are probably missing due to this.

@oldium
Copy link
Author

oldium commented Oct 28, 2025

Hm. I am able to get also locales working locally, but when packed with pkg, the --help option gets to segmentation fault... I have no solution for this.

@oldium
Copy link
Author

oldium commented Oct 28, 2025

I will leave it here in this state, feel free to close it if you do not want to continue on it.

@oldium
Copy link
Author

oldium commented Oct 28, 2025

Maybe try Node.js experimental Single Executable Applications?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant