New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fable-compiler-js

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fable-compiler-js - npm Package Compare versions

Comparing version 1.0.0-beta-001 to 1.0.0-beta-002

245

dist/app.js

@@ -7,2 +7,3 @@ "use strict";

exports.$007CRegex$007C_$007C = $007CRegex$007C_$007C;
exports.makeOtherOptions = makeOtherOptions;
exports.parseProjectScript = parseProjectScript;

@@ -29,6 +30,6 @@ exports.parseProjectFile = parseProjectFile;

var _Seq = require("./fable-library.2.1.10/Seq");
var _Array = require("./fable-library.2.1.10/Array");
var _Seq = require("./fable-library.2.1.10/Seq");
var _Util = require("./fable-library.2.1.10/Util");

@@ -65,2 +66,21 @@

function makeOtherOptions(target, defines, nowarns, otherFlags) {
const otherOptions = (0, _Array.ofSeq)((0, _Seq.delay)(function () {
return (0, _Seq.append)((0, _Seq.singleton)("--target:" + target), (0, _Seq.delay)(function () {
return (0, _Seq.append)((0, _Seq.map)(function (d) {
return "-d:" + d;
}, defines), (0, _Seq.delay)(function () {
return (0, _Seq.append)((0, _Seq.map)(function (n) {
return "-nowarn:" + n;
}, nowarns), (0, _Seq.delay)(function () {
return (0, _Seq.map)(function (o) {
return o;
}, otherFlags);
}));
}));
}));
}), Array);
return otherOptions;
}
function parseProjectScript(projectPath) {

@@ -74,29 +94,29 @@ const projectFileName = (0, _platform.Path$$$GetFileName)(projectPath);

const matchValue = line$$1.trim();
var $target$$24, path$$1;
const activePatternResult153 = $007CRegex$007C_$007C("^#r\\s+\"(.*?)\"$", matchValue);
var $target$$28, path$$1;
const activePatternResult161 = $007CRegex$007C_$007C("^#r\\s+\"(.*?)\"$", matchValue);
if (activePatternResult153 != null) {
if (activePatternResult153.tail != null) {
if (activePatternResult153.tail.tail != null) {
if (activePatternResult153.tail.tail.tail == null) {
if (path = activePatternResult153.tail.head, !(0, _String.endsWith)(path, "Fable.Core.dll")) {
$target$$24 = 0;
path$$1 = activePatternResult153.tail.head;
if (activePatternResult161 != null) {
if (activePatternResult161.tail != null) {
if (activePatternResult161.tail.tail != null) {
if (activePatternResult161.tail.tail.tail == null) {
if (path = activePatternResult161.tail.head, !(0, _String.endsWith)(path, "Fable.Core.dll")) {
$target$$28 = 0;
path$$1 = activePatternResult161.tail.head;
} else {
$target$$24 = 1;
$target$$28 = 1;
}
} else {
$target$$24 = 1;
$target$$28 = 1;
}
} else {
$target$$24 = 1;
$target$$28 = 1;
}
} else {
$target$$24 = 1;
$target$$28 = 1;
}
} else {
$target$$24 = 1;
$target$$28 = 1;
}
switch ($target$$24) {
switch ($target$$28) {
case 0:

@@ -109,25 +129,25 @@ {

{
var $target$$25, path$$2;
const activePatternResult151 = $007CRegex$007C_$007C("^#load\\s+\"(.*?)\"$", matchValue);
var $target$$29, path$$2;
const activePatternResult159 = $007CRegex$007C_$007C("^#load\\s+\"(.*?)\"$", matchValue);
if (activePatternResult151 != null) {
if (activePatternResult151.tail != null) {
if (activePatternResult151.tail.tail != null) {
if (activePatternResult151.tail.tail.tail == null) {
$target$$25 = 0;
path$$2 = activePatternResult151.tail.head;
if (activePatternResult159 != null) {
if (activePatternResult159.tail != null) {
if (activePatternResult159.tail.tail != null) {
if (activePatternResult159.tail.tail.tail == null) {
$target$$29 = 0;
path$$2 = activePatternResult159.tail.head;
} else {
$target$$25 = 1;
$target$$29 = 1;
}
} else {
$target$$25 = 1;
$target$$29 = 1;
}
} else {
$target$$25 = 1;
$target$$29 = 1;
}
} else {
$target$$25 = 1;
$target$$29 = 1;
}
switch ($target$$25) {
switch ($target$$29) {
case 0:

@@ -146,4 +166,10 @@ {

}, [[], []], (0, _String.split)(projectText, ["\n"], null, 0));
const projectRefs = [];
const sourceFiles = (0, _Array.append)(patternInput[1], [(0, _platform.Path$$$GetFileName)(projectPath)], Array);
return [projectFileName, patternInput[0], [], sourceFiles, ["FABLE_COMPILER"]];
const target$$1 = "exe";
const defines$$1 = ["FABLE_COMPILER"];
const nowarns$$1 = [];
const otherFlags$$1 = [];
const otherOptions$$1 = makeOtherOptions(target$$1, defines$$1, nowarns$$1, otherFlags$$1);
return [projectFileName, patternInput[0], projectRefs, sourceFiles, otherOptions$$1];
}

@@ -155,23 +181,39 @@

const projectText$$2 = (0, _RegExp.replace)(projectText$$1, "<!--[\\s\\S]*?-->", "");
const definesRegex = "<DefineConstants[^>]*>([^<]*)<\\/DefineConstants[^>]*>";
const defines = (0, _Array.ofSeq)((0, _Seq.except)(["$(DefineConstants)", ""], (0, _Set.distinct)((0, _Seq.map)(function mapping$$1(s) {
const m$$1 = (0, _RegExp.match)(projectText$$2, "<OutputType[^>]*>([^<]*)<\\/OutputType[^>]*>");
const target$$2 = m$$1 != null ? (m$$1[1] || "").toLowerCase() : "library";
const defines$$2 = (0, _Array.ofSeq)((0, _Seq.except)(["$(DefineConstants)", ""], (0, _Set.distinct)((0, _Seq.map)(function mapping$$1(s) {
return s.trim();
}, (0, _Seq.append)(["FABLE_COMPILER"], (0, _Seq.collect)(function mapping(m$$1) {
return (0, _String.split)(m$$1[1] || "", [";"], null, 0);
}, (0, _RegExp.matches)(projectText$$2, definesRegex)))), {
}, (0, _Seq.append)(["FABLE_COMPILER"], (0, _Seq.collect)(function mapping(m$$2) {
return (0, _String.split)(m$$2[1] || "", [";"], null, 0);
}, (0, _RegExp.matches)(projectText$$2, "<DefineConstants[^>]*>([^<]*)<\\/DefineConstants[^>]*>")))), {
Compare: _Util.comparePrimitives
})), Array);
const projectRefsRegex = "<ProjectReference\\s+[^>]*Include\\s*=\\s*(\"[^\"]*|'[^']*)";
const projectRefs = (0, _Array.ofSeq)((0, _Seq.map)(function mapping$$2(m$$2) {
return (0, _String.replace)((0, _String.trimStart)((0, _String.trimStart)(m$$2[1] || "", "\""), "'").trim(), "\\", "/");
}, (0, _RegExp.matches)(projectText$$2, projectRefsRegex)), Array);
const nowarns$$2 = (0, _Array.ofSeq)((0, _Seq.except)(["$(NoWarn)", ""], (0, _Set.distinct)((0, _Seq.map)(function mapping$$3(s$$1) {
return s$$1.trim();
}, (0, _Seq.collect)(function mapping$$2(m$$3) {
return (0, _String.split)(m$$3[1] || "", [";"], null, 0);
}, (0, _RegExp.matches)(projectText$$2, "<NoWarn[^>]*>([^<]*)<\\/NoWarn[^>]*>"))), {
Compare: _Util.comparePrimitives
})), Array);
const otherFlags$$2 = (0, _Array.ofSeq)((0, _Seq.except)(["$(OtherFlags)", ""], (0, _Set.distinct)((0, _Seq.map)(function mapping$$5(s$$2) {
return s$$2.trim();
}, (0, _Seq.collect)(function mapping$$4(m$$4) {
return (0, _String.split)(m$$4[1] || "", [" "], null, 0);
}, (0, _RegExp.matches)(projectText$$2, "<OtherFlags[^>]*>([^<]*)<\\/OtherFlags[^>]*>"))), {
Compare: _Util.comparePrimitives
})), Array);
const projectRefs$$1 = (0, _Array.ofSeq)((0, _Seq.map)(function mapping$$6(m$$5) {
return (0, _String.replace)((0, _String.trimStart)((0, _String.trimStart)(m$$5[1] || "", "\""), "'").trim(), "\\", "/");
}, (0, _RegExp.matches)(projectText$$2, "<ProjectReference\\s+[^>]*Include\\s*=\\s*(\"[^\"]*|'[^']*)")), Array);
const projectText$$3 = (0, _String.replace)(projectText$$2, "$(MSBuildProjectDirectory)", __dirname);
const m$$3 = (0, _RegExp.match)(projectText$$3, "<FSharpSourcesRoot[^>]*>([^<]*)<\\/FSharpSourcesRoot[^>]*>");
const sourcesRoot = m$$3 != null ? (0, _String.replace)(m$$3[1] || "", "\\", "/") : "";
const m$$6 = (0, _RegExp.match)(projectText$$3, "<FSharpSourcesRoot[^>]*>([^<]*)<\\/FSharpSourcesRoot[^>]*>");
const sourcesRoot = m$$6 != null ? (0, _String.replace)(m$$6[1] || "", "\\", "/") : "";
const projectText$$4 = (0, _String.replace)(projectText$$3, "$(FSharpSourcesRoot)", sourcesRoot);
const sourceFilesRegex = "<Compile\\s+[^>]*Include\\s*=\\s*(\"[^\"]*|'[^']*)";
const sourceFiles$$1 = (0, _Array.ofSeq)((0, _Seq.map)(function mapping$$3(m$$4) {
return (0, _String.replace)((0, _String.trimStart)((0, _String.trimStart)(m$$4[1] || "", "\""), "'").trim(), "\\", "/");
const sourceFiles$$1 = (0, _Array.ofSeq)((0, _Seq.map)(function mapping$$7(m$$7) {
return (0, _String.replace)((0, _String.trimStart)((0, _String.trimStart)(m$$7[1] || "", "\""), "'").trim(), "\\", "/");
}, (0, _RegExp.matches)(projectText$$4, sourceFilesRegex)), Array);
return [projectFileName$$1, [], projectRefs, sourceFiles$$1, defines];
const dllRefs$$2 = [];
const otherOptions$$2 = makeOtherOptions(target$$2, defines$$2, nowarns$$2, otherFlags$$2);
return [projectFileName$$1, dllRefs$$2, projectRefs$$1, sourceFiles$$1, otherOptions$$2];
}

@@ -199,21 +241,21 @@

const fileNames = (0, _Array.map)(function mapping$$4(path$$5) {
const sourcePaths = (0, _Array.map)(function mapping$$8(path$$5) {
return (0, _platform.normalizeFullPath)(makePath(path$$5));
}, patternInput$$1[3], Array);
const sources = (0, _Array.map)(function mapping$$5(path$$7) {
const sourceTexts = (0, _Array.map)(function mapping$$9(path$$7) {
return (0, _platform.readAllText)(makePath(path$$7));
}, patternInput$$1[3], Array);
const parsedProjects = (0, _Array.map)(parseProject, (0, _Array.map)(makePath, patternInput$$1[2], Array), Array);
const fileNames$$1 = (0, _Array.append)((0, _Array.collect)(function mapping$$7(tupledArg$$1) {
const sourcePaths$$1 = (0, _Array.append)((0, _Array.collect)(function mapping$$11(tupledArg$$1) {
return tupledArg$$1[2];
}, parsedProjects, Array), fileNames, Array);
const sources$$1 = (0, _Array.append)((0, _Array.collect)(function mapping$$8(tupledArg$$2) {
}, parsedProjects, Array), sourcePaths, Array);
const sourceTexts$$1 = (0, _Array.append)((0, _Array.collect)(function mapping$$12(tupledArg$$2) {
return tupledArg$$2[3];
}, parsedProjects, Array), sources, Array);
const defines$$2 = (0, _Array.append)((0, _Array.collect)(function mapping$$9(tupledArg$$3) {
}, parsedProjects, Array), sourceTexts, Array);
const otherOptions$$4 = (0, _Array.append)((0, _Array.collect)(function mapping$$13(tupledArg$$3) {
return tupledArg$$3[4];
}, parsedProjects, Array), patternInput$$1[4], Array);
return [patternInput$$1[0], patternInput$$1[1], fileNames$$1, sources$$1, (0, _Array.distinct)(defines$$2, {
Equals($x$$3, $y$$4) {
return $x$$3 === $y$$4;
return [patternInput$$1[0], patternInput$$1[1], sourcePaths$$1, sourceTexts$$1, (0, _Array.distinct)(otherOptions$$4, {
Equals($x$$7, $y$$8) {
return $x$$7 === $y$$8;
},

@@ -225,3 +267,3 @@

function dedupFileNames(fileNames$$2) {
function dedupFileNames(fileNames) {
const comparerIgnoreCase = {

@@ -249,4 +291,4 @@ Equals(x$$3, y) {

if (nameSet.has(name$$1)) {
const $name$$1$$26 = name$$1;
name$$1 = padName($name$$1$$26);
const $name$$1$$30 = name$$1;
name$$1 = padName($name$$1$$30);
continue dedup;

@@ -262,3 +304,3 @@ } else {

return (0, _Array.map)(dedup, fileNames$$2, Array);
return (0, _Array.map)(dedup, fileNames, Array);
}

@@ -300,4 +342,4 @@

const patternInput$$3 = parseProject(projectPath$$4);
const fileNames$$4 = dedupFileNames(patternInput$$3[2]);
const extraDll = (0, _Map.ofSeq)((0, _Seq.map)(function mapping$$10(x$$5) {
const fileNames$$2 = dedupFileNames(patternInput$$3[2]);
const dllRefMap = (0, _Map.ofSeq)((0, _Seq.map)(function mapping$$14(x$$5) {
return [(0, _platform.Path$$$GetFileName)(x$$5), x$$5];

@@ -308,10 +350,18 @@ }, patternInput$$3[1]), {

const references$$1 = (0, _Array.append)(references, (0, _Array.map)(_platform.Path$$$GetFileNameWithoutExtension, patternInput$$3[1], Array), Array);
const fable = (0, _platform.initFable)();
const readBytesExtra = function readBytesExtra(name$$2) {
return (0, _platform.readAllBytes)((0, _Option.defaultArg)((0, _Map.tryFind)(name$$2, extraDll), metadataPath + name$$2));
const findDllPath = function findDllPath(dllName) {
return (0, _Option.defaultArg)((0, _Map.tryFind)(dllName, dllRefMap), metadataPath + dllName);
};
const readAllBytes = function readAllBytes(dllName$$1) {
return (0, _platform.readAllBytes)(findDllPath(dllName$$1));
};
const fable = (0, _platform.initFable)();
const otherOptions$$6 = (0, _Array.append)(patternInput$$3[4], (0, _Array.ofSeq)((0, _Seq.delay)(function () {
return options.optimize ? (0, _Seq.singleton)("--optimize+") : (0, _Seq.empty)();
}), Array), Array);
const createChecker = function createChecker() {
return fable.CreateChecker(references$$1, readBytesExtra, patternInput$$3[4], options.optimize);
return fable.CreateChecker(references$$1, readAllBytes, otherOptions$$6);
};

@@ -324,3 +374,3 @@

const parseFSharpProject = function parseFSharpProject() {
return fable.ParseFSharpProject(patternInput$$4[1], patternInput$$3[0], fileNames$$4, patternInput$$3[3]);
return fable.ParseFSharpProject(patternInput$$4[1], patternInput$$3[0], fileNames$$2, patternInput$$3[3]);
};

@@ -338,3 +388,3 @@

const fileNames$$5 = fileNames$$4.filter(function predicate$$1(x$$6) {
const fileNames$$3 = fileNames$$2.filter(function predicate$$1(x$$6) {
return !(0, _String.endsWith)(x$$6, ".fsi");

@@ -356,9 +406,9 @@ });

for (let idx = 0; idx <= fileNames$$5.length - 1; idx++) {
const fileName$$2 = fileNames$$5[idx];
const patternInput$$6 = (0, _platform.measureTime)(parseFable, [patternInput$$5[1], fileName$$2]);
(0, _String.toConsole)((0, _String.printf)("File: %s, Fable time: %d ms"))(fileName$$2)(patternInput$$6[0]);
for (let idx = 0; idx <= fileNames$$3.length - 1; idx++) {
const fileName$$1 = fileNames$$3[idx];
const patternInput$$6 = (0, _platform.measureTime)(parseFable, [patternInput$$5[1], fileName$$1]);
(0, _String.toConsole)((0, _String.printf)("File: %s, Fable time: %d ms"))(fileName$$1)(patternInput$$6[0]);
printErrors(showWarnings$$1, patternInput$$6[1].FableErrors);
const filePath$$1 = trimPath((0, _platform.getRelativePath)(projDir, fileName$$2));
(0, _platform.transformAndSaveBabelAst)(patternInput$$6[1].BabelAst, filePath$$1, projDir, outDir, options.commonjs);
const filePath$$2 = trimPath((0, _platform.getRelativePath)(projDir, fileName$$1));
(0, _platform.transformAndSaveBabelAst)(patternInput$$6[1].BabelAst, filePath$$2, projDir, outDir, options.commonjs);
}

@@ -370,3 +420,3 @@ }

return "--run" === y$$1;
}, opts), null, function mapping$$11(i$$1) {
}, opts), null, function mapping$$15(i$$1) {
const scriptFile = (0, _platform.Path$$$Combine)(outDir$$1, (0, _platform.Path$$$GetFileNameWithoutExtension)(projectPath$$5) + ".js");

@@ -377,4 +427,4 @@ const runArgs = (0, _String.join)(" ", ...opts.slice(i$$1 + 1, opts.length));

const options$$1 = new CmdLineOptions(commandToRun != null ? true : (0, _Array.contains)("--commonjs", opts, {
Equals($x$$7, $y$$8) {
return $x$$7 === $y$$8;
Equals($x$$11, $y$$12) {
return $x$$11 === $y$$12;
},

@@ -384,4 +434,4 @@

}), (0, _Array.contains)("--optimize-fcs", opts, {
Equals($x$$9, $y$$10) {
return $x$$9 === $y$$10;
Equals($x$$13, $y$$14) {
return $x$$13 === $y$$14;
},

@@ -391,4 +441,4 @@

}), (0, _Array.contains)("--watch", opts, {
Equals($x$$11, $y$$12) {
return $x$$11 === $y$$12;
Equals($x$$15, $y$$16) {
return $x$$15 === $y$$16;
},

@@ -399,4 +449,4 @@

parseFiles(projectPath$$5, outDir$$1, options$$1);
(0, _Seq.iterate)(_platform.runCmdAndExitIfFails, (0, _Option.defaultArg)(commandToRun, [], function ($x$$13) {
return [$x$$13];
(0, _Seq.iterate)(_platform.runCmdAndExitIfFails, (0, _Option.defaultArg)(commandToRun, [], function ($x$$17) {
return [$x$$17];
}));

@@ -408,4 +458,4 @@ }

let patternInput$$7;
const matchValue$$1 = (0, _Array.tryFindIndex)(function predicate$$3(s$$1) {
return s$$1.indexOf("--") === 0;
const matchValue$$1 = (0, _Array.tryFindIndex)(function predicate$$3(s$$3) {
return s$$3.indexOf("--") === 0;
}, argv);

@@ -421,31 +471,31 @@

const matchValue$$2 = [patternInput$$7[1], patternInput$$7[0]];
var $target$$27, projectPath$$6, outDir$$3, projectPath$$7;
var $target$$31, projectPath$$6, outDir$$3, projectPath$$7;
if (!(0, _Array.equalsWith)(_Util.comparePrimitives, matchValue$$2[0], null) ? matchValue$$2[0].length === 1 : false) {
if (matchValue$$2[0][0] === "--help") {
$target$$27 = 0;
$target$$31 = 0;
} else if (matchValue$$2[0][0] === "--version") {
$target$$27 = 1;
$target$$31 = 1;
} else if (!(0, _Array.equalsWith)(_Util.comparePrimitives, matchValue$$2[1], null) ? matchValue$$2[1].length === 1 : false) {
$target$$27 = 2;
$target$$31 = 2;
projectPath$$6 = matchValue$$2[1][0];
} else if (!(0, _Array.equalsWith)(_Util.comparePrimitives, matchValue$$2[1], null) ? matchValue$$2[1].length === 2 : false) {
$target$$27 = 3;
$target$$31 = 3;
outDir$$3 = matchValue$$2[1][1];
projectPath$$7 = matchValue$$2[1][0];
} else {
$target$$27 = 4;
$target$$31 = 4;
}
} else if (!(0, _Array.equalsWith)(_Util.comparePrimitives, matchValue$$2[1], null) ? matchValue$$2[1].length === 1 : false) {
$target$$27 = 2;
$target$$31 = 2;
projectPath$$6 = matchValue$$2[1][0];
} else if (!(0, _Array.equalsWith)(_Util.comparePrimitives, matchValue$$2[1], null) ? matchValue$$2[1].length === 2 : false) {
$target$$27 = 3;
$target$$31 = 3;
outDir$$3 = matchValue$$2[1][1];
projectPath$$7 = matchValue$$2[1][0];
} else {
$target$$27 = 4;
$target$$31 = 4;
}
switch ($target$$27) {
switch ($target$$31) {
case 0:

@@ -484,4 +534,9 @@ {

(function (argv$$1) {
parseArguments(argv$$1);
try {
parseArguments(argv$$1);
} catch (ex) {
(0, _String.toConsole)((0, _String.printf)("Error: %A"))(ex.message);
}
return 0;
})(process.argv.slice(2));

@@ -11,2 +11,3 @@ "use strict";

exports.Record = Record;
exports.anonRecord = anonRecord;
exports.isException = isException;

@@ -244,2 +245,6 @@ exports.Attribute = exports.MatchFailureException = exports.FSharpException = exports.Exception = exports.FSharpRef = void 0;

function anonRecord(o) {
return Object.assign(Object.create(Record.prototype), o);
}
const FSharpRef = declare(function FSharpRef(contents) {

@@ -246,0 +251,0 @@ this.contents = contents;

@@ -201,2 +201,5 @@ import { combineHashCodes, compare, compareArrays, equals, equalArrays, identityHash, structuralHash, numberHash } from "./Util";

};
export function anonRecord(o) {
return Object.assign(Object.create(Record.prototype), o);
}
export const FSharpRef = declare(function FSharpRef(contents) {

@@ -203,0 +206,0 @@ this.contents = contents;

@@ -46,12 +46,12 @@ "use strict";

function readAllBytes(fileName) {
return FileSystem.readFileSync(fileName);
function readAllBytes(filePath) {
return FileSystem.readFileSync(filePath);
}
function readAllText(filePath) {
return (0, _String.trimStart)(FileSystem.readFileSync(filePath, "utf8"), "");
function readAllText(filePath$$1) {
return (0, _String.trimStart)(FileSystem.readFileSync(filePath$$1, "utf8"), "");
}
function writeAllText(filePath$$1, text) {
FileSystem.writeFileSync(filePath$$1, text);
function writeAllText(filePath$$2, text) {
FileSystem.writeFileSync(filePath$$2, text);
}

@@ -58,0 +58,0 @@

@@ -7,4 +7,4 @@ "use strict";

exports.getVersion = getVersion;
exports.serializeToJson = serializeToJson;
exports.ensureDirExists = ensureDirExists;
exports.serializeToJson = serializeToJson;
exports.copyFolder = copyFolder;

@@ -30,2 +30,16 @@ exports.transformAndSaveBabelAst = transformAndSaveBabelAst;

function serializeToJson(data) {
return JSON.stringify(data, (key, value) => {
if (value === Infinity) {
return "Infinity";
} else if (value === -Infinity) {
return "-Infinity";
} else if (value !== value) {
return "NaN";
}
return value;
});
}
function ensureDirExists(dir, cont) {

@@ -49,14 +63,17 @@ if (fs.existsSync(dir)) {

function serializeToJson(data) {
return JSON.stringify(data, (key, value) => {
if (value === Infinity) {
return "Infinity";
} else if (value === -Infinity) {
return "-Infinity";
} else if (value !== value) {
return "NaN";
}
const uniquePaths = new Map();
return value;
});
function ensureUniquePath(sourcePath, outDir, relPath) {
let outPath = Path.resolve(outDir, relPath);
while (uniquePaths.has(outPath) && uniquePaths.get(outPath) !== sourcePath) {
var i = outPath.lastIndexOf(".");
outPath = i < 0 ? outPath + "_" : outPath.substr(0, i) + "_" + outPath.substr(i);
}
if (!uniquePaths.has(outPath)) {
uniquePaths.set(outPath, sourcePath);
}
return outPath;
}

@@ -89,4 +106,2 @@

const outPath = Path.join(Path.dirname(filePath), relPath); //TODO: handle duplicate files with different content
let jsPath = Path.resolve(Path.dirname(sourcePath), importPath);

@@ -98,2 +113,3 @@ jsPath = jsPath.match(JAVASCRIPT_EXT) ? jsPath : jsPath + ".js";

});
const outPath = ensureUniquePath(jsPath, Path.dirname(filePath), relPath);
fixImportPaths(resAst.ast, outPath, outDir);

@@ -144,5 +160,5 @@ const resCode = Babel.transformFromAstSync(resAst.ast, null, babelOptions);

const sourcePath = babelAst.fileName;
const jsPath = filePath.replace(FSHARP_EXT, ".js");
const outPath = Path.join(outDir, jsPath); //TODO: handle duplicate files with different content
const outPath = ensureUniquePath(sourcePath, outDir, jsPath);
ensureDirExists(Path.dirname(outPath));

@@ -149,0 +165,0 @@ const babelOptions = commonjs ? {

{
"name": "fable-compiler-js",
"version": "1.0.0-beta-001",
"version": "1.0.0-beta-002",
"main": "index.js",

@@ -29,4 +29,4 @@ "bin": {

"fable-metadata": "^1.0.0-beta-002",
"fable-standalone": "^1.0.0-beta-004"
"fable-standalone": "^1.0.0-beta-007"
}
}

@@ -0,1 +1,5 @@

### 1.0.0-beta-002
* Added project options parsing @ncave
### 1.0.0-beta-001

@@ -2,0 +6,0 @@

@@ -18,13 +18,2 @@ const fs = require("fs");

export function ensureDirExists(dir, cont) {
if (fs.existsSync(dir)) {
if (typeof cont === "function") { cont(); }
} else {
ensureDirExists(Path.dirname(dir), () => {
if (!fs.existsSync(dir)) { fs.mkdirSync(dir); }
if (typeof cont === "function") { cont(); }
});
}
}
export function serializeToJson(data) {

@@ -43,2 +32,25 @@ return JSON.stringify(data, (key, value) => {

export function ensureDirExists(dir, cont) {
if (fs.existsSync(dir)) {
if (typeof cont === "function") { cont(); }
} else {
ensureDirExists(Path.dirname(dir), () => {
if (!fs.existsSync(dir)) { fs.mkdirSync(dir); }
if (typeof cont === "function") { cont(); }
});
}
}
const uniquePaths = new Map();
function ensureUniquePath(sourcePath, outDir, relPath) {
let outPath = Path.resolve(outDir, relPath);
while (uniquePaths.has(outPath) && uniquePaths.get(outPath) !== sourcePath) {
var i = outPath.lastIndexOf(".");
outPath = (i < 0) ? outPath + "_" : outPath.substr(0, i) + "_" + outPath.substr(i);
}
if (!uniquePaths.has(outPath)) { uniquePaths.set(outPath, sourcePath); }
return outPath;
}
function ensureArray(obj) {

@@ -68,6 +80,6 @@ return (Array.isArray(obj) ? obj : obj != null ? [obj] : []);

// transform and save javascript imports
const outPath = Path.join(Path.dirname(filePath), relPath); //TODO: handle duplicate files with different content
let jsPath = Path.resolve(Path.dirname(sourcePath), importPath);
jsPath = jsPath.match(JAVASCRIPT_EXT) ? jsPath : jsPath + ".js";
const resAst = Babel.transformFileSync(jsPath, { ast: true, code: false });
const outPath = ensureUniquePath(jsPath, Path.dirname(filePath), relPath);
fixImportPaths(resAst.ast, outPath, outDir);

@@ -114,4 +126,5 @@ const resCode = Babel.transformFromAstSync(resAst.ast, null, babelOptions);

babelAst = JSON.parse(serializeToJson(babelAst)); // somehow this helps with that
const sourcePath = babelAst.fileName;
const jsPath = filePath.replace(FSHARP_EXT, ".js");
const outPath = Path.join(outDir, jsPath); //TODO: handle duplicate files with different content
const outPath = ensureUniquePath(sourcePath, outDir, jsPath);
ensureDirExists(Path.dirname(outPath));

@@ -118,0 +131,0 @@ const babelOptions = commonjs ?

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc