Hi,
I've noticed that when Dart code is compiled to JavaScript for building npm, it adds some methods to the Function.prototype, which causes global pollution. This can lead to potential conflicts with other libraries and unexpected behaviors. Here's an example of the problematic code:
Function.prototype.$1 = function (a) { return this(a) }
Function.prototype.$0 = function () { return this() }
Function.prototype.$2 = function (a, b) { return this(a, b) }
// ... other similar methods
This approach modifies the global Function object, which is not considered a good practice. Instead, these methods should be encapsulated or implemented in a way that does not affect global objects.
Steps to Reproduce:
1、dart run grinder npm
2、Inspect the resulting JavaScript code in the build/node/gltf_validator.dart.js file, and you'll find the above-mentioned modifications to Function.prototype
Hi, I've noticed that when Dart code is compiled to JavaScript for building npm, it adds some methods to the Function.prototype, which causes global pollution. This can lead to potential conflicts with other libraries and unexpected behaviors. Here's an example of the problematic code:
This approach modifies the global Function object, which is not considered a good practice. Instead, these methods should be encapsulated or implemented in a way that does not affect global objects. Steps to Reproduce: 1、dart run grinder npm 2、Inspect the resulting JavaScript code in the build/node/gltf_validator.dart.js file, and you'll find the above-mentioned modifications to Function.prototype