commontoolsinc / system

A constellation of Common tools
2 stars 0 forks source link

Ensure that `import.meta` presents uniform state in every VM #35

Open cdata opened 2 months ago

cdata commented 2 months ago

As of #32 , we have a Common Module invocation path that utilizes a JS VM running inside of a Wasm VM to interpret JS on-demand. There will be several mitigations required to reduce the chance of user code detecting that it is running as a compiled module vs. interpreted. One such mitigation is to ensure that import.meta presents the same state to user code in compiled and interpreted modes.

jsantell commented 1 month ago

Currently, CommonModule's environment produces a SyntaxError upon accessing import.meta, whereas CommonScript has an (empty) Object. These aren't ES modules in the sense that they can import modules (outside of authoring/bundling), so the SyntaxError approach seems more appropriate, though possibly more difficult to recreate within boa.

cdata commented 1 month ago

Yah, I agree. By default I would seek to emulate whatever the behavior happens to be in the Common Module case.

cdata commented 1 month ago

Eventually we should probably support reading import.meta without throwing, but that can be covered by a different issue.