Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@yunho1017/ts-loader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yunho1017/ts-loader - npm Package Compare versions

Package version was removed
This package version has been unpublished, mostly likely due to security reasons
Comparing version
0.1.0
to
0.3.0
+1
-1
package.json
{
"name": "@yunho1017/ts-loader",
"version": "0.1.0",
"version": "0.3.0",
"author": "Yunho Seo",

@@ -5,0 +5,0 @@ "license": "MIT",

const ts = require("typescript");
const fs = require("fs");
const path = require("path");
function findConfigFile(requestDirPath, configFile) {
if (path.isAbsolute(configFile)) {
return fs.existsSync(configFile) ? configFile : undefined;
}
if (/^\.\.?(\/|\\)/.test(configFile)) {
const resolvedPath = path.resolve(requestDirPath, configFile);
return fs.existsSync(resolvedPath) ? resolvedPath : undefined;
}
while (true) {
const fileName = path.join(requestDirPath, configFile);
if (fs.existsSync(fileName)) {
return fileName;
}
const parentPath = path.dirname(requestDirPath);
if (parentPath === requestDirPath) {
break;
}
requestDirPath = parentPath;
}
return undefined;
}
function readConfigFile(filePath) {
try {
const fileContent = fs.readFileSync(filePath, "utf-8");
return JSON.parse(fileContent);
} catch (error) {
console.error(`Error reading config file at ${filePath}:`, error);
return undefined;
}
}
function getConfigFileOptions(requestDirPath, configFile) {
const configFilePath = findConfigFile(requestDirPath, configFile);
if (configFilePath) {
const configFileContent = readConfigFile(configFilePath);
return configFileContent ? configFileContent.compilerOptions : {};
}
return {};
}
exports.default = async function loader(content, emitError) {
try {
return ts.transpileModule(content, {
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
noImplicitUseStrict: true,
pretty: true,
},
compilerOptions: getConfigFileOptions(process.cwd(), "tsconfig.json"),
}).outputText;

@@ -13,0 +54,0 @@ } catch (err) {