const require_rolldown_runtime = require('../../../../../../../../../../../../../../_virtual/rolldown_runtime.cjs');
const require_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
const require_bundleFile = require('./bundleFile.cjs');
let node_path = require("node:path");
let esbuild = require("esbuild");
let node_url = require("node:url");

//#region ../@intlayer/cli/dist/esm/chokidar/dist/esm/unmerged-dictionaries-entry/dist/esm/config/dist/esm/loadExternalFile/transpileTSToMJS.mjs
const getTransformationOptions = (filePath) => ({
	loader: {
		".js": "js",
		".jsx": "jsx",
		".mjs": "js",
		".ts": "ts",
		".tsx": "tsx",
		".cjs": "js",
		".json": "json",
		".md": "text",
		".mdx": "text"
	},
	format: "cjs",
	target: "node20",
	platform: "node",
	write: false,
	packages: "external",
	bundle: true,
	tsconfig: (0, node_path.join)(require_getPackageJsonPath.getPackageJsonPath((0, node_path.dirname)(filePath)).baseDir, "tsconfig.json"),
	define: { "import.meta.url": JSON.stringify((0, node_url.pathToFileURL)(filePath).href) }
});
const transpileTSToMJSSync = (code, filePath, options) => {
	return (0, esbuild.buildSync)({
		stdin: {
			contents: code,
			loader: require_bundleFile.getLoader((0, node_path.extname)(filePath)),
			resolveDir: (0, node_path.dirname)(filePath),
			sourcefile: filePath
		},
		...getTransformationOptions(filePath),
		...options
	}).outputFiles?.[0].text;
};

//#endregion
exports.transpileTSToMJSSync = transpileTSToMJSSync;
//# sourceMappingURL=transpileTSToMJS.cjs.map