Repository navigation
Conversation
…piled binaries After the host-specifier rewrite, onLoad runs rewriteInstalledPackageSpecifiers on the transpiled source of every file under the extension directory, including packages installed inside it. Each static bare specifier in import, export-from, import(), or require() is replaced with the file installed for it: a file URL for the module forms, and an escaped absolute path for require(). Resolution uses Bun.resolveSync when that path exists on disk, then createRequire from the importer, then the package root import or default export when require cannot read an import-only exports map. Relative paths, Node and Bun builtins, hunk-host and file URLs, and packages neither resolver can find stay as written, so a missing package still fails with the existing error. Fixes modem-dev#1136
Contributor
|
PR author is not in the allowed authors list. |
|
@mvanhorn is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After the host-specifier rewrite, onLoad runs rewriteInstalledPackageSpecifiers on the transpiled source of every file under the extension directory, including packages installed inside it. Each static bare specifier in import, export-from, import(), or require() is replaced with the file installed for it: a file URL for the module forms, and an escaped absolute path for require(). Resolution uses Bun.resolveSync when that path exists on disk, then createRequire from the importer, then the package root import or default export when require cannot read an import-only exports map. Relative paths, Node and Bun builtins, hunk-host and file URLs, and packages neither resolver can find stay as written, so a missing package still fails with the existing error.
A folder extension that imports a package installed in its own node_modules fails to load when Hunk is the compiled binary. The status bar reports that the package cannot be found from the extension entry, and the extension action does nothing. The same package imported by a relative path into that node_modules loads. Extension source is returned as contents from the Bun plugin onLoad hook after transpilation. In a compiled binary those bare specifiers are not resolved from the extension file, so the folder-local node_modules is never opened. Relative specifiers still resolve from that file.
Verification
./scripts/quality/source-boundaries.test.tscould not run in this environment (./scripts/quality/source-boundaries.test.ts is not executable).Fixes #1136