"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.moduleExtension = void 0;
const babel_options = {
    plugins: [
        [
            "@babel/plugin-transform-modules-commonjs",
            {
                noInterop: true,
            }
        ]
    ]
};
exports.moduleExtension = ".mjs";
const isNode = typeof window === "undefined";
function toModuleFiles(output, options) {
    let modules = new Map();
    for (let path of output.modules.keys()) {
        let modernCode = output.modules.get(path);
        // create the modern modules with import/export syntax
        modules.set(path + exports.moduleExtension, modernCode);
        // create the nodejs compatible modules with require syntax
        if (isNode) {
            let r = require; // don't want parcel resolving
            let babel = r("@babel/core");
            let nodejsCode = babel.transform(modernCode, babel_options).code;
            modules.set(path + ".js", nodejsCode);
        }
    }
    return { ...output, modules };
}
exports.default = toModuleFiles;
