You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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){returnthis(a)}Function.prototype.$0=function(){returnthis()}Function.prototype.$2=function(a,b){returnthis(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
The text was updated successfully, but these errors were encountered:
GeoLibra
changed the title
Avoid global pollution of Function.prototype in node npm
Avoid global pollution of Function.prototype in Dart to JavaScript conversion for Node.js npm package
Jun 24, 2024
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
The text was updated successfully, but these errors were encountered: