From ede557369801624163c8c82f757f4a088682f89b Mon Sep 17 00:00:00 2001 From: Ryan Adolf Date: Sun, 24 Dec 2023 22:19:27 -0800 Subject: [PATCH] Fix build scripts --- src/lib/worker/modeling/assembly.ts | 2 +- src/model_gen/keyholes.ts | 11 ++--------- src/model_gen/loader.js | 1 + 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/lib/worker/modeling/assembly.ts b/src/lib/worker/modeling/assembly.ts index b086583..91af4b0 100644 --- a/src/lib/worker/modeling/assembly.ts +++ b/src/lib/worker/modeling/assembly.ts @@ -1,6 +1,6 @@ import type { Handle_TDocStd_Document, OpenCascadeInstance, STEPControl_StepModelType, XCAFDoc_ShapeTool } from '$assets/replicad_single' import { type AnyShape, Compound, getOC, type Plane, type PlaneName, type Point } from 'replicad' -import { blobSTL, combine } from '.' +import { blobSTL, combine } from './index' /** Builds named assemblies for use in STEP models. */ export class Assembly { diff --git a/src/model_gen/keyholes.ts b/src/model_gen/keyholes.ts index 206066e..6b1fc27 100644 --- a/src/model_gen/keyholes.ts +++ b/src/model_gen/keyholes.ts @@ -1,16 +1,10 @@ -import loadOC from '$assets/replicad_single' import { exec } from 'child_process' import { writeFile } from 'fs/promises' import { dirname } from 'path' -import { setOC } from 'replicad' import { fileURLToPath } from 'url' import { promisify } from 'util' import * as modeling from './modeling' - -// patch require and __dirname so that opencascade can import -globalThis.__dirname = 'src/routes/beta/assets' -import { createRequire } from 'module' -globalThis.require = createRequire(import.meta.url) +import { setup } from './node-model' // async function generateMXPCB() { // const ops = await parse("src/assets/key_hole.csg.scad") @@ -42,8 +36,7 @@ async function generateKey(name: string, options: any) { } async function main() { - const oc = await loadOC() - setOC(oc) + await setup() console.log('Compiling ClojureScript...') await promisify(exec)('lein cljsbuild once keyholes', { diff --git a/src/model_gen/loader.js b/src/model_gen/loader.js index d497565..91c9b41 100644 --- a/src/model_gen/loader.js +++ b/src/model_gen/loader.js @@ -17,6 +17,7 @@ export function resolve(specifier, context, defaultResolver) { specifier = `${mappedSpecifier}.js` } else if ( !specifier.endsWith('.ts') && !specifier.endsWith('.js') + && !specifier.endsWith('.cjs') && (specifier.includes('three/') || specifier.includes('./')) ) { specifier = specifier + '.js'