这是indexloc提供的服务,不要输入任何密码
Skip to content

feat(minor): support node: import in older node versions #460

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

Merged
merged 1 commit into from
Nov 20, 2021
Merged

feat(minor): support node: import in older node versions #460

merged 1 commit into from
Nov 20, 2021

Conversation

privatenumber
Copy link
Contributor

Problem

Bundling a dependency with import fs from 'node:fs' didn't work with Node v12 because it would convert the import statement to a require, which requires Node v14.18.0.

Changes

  • Add a simple esbuild plugin to strip the node: protocol
  • Remove the disabled option in externalPlugin in favor of not passing it into esbuild in the first place. Minor performance nitpick since I didn't want to have two different ways of disabling plugins.

@vercel
Copy link

vercel bot commented Nov 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/egoist/tsup/Fo7kSh9BkouZpEP9zEhJa5ZXwteV
✅ Preview: https://tsup-git-fork-privatenumber-support-node-protocol-egoist.vercel.app

@egoist egoist changed the title feat: support node protocol feat(minor): support node: import in older node versions Nov 20, 2021
@egoist egoist merged commit c78ea9c into egoist:master Nov 20, 2021
@github-actions
Copy link
Contributor

🎉 This PR is included in version 5.7.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

RobinTail added a commit to RobinTail/express-zod-api that referenced this pull request Jul 23, 2024
Node protocol removal was introduced here for CJS:
egoist/tsup#460

The target was set to `es2022` which does not explicitly address Node,
therefore it was removed for ESM too.

Setting the target to `node18.18.0` enabled the protocol for ESM.

The recently added setting allows also to enable it for CJS:

egoist/tsup@e7ced34

This will certainly not work in Node below 14.18, but it should not
anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants