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?
I try to use a ES6
Mapinside 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:
This will cause the following error later:
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
Mapin library code?