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(ses): Module descriptors for XS parity #2345

Merged
merged 8 commits into from
Jul 16, 2024

Conversation

kriskowal
Copy link
Member

@kriskowal kriskowal commented Jul 11, 2024

Refs: #400 #2251

Description

This change introduces support for XS-compatible module descriptors with the discriminating properties source and namespace, including support for loading a module from the parent compartment.

Security Considerations

None.

Scaling Considerations

None.

Documentation Considerations

This change is additive.

Testing Considerations

Covered.

Compatibility Considerations

Some usage patterns are now deprecated but continue to be supported without complaint.

Upgrade Considerations

None.

@kriskowal kriskowal changed the title Kriskowal ses module descriptors xs parity feat(ses): Module descriptors for XS parity Jul 11, 2024
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-refactor branch from 2a29262 to d3d8b9f Compare July 11, 2024 20:32
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from 29e3f8d to 3147a5d Compare July 11, 2024 20:32
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-refactor branch from d3d8b9f to d3b447f Compare July 11, 2024 20:49
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from 3147a5d to 319c8e1 Compare July 11, 2024 20:49
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-refactor branch from d3b447f to 91c3cd3 Compare July 11, 2024 21:06
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from 319c8e1 to 8c74126 Compare July 11, 2024 21:06
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-refactor branch from 91c3cd3 to caf80a9 Compare July 12, 2024 23:33
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from 8c74126 to c7fdfb2 Compare July 12, 2024 23:33
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-refactor branch from caf80a9 to db465e4 Compare July 12, 2024 23:58
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from c7fdfb2 to 6320908 Compare July 12, 2024 23:58
@kriskowal kriskowal requested a review from erights July 12, 2024 23:59
@kriskowal kriskowal marked this pull request as ready for review July 12, 2024 23:59
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from 6320908 to 68d8f93 Compare July 13, 2024 00:27

```js
import 'ses';
import { StaticModuleRecord } from '@endo/static-module-record';
import { StaticModuleRecord as ModuleSource } from '@endo/static-module-record';
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this renaming into @endo/static-module-record , if necessary still continuing to export the old name for now, but deprecated?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, could we also rename the package from static-module-record to module-source?

Copy link
Member Author

Choose a reason for hiding this comment

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

I’ll follow-up. This is a good time.

default `importMeta` object is an empty object.

Compartments copy the `importMeta` object properties into the module
`import.meta` object like `Object.assign`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This is copypasta from XS docs. We don’t actually implement importMeta yet, but if we did, we’d use Object.assign.


- Otherwise, the value of `namespace` property must be an object. The module is
loaded and initialized from the object according to the [virtual module
namespace](#VirtualModuleNamespace) pattern.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does #VirtualModuleNamespace link to? I don't see it.

Copy link
Member Author

Choose a reason for hiding this comment

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

It’s an internal anchor to the corresponding heading.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where is that corresponding heading? I did not see it.

'c2': c2.module('./main.js'),
const compartment = new Compartment({}, {
c: {
source: new StaticModuleRecord(''),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
source: new StaticModuleRecord(''),
source: new ModuleSource(''),

Copy link
Contributor

@erights erights Jul 15, 2024

Choose a reason for hiding this comment

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

please do a global search for stale names

Copy link
Member Author

Choose a reason for hiding this comment

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

I’ll do a follow-up.

const moduleText = fs.readFileSync(moduleLocation);
return new StaticModuleRecord(moduleText, moduleLocation);
return {
source: new StaticModuleRecord(moduleText, moduleLocation),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
source: new StaticModuleRecord(moduleText, moduleLocation),
source: new ModuleSource(moduleText, moduleLocation),

aliasDescriptor = weakmapGet(moduleAliases, namespace);
if (aliasDescriptor !== undefined) {
moduleDescriptor = aliasDescriptor;
// Fall through to processing the reesulting {compartment, specifier}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Fall through to processing the reesulting {compartment, specifier}
// Fall through to processing the resulting {compartment, specifier}

Copy link
Contributor

@erights erights left a comment

Choose a reason for hiding this comment

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

LGTM

The README.md is an awesome guide for stating this stuff precisely. Should already be much of the work towards spec text!

@kriskowal
Copy link
Member Author

LGTM

The README.md is an awesome guide for stating this stuff precisely. Should already be much of the work towards spec text!

Credit where due https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/xs/XS%20Compartment.md#-module-descriptor

@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-refactor branch from db465e4 to 5df0f1a Compare July 15, 2024 22:54
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from 68d8f93 to 984d3d2 Compare July 15, 2024 22:54
Base automatically changed from kriskowal-ses-module-descriptors-refactor to master July 15, 2024 23:05
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch 2 times, most recently from debd810 to 5998c1b Compare July 15, 2024 23:58
@kriskowal kriskowal force-pushed the kriskowal-ses-module-descriptors-xs-parity branch from 5998c1b to 18796bc Compare July 16, 2024 00:05
@kriskowal kriskowal enabled auto-merge July 16, 2024 00:12
@kriskowal kriskowal merged commit d7c6639 into master Jul 16, 2024
17 checks passed
@kriskowal kriskowal deleted the kriskowal-ses-module-descriptors-xs-parity branch July 16, 2024 00:14
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