-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8.1.3 - Issue with running program when zx is webpacked due to deno.js #957
Comments
Provide a full reproducible example / repo ref plz. |
Sure, the readme explains the steps to reproduce this problem: |
This is definitely not zx or deno issue. I'm afraid webpack does not build the module tree properly, when ESM module uses the require API. But you can point the bundler to the cjs entry by hand: resolve: {
// Add '.ts' as a resolvable extension.
extensions: ['.ts', '.js'],
symlinks: false,
alias: {
"zx/build/index.js": "./node_modules/zx/build/index.cjs"
}
// plugins: [new TsconfigPathsPlugin({ extensions: ['.ts', '.js'] })],
}, |
Thanks, I’ll apply this for the time being. What is the reason for using require instead of regular imports here? When I replace require with import, everything starts to work correctly, at least in the Node.js environment and in my simple example: main.mjs import { $ } from 'zx';
$.verbose = true;
await $`echo "Hello, world!"`; |
The alias below woks for me: {
resolve: {
extensions: ['.ts', '.js'],
symlinks: false,
alias: {
"zx": path.resolve(__dirname, 'node_modules/zx/build/index.cjs'),
},
},
} |
This is a limitation of our bundler plugin for now: |
* build: use reexport to bind esm and cjs bundles closes #957 * chore: update esbuild-hybrid-plugin to v0.3.1
Try v8.2.3-dev.b15179f and allow cjs here resolve: {
// Add '.ts' as a resolvable extension.
extensions: ['.ts', '.js', ".cjs"], |
@antongolub Thanks, I confirm that it bundles all files now (lines comes from resolve plugin): plugin: {
apply(resolver: Resolver) {
resolver.getHook('before-resolve')
.tapAsync('AddonPlugin', (request, _resolveContext, callback) => {
console.log(request.path, request.request);
callback();
});
}
} I can still see full deno.js file path in my output, however this doesn't cause any problem now since require isn't used any longer: |
Hello,
I noticed an issue with zx version 8.1.3 and newer, where zx does not work well with Webpack. The problem occurs when the program tries to load deno.js, which does not exist after bundling the application. 8.1.2 seems to work fine, although reference to
node_modules/zx/build/deno.js
is the output file since 8.1.0.tsconfig:
The text was updated successfully, but these errors were encountered: