From d4e2c446d176ac9517a3dddc629cf4447e939562 Mon Sep 17 00:00:00 2001 From: verytactical <186486509+verytactical@users.noreply.github.com> Date: Thu, 16 Jan 2025 19:14:56 +0400 Subject: [PATCH] remove unnecessary union --- src/browser.ts | 3 ++- src/node.ts | 5 +++-- src/pipeline/build.ts | 9 ++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/browser.ts b/src/browser.ts index bd5d45fcc..ac2a5cf48 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -2,6 +2,7 @@ import { Config, verifyConfig } from "./config/parseConfig"; import { ILogger } from "./context/logger"; import { build } from "./pipeline/build"; import { createVirtualFileSystem } from "./vfs/createVirtualFileSystem"; +import files from "./stdlib/stdlib"; export async function run(args: { config: Config; @@ -15,7 +16,7 @@ export async function run(args: { const project = createVirtualFileSystem("/", args.files, false); // Create stdlib path - const stdlib = "@stdlib"; + const stdlib = createVirtualFileSystem("@stdlib", files); // Compile let success = true; diff --git a/src/node.ts b/src/node.ts index 33045b7aa..8571caa66 100644 --- a/src/node.ts +++ b/src/node.ts @@ -5,7 +5,8 @@ import { createNodeFileSystem } from "./vfs/createNodeFileSystem"; import { build } from "./pipeline/build"; import { LogLevel, Logger } from "./context/logger"; import { TactErrorCollection } from "./error/errors"; -import { stdlibPath } from "./stdlib/path"; +import { createVirtualFileSystem } from "./vfs/createVirtualFileSystem"; +import files from "./stdlib/stdlib"; type AdditionalCliOptions = { mode?: ConfigProject["mode"]; @@ -116,7 +117,7 @@ export async function run(args: { configWithRootPath.rootPath as string, false, ); - const stdlib = createNodeFileSystem(stdlibPath, false); // Improves developer experience + const stdlib = createVirtualFileSystem("@stdlib", files); for (const config of projects) { logger.info(`💼 Compiling project ${config.name} ...`); let cliConfig = { ...config }; diff --git a/src/pipeline/build.ts b/src/pipeline/build.ts index 5a1c1a31e..b6805ecf8 100644 --- a/src/pipeline/build.ts +++ b/src/pipeline/build.ts @@ -7,14 +7,12 @@ import { CompilerContext } from "../context/context"; import { funcCompile } from "../func/funcCompile"; import { writeReport } from "../generator/writeReport"; import { getRawAST } from "../context/store"; -import files from "../stdlib/stdlib"; import { ILogger, Logger } from "../context/logger"; import { PackageFileFormat } from "../packaging/fileFormat"; import { packageCode } from "../packaging/packageCode"; import { createABITypeRefFromTypeRef } from "../types/resolveABITypeRef"; import { getContracts, getType } from "../types/resolveDescriptors"; import { posixNormalize } from "../utils/filePath"; -import { createVirtualFileSystem } from "../vfs/createVirtualFileSystem"; import { VirtualFileSystem } from "../vfs/VirtualFileSystem"; import { compile } from "./compile"; import { precompile } from "./precompile"; @@ -51,16 +49,13 @@ export function enableFeatures( export async function build(args: { config: ConfigProject; project: VirtualFileSystem; - stdlib: string | VirtualFileSystem; + stdlib: VirtualFileSystem; logger?: ILogger; parser?: Parser; ast?: FactoryAst; }): Promise<{ ok: boolean; error: TactErrorCollection[] }> { const { config, project } = args; - const stdlib = - typeof args.stdlib === "string" - ? createVirtualFileSystem(args.stdlib, files) - : args.stdlib; + const stdlib = args.stdlib; const ast: FactoryAst = args.ast ?? getAstFactory(); const parser: Parser = args.parser ?? getParser(ast, config.options?.parser ?? defaultParser);