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

require.main not working #1045

Closed
metachris opened this issue Mar 24, 2021 · 1 comment
Closed

require.main not working #1045

metachris opened this issue Mar 24, 2021 · 1 comment

Comments

@metachris
Copy link

This typical pattern doesn't work in a bundled output script:

if (require.main === module) {
  // ...
}

See also #560

Output during build:

 > src/main.ts:8:4: warning: Indirect calls to "require" will not be bundled (surround with a try/catch to silence this warning)
    8 │ if (require.main === module) {
      ╵     ~~~~~~~
@metachris
Copy link
Author

Sorry my mistake, needed to add --platform=node

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

No branches or pull requests

1 participant