Fix Turbopack module resolution for lzma and restore path imports
This commit is contained in:
1 parent
a5044c80d7
commit
e06596391e
35 files changed
+392
-333
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import { existsSync, promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { resolveFigureSwfUrl } from "@/lib/services/figure-source";
|
||||
import { listFigureLibraries } from "@/lib/services/figuremap";
|
||||
import { getGamedataRoot } from "@/lib/services/furni-asset-dirs";
|
||||
import { downloadFile } from "@/lib/services/import/core/download";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
import { convertSwfToNitro } from "@/lib/services/swf-to-nitro";
|
||||
import { getRuntimePath } from "@/lib/utils/runtime-path";
|
||||
|
||||
export interface FigureListItem {
|
||||
lib: string;
|
||||
@@ -24,11 +24,11 @@ export interface ImportFigureResult {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
const FIGURE_NITRO_DIR_FALLBACK = path.join(
|
||||
const FIGURE_NITRO_DIR_FALLBACK = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ process.cwd(),
|
||||
"public/nitro-assets/bundled/figure",
|
||||
);
|
||||
const FIGURE_SWF_DIR_FALLBACK = path.join(
|
||||
const FIGURE_SWF_DIR_FALLBACK = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ process.cwd(),
|
||||
"public/swf/gordon",
|
||||
);
|
||||
@@ -40,7 +40,10 @@ async function getFigureNitroDir(): Promise<string> {
|
||||
if (configured) return configured;
|
||||
const gamedataRoot = await getGamedataRoot();
|
||||
if (gamedataRoot)
|
||||
return path.join(/*turbopackIgnore: true*/ gamedataRoot, "bundled/figure");
|
||||
return getRuntimePath(
|
||||
/*turbopackIgnore: true*/ gamedataRoot,
|
||||
"bundled/figure",
|
||||
);
|
||||
return FIGURE_NITRO_DIR_FALLBACK;
|
||||
}
|
||||
|
||||
@@ -66,7 +69,7 @@ export async function ensureFigureDirs(): Promise<void> {
|
||||
}
|
||||
|
||||
async function nitroPathFor(lib: string): Promise<string> {
|
||||
return path.join(
|
||||
return getRuntimePath(
|
||||
/*turbopackIgnore: true*/ await getFigureNitroDir(),
|
||||
`${lib}.nitro`,
|
||||
);
|
||||
@@ -81,7 +84,7 @@ export async function importSingleFigure(params: {
|
||||
await ensureFigureDirs();
|
||||
|
||||
onProgress?.("downloading");
|
||||
const swfPath = path.join(
|
||||
const swfPath = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ await getFigureSwfDir(),
|
||||
`${lib}.swf`,
|
||||
);
|
||||
@@ -158,7 +161,7 @@ export async function getFigureList(params: {
|
||||
lib: l.id,
|
||||
revision: l.revision,
|
||||
nitroExists: existsSync(
|
||||
/*turbopackIgnore: true*/ path.join(nitroDir, `${l.id}.nitro`),
|
||||
/*turbopackIgnore: true*/ getRuntimePath(nitroDir, `${l.id}.nitro`),
|
||||
),
|
||||
previewType: l.parts?.[0]?.type,
|
||||
previewId: l.parts?.[0]?.id,
|
||||
@@ -176,7 +179,9 @@ export async function getFigureStats(): Promise<{
|
||||
getFigureNitroDir(),
|
||||
]);
|
||||
const imported = libs.filter((l) =>
|
||||
existsSync(/*turbopackIgnore: true*/ path.join(nitroDir, `${l.id}.nitro`)),
|
||||
existsSync(
|
||||
/*turbopackIgnore: true*/ getRuntimePath(nitroDir, `${l.id}.nitro`),
|
||||
),
|
||||
).length;
|
||||
return { total: libs.length, imported, missing: libs.length - imported };
|
||||
}
|
||||
Reference in new issue
Block a user