HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-172-31-4-197 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/api-storage/node_modules/@swc/cli/lib/swc/compile.js
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    compile: function() {
        return compile;
    },
    outputResult: function() {
        return outputResult;
    }
});
const _slash = /*#__PURE__*/ _interop_require_default(require("slash"));
const _fs = require("fs");
const _path = require("path");
const _core = require("@swc/core");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const { mkdir, stat, writeFile } = _fs.promises;
function withSourceMap(output, options, sourceMapFile, destDir) {
    let dts;
    // TODO: Remove once fixed in core
    if (output.output) {
        const json = JSON.parse(output.output);
        if (json.__swc_isolated_declarations__) {
            dts = json.__swc_isolated_declarations__;
        }
    }
    if (!output.map || options.sourceMaps === "inline") {
        return {
            sourceCode: output.code,
            dts
        };
    }
    // TODO: remove once fixed in core https://github.com/swc-project/swc/issues/1388
    const sourceMap = JSON.parse(output.map);
    if (options.sourceFileName) {
        sourceMap["sources"][0] = options.sourceFileName;
    }
    if (options.sourceRoot) {
        sourceMap["sourceRoot"] = options.sourceRoot;
    }
    output.map = JSON.stringify(sourceMap);
    output.code += `\n//# sourceMappingURL=${(0, _slash.default)((0, _path.relative)(destDir, sourceMapFile))}`;
    return {
        sourceMap: output.map,
        sourceCode: output.code,
        dts
    };
}
async function outputResult({ output, sourceFile, destFile, destDtsFile, destSourcemapFile, options }) {
    const destDir = (0, _path.dirname)(destFile);
    const { sourceMap, sourceCode, dts } = withSourceMap(output, options, destSourcemapFile, destDir);
    await mkdir(destDir, {
        recursive: true
    });
    const { mode } = await stat(sourceFile);
    const dtsPromise = dts ? writeFile(destDtsFile, dts, {
        mode
    }) : Promise.resolve();
    const sourceMapPromise = sourceMap ? writeFile(destSourcemapFile, sourceMap, {
        mode
    }) : Promise.resolve();
    await Promise.all([
        writeFile(destFile, sourceCode, {
            mode
        }),
        dtsPromise,
        sourceMapPromise
    ]);
}
async function compile(filename, opts, sync, outputPath) {
    const options = {
        ...opts
    };
    if (outputPath) {
        options.outputPath = outputPath;
    }
    try {
        const result = sync ? (0, _core.transformFileSync)(filename, options) : await (0, _core.transformFile)(filename, options);
        return result;
    } catch (err) {
        if (!err.message.includes("ignored by .swcrc")) {
            throw err;
        }
    }
}

//# sourceMappingURL=compile.js.map