diff --git a/src/lib/libembind.js b/src/lib/libembind.js index fa554eb3ab6a7..d1ad311928581 100644 --- a/src/lib/libembind.js +++ b/src/lib/libembind.js @@ -28,10 +28,8 @@ #include "libembind_shared.js" var LibraryEmbind = { - $UnboundTypeError__deps: ['$extendError'], - $UnboundTypeError: "=Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError')", - $PureVirtualError__deps: ['$extendError'], - $PureVirtualError: "=Module['PureVirtualError'] = extendError(Error, 'PureVirtualError')", + $UnboundTypeError: class extends Error {}, + $PureVirtualError: class extends Error {}, $GenericWireTypeSize: {{{ 2 * POINTER_SIZE }}}, #if EMBIND_AOT $InvokerFunctions: '<<< EMBIND_AOT_OUTPUT >>>', @@ -148,32 +146,6 @@ var LibraryEmbind = { } }, - // from https://github.com/imvu/imvujs/blob/master/src/error.js - $extendError__deps: ['$createNamedFunction'], - $extendError: (baseErrorType, errorName) => { - var errorClass = createNamedFunction(errorName, function(message) { - this.name = errorName; - this.message = message; - - var stack = (new Error(message)).stack; - if (stack !== undefined) { - this.stack = this.toString() + '\n' + - stack.replace(/^Error(:[^\n]*)?\n/, ''); - } - }); - errorClass.prototype = Object.create(baseErrorType.prototype); - errorClass.prototype.constructor = errorClass; - errorClass.prototype.toString = function() { - if (this.message === undefined) { - return this.name; - } else { - return `${this.name}: ${this.message}`; - } - }; - - return errorClass; - }, - $createNamedFunction: (name, func) => Object.defineProperty(func, 'name', { value: name }), $embindRepr: (v) => { diff --git a/test/code_size/embind_hello_wasm.json b/test/code_size/embind_hello_wasm.json index 462514bbd10cb..2fcd2e346f049 100644 --- a/test/code_size/embind_hello_wasm.json +++ b/test/code_size/embind_hello_wasm.json @@ -1,10 +1,10 @@ { "a.html": 552, "a.html.gz": 380, - "a.js": 9475, - "a.js.gz": 4154, + "a.js": 9094, + "a.js.gz": 3993, "a.wasm": 7348, "a.wasm.gz": 3378, - "total": 17375, - "total_gz": 7912 + "total": 16994, + "total_gz": 7751 } diff --git a/test/test_other.py b/test/test_other.py index a59d5da52e2d9..34f0fbc2de0ae 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -3363,7 +3363,7 @@ def test_embind(self, *extra_args): '-Wno-deprecated-declarations', '-lembind', '-sRETAIN_COMPILER_SETTINGS', - '-sEXPORTED_RUNTIME_METHODS=getCompilerSetting,setDelayFunction,flushPendingDeletes', + '-sEXPORTED_RUNTIME_METHODS=getCompilerSetting,setDelayFunction,flushPendingDeletes,PureVirtualError', '-sWASM_ASYNC_COMPILATION=0', # This test uses a `CustomSmartPtr` class which has 1MB of data embedded in # it which means we need more stack space than normal.