Skip to content

tsdown shims are not available after migration to vite+ #999

@alexfigliolia

Description

@alexfigliolia

Describe the bug

I migrated a node.js project using tsdown to vite+ and noticed that tsdown's shims are not bundled with the vite+ installation. When running vp pack with shims: true the command fails because the build process cannot find node_modules/tsdown/esm-shims.js.

The shims are used for transforming __dirname and __filename references for ESM compatibility

In tsdown esm-shims.js is a static file currently sitting at the root of the repository

Reproduction

https://github.com/alexfigliolia/vite-plus-minimal-reproduction

Steps to reproduce

  1. Create a small node.js project and configure the vite+ pack options to specify shims: true.
  2. Create file to build that uses the __filename or __dirname global
  3. Run vp pack

System Info

VITE+ - The Unified Toolchain for the Web

Environment:
  Version  24.14.0
  Source   lts

Tool Paths:
  node  /.vite-plus/js_runtime/node/24.14.0/bin/node
  npm   /.vite-plus/js_runtime/node/24.14.0/bin/npm
  npx   /.vite-plus/js_runtime/node/24.14.0/bin/npx



VITE+ - The Unified Toolchain for the Web

vp v0.1.12

Local vite-plus:
  vite-plus  v0.1.12

Tools:
  vite             v8.0.0
  rolldown         v1.0.0-rc.9
  vitest           v4.1.0
  oxfmt            v0.40.0
  oxlint           v1.55.0
  oxlint-tsgolint  v0.17.0
  tsdown           v0.21.3

Environment:
  Package manager  yarn v4.0.2
  Node.js          Not found

Used Package Manager

yarn

Logs

error: Build failed with 1 error:

[UNRESOLVED_IMPORT] Error: Could not resolve '<project>/node_modules/@voidzero-dev/vite-plus-core/dist/esm-shims.js' in <project>/<file-using-__dirname-or__filename>

Validations

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions