Skip to content

fix: compile packages that export dirname paths as object shorthand - #1348

Open
umeraamir69 wants to merge 1 commit into
vercel:mainfrom
umeraamir69:fix/ngrok-dirname-shorthand
Open

umeraamir69 wants to merge 1 commit into
vercel:mainfrom
umeraamir69:fix/ngrok-dirname-shorthand

Conversation

@umeraamir69

Copy link
Copy Markdown

Summary

  • ncc build of a file that uses ngrok.connect() failed in webpack parse after relocate-loader. ngrok exports a __dirname join as object shorthand ({ defaultDir, bin }); relocate rewrote that shorthand into __webpack_require__.ab + "bin", which is not valid JS.
  • Relocate now sees defaultDir: defaultDir first, so the key stays an identifier and the value becomes __nccwpck_require__.ab + "bin". The ngrok binary is still emitted as an asset.
  • The expand runs inside the existing relocate-loader wrapper, so other unit snapshots keep their module ids.

Fixes #1255

Test plan

  • jest test/expand-shorthand.test.js (helper: expand shorthand, leave unrelated files alone)
  • jest test/unit.test.js -t dirname-shorthand-export --globals '{"coverage":true}' (fake ngrok package that used to throw the parse error)
  • Existing unit fixtures still match (custom-emit, shebang, externals, runtime-notfound, and the rest of the coverage unit suite)
  • pnpm build && pnpm test on CI

Relocate rewrote ngrok-style `{ defaultDir }` exports into invalid JS.
Expand those shorthands first so the key stays an identifier.
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.

VCC cannot transpile ngrok

1 participant