Bundled Output Missing core.cjs File When Using esbuild with zx Library #895
-
🐛 Bug ReportProblem DescriptionI encountered an issue when using esbuild to bundle a project that imports the zx library. The bundled output file fails to run due to the absence of the core.cjs file, which is required by the Steps to Reproduce
Expected BehaviorThe bundled JavaScript file should run without errors, and the functionality from the Actual BehaviorAfter bundling with Reproduction Files
import { $ } from 'zx/core';
const main = async () => {
const list = ['5', '10', '15', '20', '25'];
for (const item of list) {
console.log(`${item} start`);
await $`sleep ${item}`;
console.log(`${item} end`);
}
}
main();
"use strict";
// node_modules/.pnpm/[email protected]/node_modules/zx/build/deno.js
var import_node_module = require("node:module");
var import_meta = {};
var require2 = (0, import_node_module.createRequire)(import_meta.url);
var __filename = new URL(import_meta.url).pathname;
var __dirname = new URL(".", import_meta.url).pathname;
if (globalThis.Deno) {
globalThis.require = require2;
globalThis.__filename = __filename;
globalThis.__dirname = __dirname;
}
// node_modules/.pnpm/[email protected]/node_modules/zx/build/core.js
var {
$,
ProcessOutput,
ProcessPromise,
cd,
defaults,
kill,
log,
syncProcessCwd,
useBash,
usePowerShell,
usePwsh,
within
} = require2("./core.cjs");
// test.ts
var main = async () => {
const list = ["5", "10", "15", "20", "25"];
for (const item of list) {
console.log(`${item} start`);
await $`sleep ${item}`;
console.log(`${item} end`);
}
};
main(); Build CommandThe command used for bundling: Specifications
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm afraid, the issue is on esbuild's side: evanw/esbuild#1828 |
Beta Was this translation helpful? Give feedback.
-
You may try smth like this: |
Beta Was this translation helpful? Give feedback.
@shetz163,
You may try smth like this:
--alias:zx/core=./node_modules/zx/build/core.cjs