Skip to content
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

feat(endo): Module specifier and URL math #342

Merged
merged 7 commits into from
Jun 24, 2020
Merged

feat(endo): Module specifier and URL math #342

merged 7 commits into from
Jun 24, 2020

Conversation

kriskowal
Copy link
Member

The url.js module implements relative(referrer, specifier) to reconstruct a relative path between two URLs. This is useful for creating references in a compartmap.json that are normalized relative to the root of an archive.

The remaining module-specifier.js provides three functions for manipulating Node.js packaged module specifiers.

The Node.js package.json allows relative or absolute module specifiers
like "main": "./index.js" or "main": "index.js".
The relativize function normalizes all such paths to their relative
form since Endo compartments use absolute specifiers for external
linkage and relative specifiers for internal linkage.
It is not possible for package.json to express a module specifier
that refers to a module in another package.

The join function joins an absolute module specifier to a relative
module specifier.
Creating a compartment map joins external dependency package names to
internal module specifiers.
The external dependency specifier must be absolute and the internal
module specifier must be relative.

Endo uses this resolve function for all compartment resolve hooks.
The referrer is always a relative module specifier like "./index.js".
The referent may be relative to import a module in the same package, or
absolute to import an external dependency, either a built-in module or a
module from a third-party package.

Base automatically changed from kris/endo-scaffold to master June 18, 2020 17:48
@kriskowal kriskowal force-pushed the kris/endo-math branch 2 times, most recently from 10925df to 650af99 Compare June 18, 2020 19:06
@kriskowal kriskowal requested a review from warner June 18, 2020 21:55
@kriskowal kriskowal force-pushed the kris/endo-math branch 3 times, most recently from c148ba9 to 16d2824 Compare June 19, 2020 00:33
@kriskowal kriskowal mentioned this pull request Jun 19, 2020
36 tasks
@kriskowal kriskowal force-pushed the kris/endo-math branch 4 times, most recently from b2c8412 to cdd3511 Compare June 19, 2020 20:21
Copy link
Contributor

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those issues are minor, feel free to land

packages/endo/src/node-module-specifier.js Outdated Show resolved Hide resolved
packages/endo/src/node-module-specifier.js Outdated Show resolved Hide resolved
@kriskowal kriskowal force-pushed the kris/endo-math branch 2 times, most recently from 00323de to c0a1c68 Compare June 24, 2020 02:57
The Node.js package.json allows relative or absolute module specifiers
like `"main": "./index.js"` or `"main": "index.js"`.
The `relativize` function normalizes all such paths to their relative
form since Endo compartments use absolute specifiers for external
linkage and relative specifiers for internal linkage.
It is not possible for `package.json` to express a module specifier
that refers to a module in another package.

The join function joins an absolute module specifier to a relative
module specifier.
Creating a compartment map joins external dependency package names to
internal module specifiers.
The external dependency specifier must be absolute and the internal
module specifier must be relative.

Endo uses this resolve function for all compartment resolve hooks.
The referrer is always a relative module specifier like "./index.js".
The referent may be relative to import a module in the same package, or
absolute to import an external dependency, either a built-in module or a
module from a third-party package.
@kriskowal kriskowal merged commit 96edfab into master Jun 24, 2020
@kriskowal kriskowal deleted the kris/endo-math branch June 24, 2020 03:08
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