async function loadScriptFileInternal()

in src/loadScriptFile.ts [53:72]


async function loadScriptFileInternal(filePath: string, packageJson: PackageJson): Promise<unknown> {
    const start = Date.now();
    try {
        let script: unknown;
        if (isESModule(filePath, packageJson)) {
            const fileUrl = url.pathToFileURL(filePath);
            if (fileUrl.href) {
                // use eval so it doesn't get compiled into a require()
                script = await eval('import(fileUrl.href)');
            } else {
                throw new AzFuncSystemError(`'${filePath}' could not be converted to file URL (${fileUrl.href})`);
            }
        } else {
            script = require(/* webpackIgnore: true */ filePath);
        }
        return script;
    } finally {
        warnIfLongLoadTime(filePath, start);
    }
}