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

Warning-free hack for ergonomic require of cjs esbuild plugin #718

Merged
merged 1 commit into from
Sep 10, 2023

Conversation

edemaine
Copy link
Collaborator

It's still a bit hacky, but at least it doesn't cause esbuild to generate a loud warning.

Tested:

  • require('./dist/esbuild-plugin.js') in node CLI (produces function)
  • import plugin from './dist/esbuild-plugin.js' in a file test.mjs (produces function)
  • yarn test

Based on egoist/tsup#572 (comment). Also, it looks like if we used tsup for this (we already do for the unplugin), there's a cleaner solution: https://tsup.egoist.dev/#interop-with-commonjs

@edemaine edemaine temporarily deployed to build September 10, 2023 02:27 — with GitHub Actions Inactive
Copy link
Contributor

@STRd6 STRd6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only thing to note is that this depends on having a single export. We could expand it later if we need to.

@edemaine edemaine merged commit ef4ba0c into main Sep 10, 2023
@edemaine edemaine deleted the esbuild-plugin-cjs branch September 10, 2023 11:29
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

Successfully merging this pull request may close these issues.

2 participants