Skip to content

Using Map in library code seems not allowed #23672

Description

@fs-eire

I try to use a ES6 Map inside library code like this:

 // library_webgpu.js
 
 var LibraryWebGPU = {
   $WebGPU__deps: [],
   $WebGPU: {
     Internals: {
+      buffers: new Map(),
       ...
     },
     ...
   },
 };
 
 autoAddDeps(LibraryWebGPU, '$WebGPU');
 mergeInto(LibraryManager.library, LibraryWebGPU);
 

And the final generated JS files is like this:

var WebGPU = {
  Internals: {
    buffers: {},

This will cause the following error later:

Uncaught TypeError: buffers.set is not a function

I tried to figure out whether this is an expected behavior, but didn't see document about this. And I don't understand why this behavior happens. If this is expected behavior (re-writing a Map to a plain object), is there a way to use ES6 Map in library code?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions