Skip to content

fix(hir): resolve CJS worker path joins#4815

Merged
proggeramlug merged 2 commits into
PerryTS:mainfrom
JagritGumber:fix/worker-static-path-join
Jun 9, 2026
Merged

fix(hir): resolve CJS worker path joins#4815
proggeramlug merged 2 commits into
PerryTS:mainfrom
JagritGumber:fix/worker-static-path-join

Conversation

@JagritGumber

Copy link
Copy Markdown
Contributor

Summary

  • Normalize Windows source paths before lowering __dirname and import.meta path fields.
  • Let the static import/worker filename resolver fold deterministic CommonJS path shapes like string .replace(...) and path.default.join(...).
  • Add regression coverage for the Windows node-pty worker path shape and closure-contained WorkerNew discovery.

Why

Some CommonJS packages construct worker entry filenames through deterministic path expressions instead of direct literals. One concrete shape is path.join(__dirname.replace(...), "worker/file.js"). Before this change Perry could not resolve that worker filename, so module collection stopped before the worker module was registered.

This does not add native .node addon loading. In the node-pty probe, this change gets Perry past worker module collection and compilation; executing the compiled probe still reaches the existing native-addon boundary at require("./prebuilds/win32-x64/pty.node").

Tests

  • cargo fmt -p perry-hir --check
  • cargo test -p perry-hir dynamic_import::tests --message-format=short

@proggeramlug proggeramlug merged commit ddc334f into PerryTS:main Jun 9, 2026
13 checks passed
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