Skip to content
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

how to bundle yargs with esbuild #1929

Closed
hardfist opened this issue Apr 28, 2021 · 8 comments · Fixed by #2075
Closed

how to bundle yargs with esbuild #1929

hardfist opened this issue Apr 28, 2021 · 8 comments · Fixed by #2075

Comments

@hardfist
Copy link
Contributor

It seems that esbuild will leave import.meta untouched when bundling, which make the bundle code not working for cjs format

@bcoe
Copy link
Member

bcoe commented May 2, 2021

@hardfit could you provide a minimal example I could run, demonstrating the build process.

import.meta should only be used by the ESM version of yargs. If you instead bundle build/index.cjs, it does not expose import.meta.

@hardfist
Copy link
Contributor Author

hardfist commented May 3, 2021

you can reproduce the problem here, https://github.com/hardfist/yargs-bundle

$ yarn install && yarn bundle && node bundle.js

@Wallacy
Copy link

Wallacy commented Sep 15, 2021

FWIW: Change from import yargs from 'yargs' to const yargs = require('yargs') fix my bundle, but that is not ideal anyway.

@bcoe
Copy link
Member

bcoe commented Sep 23, 2021

@Wallacy @hardfist perhaps we could add a guide in bundling, with this workaround for esbuild?

@baob
Copy link

baob commented Nov 1, 2021

Would this be the same problem I'm seeing as Cannot resolve module ...../node_modules/yargs/index.cjs ? when running flow against versions 16 & 17 of yargs ?

@Wallacy
Copy link

Wallacy commented Nov 1, 2021

@Wallacy @hardfist perhaps we could add a guide in bundling, with this workaround for esbuild?

Yes, that works for esbuild.

@bcoe
Copy link
Member

bcoe commented Nov 8, 2021

Perhaps we should add an esbuild sample? anyone interested in contributing?

@xkn1ght
Copy link

xkn1ght commented Nov 26, 2021

seems relative issue: evanw/esbuild#1492

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

Successfully merging a pull request may close this issue.

5 participants