Bundled Output Missing core.cjs File When Using esbuild with zx Library #895
Answered
by
antongolub
shetz163
asked this question in
Help needed
🐛 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/zx@8.1.6/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/zx@8.1.6/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
|
Answered by
antongolub
Sep 15, 2024
Replies: 2 comments 1 reply
|
I'm afraid, the issue is on esbuild's side: evanw/esbuild#1828 |
0 replies
|
You may try smth like this: |
1 reply
Answer selected by
shetz163
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@shetz163,
You may try smth like this:
--alias:zx/core=./node_modules/zx/build/core.cjs