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

test: tests live binding on a let (demonstrates: #2431) #2432

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

naugtur
Copy link
Member

@naugtur naugtur commented Aug 27, 2024

Refs: #2431

This is the ModuleSource instance being produced in the test in SES:

ModuleSource {
  imports: [],
  exports: [ 'quuux' ],
  reexports: [],
  __syncModuleProgram__: "({   imports: $h‍_imports,   liveVar: $h‍_live,   onceVar: $h‍_once,   importMeta: $h‍____meta, }) => (function () { 'use strict';   $h‍_imports([]);   \n" +
    '    let $c‍_quuux=null;\n' +
    '    // Live binding of an exported variable.\n' +
    "$h‍_live.quuux($c‍_quuux);quuux='Hello World!';\n" +
    '})()\n' +
    '//# sourceURL=https://example.com/main.js\n',
  __liveExportMap__: [Object: null prototype] { quuux: [ 'quuux', true ] },
  __reexportMap__: [Object: null prototype] {},
  __fixedExportMap__: [Object: null prototype] {},
  __needsImportMeta__: false
}

Note how quuux='Hello World!' is not assigning to $c‍_quuux and the only reason it works is moduleLexicals being there.
Since there's no moduleLexicals in the bundler, that test is failing.

@kriskowal
Copy link
Member

This is a known-limitation that we must at least document better.

@erights
Copy link
Contributor

erights commented Aug 27, 2024

This is a known-limitation that we must at least document better.

I'm surprised. Not urgent, but I am curious:

I know we handle such live-binding assignments in general through the with-proxy mechanism, and the hidden callback functions registered by the transformed module code. But why doesn't it work in this case?

@kriskowal
Copy link
Member

This is a known-limitation that we must at least document better.

I'm surprised. Not urgent, but I am curious:

I know we handle such live-binding assignments in general through the with-proxy mechanism, and the hidden callback functions registered by the transformed module code. But why doesn't it work in this case?

We don’t use a with block in the calling convention for bundles generated with our bundle.js. We also generally don’t use live bindings for “bootstrap bundles”. This is the tool we use to make the ses/dist/* scripts to replace Rollup, which we are going to use for more cases down the road, but it is a trusted and not a confined bundle format. We have not needed live binding support yet and I would prefer to avoid the with block indefinitely.

@naugtur naugtur force-pushed the test-live-bindings-depend-on-moduleLexicals branch from 02f184e to a1a1a42 Compare August 28, 2024 08:22
@naugtur
Copy link
Member Author

naugtur commented Aug 29, 2024

Added a test documenting lack of live bindings support.

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.

3 participants