Maybe you can use rollup or similar to bundle moment inside this lib and use tree-shaking to reduce the final size ?
About the polyfill, of course it is more complicated than that. There's no test of support, the value formatting is different, the optional HTML attributes are not handled etc. This would imply major changes in your library to mimic the standard.
I agree that type checking at runtime is really important for JS applications. That's why I made this: http://objectmodel.js.org ; it works really well with Babel, and it has non-nullable types by default from the beginning
You talk about the risk of code injection but it seems you don't care at all. This test for detecting serialized functions is ridiculously weak, making a XSS with this example as easy as:
let person ={
name: 'function f(){},alert("XSS")'
};
Of course you can try to sanitize any user-inserted data, but unless you like playing russian roulette, I strongly discourage you to go that way.
You talk about the risk of code injection but it seems you don't care at all. This test for detecting serialized functions is ridiculously weak, making a XSS with this example as easy as: let person ={ name: 'function f(){},alert("XSS")' }; Of course you can try to sanitize any user-inserted data, but unless you like playing russian roulette, I strongly discourage you to go that way.