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

fix: remove createRequire for package json #978

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tylersayshi
Copy link
Contributor

follow up to this: #974 (comment)

Copy link

vercel bot commented Oct 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
waku ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2024 2:10pm

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Contributor

@ojj1123 ojj1123 left a comment

Choose a reason for hiding this comment

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

👍👍

Comment on lines 10 to 11
banner: {
js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url);`,
Copy link
Contributor

Choose a reason for hiding this comment

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

You removed createRequire, but Is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prompts dynamically requires readline causing this error when the banner is omitted:

Error: Dynamic require of "readline" is not supported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could look into moving to inquirer.js from prompts:

https://github.com/SBoudrias/Inquirer.js

It seems like it is more actively maintained, so I'd imagine the esm support is more up to date and we could then remove this banner.

Copy link
Contributor

@ojj1123 ojj1123 Oct 19, 2024

Choose a reason for hiding this comment

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

Yeah It feels like prompts is not almost maintained. But both of them have similar features. I wonder @dai-shi thoughts :)

Copy link
Owner

Choose a reason for hiding this comment

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

Previously, I rejected the idea #339 by @himself65 because I thought it was too early.
But now that we have more active contributors, I think the time is right.
I don't think prompts is too bad, but if you guys have a better alternative, and feel like maintaining it, I'm fine of changing the dependency library, or completely re-implementing it.

format: ['esm'],
minify: !options.watch,
clean: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

clean: true is nice! 👍

// keep original require to avoid
// bundling the whole package.json by `@vercel/ncc`
const packageJson = createRequire(import.meta.url)('../package.json');
const packageJson = await import('../package.json');
Copy link
Owner

Choose a reason for hiding this comment

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

So, is this syntax supported by tsup?

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.

3 participants