I've noticed following oddities when bundling for Node with the following command:
microbundle --target node --no-sourcemap -f cjs,esm --strict --types
When object spread operator is used ({ ...defaults, ...options }), in both the generated index.js and index.cjs (of a type: module package), those lines are replaced with a custom _extends function, which is added:
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
Object spread is supported in Node since v8.3 and my package specifies engines.node >= 12 so this is "useless" extra code in the output. Temp fix is to directly use Object.assign in source code instead of obj spread.
Another oddity I noticed was that there was generated code referring to document but this shouldn't be the case for Node builds?
I've noticed following oddities when bundling for Node with the following command:
When object spread operator is used (
{ ...defaults, ...options }), in both the generatedindex.jsandindex.cjs(of atype: modulepackage), those lines are replaced with a custom_extendsfunction, which is added:Object spread is supported in Node since v8.3 and my package specifies
engines.node >= 12so this is "useless" extra code in the output. Temp fix is to directly use Object.assign in source code instead of obj spread.Another oddity I noticed was that there was generated code referring to
documentbut this shouldn't be the case for Node builds?