Skip to content

Dynamic import of proxy-agent breaks bun single executable bundling #861

@vladfrangu

Description

@vladfrangu

Source code:

import { ApifyClient } from 'apify-client';

const client = new ApifyClient({
	token: process.env.APIFY_TOKEN,
});

const me = await client.user('me').get();

console.log(me);

Running like this works: APIFY_TOKEN="apify_api_you_wish" bun src/index.ts

Building into a single executable like so: bun build src/index.ts --target node --compile --outfile apifyclient followed by running it does not, and throws error: Cannot find package 'proxy-agent' from '/$bunfs/root/apifyclient'

In apify-cli I had to basically build bundles in 2 steps:

  1. single file executable that manually imports proxy-agent by adding in a import {} from "proxy-agent"
  2. patch the result to reference the manual import.

See the diff from the PR

Metadata

Metadata

Assignees

Labels

t-toolingIssues with this label are in the ownership of the tooling team.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions