diff --git a/packages/core/src/utils/filesystem.ts b/packages/core/src/utils/filesystem.ts index 2631ad4..d0370c1 100644 --- a/packages/core/src/utils/filesystem.ts +++ b/packages/core/src/utils/filesystem.ts @@ -284,12 +284,13 @@ export async function createOPFSFileSystem() { */ export async function useFileSystem(events: typeof EVENTS, type: "OPFS" | "DEFAULT" = "OPFS") { try { - switch (type) { - case "DEFAULT": - return createDefaultFileSystem(); - case "OPFS": - return await createOPFSFileSystem(); - } + return createDefaultFileSystem(); + // switch (type) { + // case "DEFAULT": + // return createDefaultFileSystem(); + // case "OPFS": + // return await createOPFSFileSystem(); + // } } catch (e) { events.emit('logger.warn', e); } diff --git a/packages/core/src/utils/get-esbuild.ts b/packages/core/src/utils/get-esbuild.ts index cf562c4..5752d5b 100644 --- a/packages/core/src/utils/get-esbuild.ts +++ b/packages/core/src/utils/get-esbuild.ts @@ -31,7 +31,7 @@ export async function getEsbuild(platform: Platform = PLATFORM_AUTO): Promise import type { ConfigOptions } from "../../configs/options"; -import type { BuildConfig } from "@bundlejs/core/src/build"; +import type { BuildConfig, ESBUILD } from "@bundlejs/core"; -import { build, compress, deepAssign, setFile } from "@bundlejs/core/src/index"; +import { build, compress, setFile, deepAssign, TheFileSystem } from "@bundlejs/core/src/index"; import { parseConfig } from "./parse-config"; import { DefaultConfig } from "../../configs/options"; import { initOpts, ready } from "./utils/init"; +// const timeFormatter = new Intl.RelativeTimeFormat("en", { +// style: "narrow", +// numeric: "auto", +// }); + +// const inputModelResetValue = [ +// 'export * from "@okikio/animate";' +// ].join("\n"); + +// let WASM_MODULE: Uint8Array; export async function bundle(fileName: string, content: string, _config = "export default {}") { - setFile("/index.tsx", content); + + const fs = await TheFileSystem; + const start = performance.now(); + + setFile(fs, "/index.tsx", content); const newConfig = await parseConfig(_config); const config = deepAssign({}, DefaultConfig, newConfig) as ConfigOptions; @@ -19,6 +33,7 @@ export async function bundle(fileName: string, content: string, _config = "expor const buildConfig = config as BuildConfig; const result = await build({ + entryPoints: ["/index.tsx"], ...buildConfig, init: initOpts, }); @@ -29,7 +44,16 @@ export async function bundle(fileName: string, content: string, _config = "expor result.contents.map(x => x.contents), config.compression ); - return { ...result, ...sizeInfo }; + + const end = performance.now(); + + return { + ...result, + ...sizeInfo, + + // time: timeFormatter.format((end - start) / 1000, "seconds"), + // rawTime: (end - start) / 1000, + }; } export default bundle; \ No newline at end of file