This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Description
When bundling code which uses getOwnPropertyNames, getPrototypeOf, etc, this error happens:
SyntaxError: 'import' and 'export' may only appear at the top level (2:0) in /home/****/****/node_modules/core-js/library/modules/$.is-object.js
at Parser.pp$4.raise (/home/****/****/node_modules/gulp-rollup/node_modules/rollup/dist/rollup.js:4271:13)
at Parser.pp$1.parseStatement (/home/****/****/node_modules/gulp-rollup/node_modules/rollup/dist/rollup.js:2836:29)
My code:
function propertiesOf(klass) {
let proto = klass;
let props = [];
let keys;
do {
proto = Object.getPrototypeOf(proto);
keys = Reflect.ownKeys(proto);
props = props.concat(
keys.filter(key => props.indexOf(key) < 0)
);
}
while (typeof proto === 'function');
return props;
}
The transformed code of "$.is-object.js" after commonjs plugin:
var $_isObject = __commonjs(function (module) {
import _typeof from 'babel-runtime/helpers/typeof';
module.exports = function (it) {
return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function';
};
});
export default ($_isObject && typeof $_isObject === 'object' && 'default' in $_isObject ? $_isObject['default'] : $_isObject);