简体   繁体   中英

How can I re-export with CJS?

How can I re-export modules in CJS? What would be the CJS equivalent to the following ES6 code?

export * from './lib/setAttribute.js'

I think you can do exactly the same way that tsc currently does as it compiles our code back to commonjs :

var __createBinding = function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
};

var __exportStar = function(m, exports) {
    for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};

__exportStar(require("./lib/setAttribute.js"), exports);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM