6cd126af41
Release pipeline / Get version (push) Has been cancelled
Release pipeline / Get Chart Name (push) Has been cancelled
Release pipeline / tests (push) Has been cancelled
Release pipeline / builds (push) Has been cancelled
Release pipeline / builds-ghcr (push) Has been cancelled
Release pipeline / test-deployments (push) Has been cancelled
Release pipeline / deploy (push) Has been cancelled
Release pipeline / Helm chart oci (push) Has been cancelled
Release pipeline / npm (push) Has been cancelled
Release pipeline / snyk (push) Has been cancelled
- Add custom IFC converter using web-ifc C++ DLL for geometry extraction - Add GeometryInjector.cs: patches Speckle objects with mesh geometry - Add NativeIfcGeometry.cs: P/Invoke bindings to WebIfcDll - Add CustomMeshConverterFactory.cs: custom Xbim mesh converter - Configure fileimport-service dotnet IFC pipeline - Add VPS deployment config (docker-compose-vps.yml) - Add dev scripts: run_backend.bat, run_frontend.bat, start_dev.bat - Update .gitignore: exclude scratch/IFC-toolkit, engine_web-ifc - Memory optimization for Xbim (MemoryModel mode)
88 lines
2.2 KiB
JavaScript
88 lines
2.2 KiB
JavaScript
import path from 'node:path'
|
|
import { pathToFileURL } from 'node:url'
|
|
import { register } from 'node:module'
|
|
import { appRoot, packageRoot } from './root.js'
|
|
|
|
/**
|
|
* Must be invoked through --import when running the node app to set up the following:
|
|
* - Custom path aliases for imports
|
|
* - Extensionless imports
|
|
* - Directory imports like in CJS
|
|
*/
|
|
|
|
/**
|
|
* PATH ALIAS DEFINITIONS
|
|
*/
|
|
const aliases = {
|
|
'@/': appRoot + '/',
|
|
'#/': packageRoot + '/'
|
|
}
|
|
|
|
/**
|
|
* EXTENSIONS TO EVALUATE FOR EXTENSIONLESS IMPORTS
|
|
*/
|
|
const extensions = ['.ts', '.js', '.mjs', '.cjs', '.json']
|
|
|
|
// Register the module hooks
|
|
register('./esmLoader.js', {
|
|
parentURL: import.meta.url
|
|
})
|
|
|
|
// Custom path resolver
|
|
function resolveAlias(specifier) {
|
|
for (const [alias, target] of Object.entries(aliases)) {
|
|
if (specifier.startsWith(alias)) {
|
|
const relativePath = specifier.replace(alias, target)
|
|
return pathToFileURL(path.resolve(relativePath)).href
|
|
}
|
|
}
|
|
return null // No alias found, fall back to default resolution
|
|
}
|
|
|
|
/**
|
|
* Adjust global ESM resolution logic to allow for path/package aliases, dir imports and extensionless imports
|
|
*/
|
|
export async function resolve(specifier, _context, nextResolve) {
|
|
// Resolve alias
|
|
const aliasResolved = resolveAlias(specifier)
|
|
specifier = aliasResolved || specifier
|
|
|
|
// Try to resolve as is
|
|
if (path.isAbsolute(specifier) && !specifier.startsWith('file://')) {
|
|
specifier = pathToFileURL(specifier).href
|
|
}
|
|
let throwableError = undefined
|
|
try {
|
|
return await nextResolve(specifier)
|
|
} catch (e) {
|
|
throwableError = e
|
|
}
|
|
|
|
const isDirImport = throwableError.code === 'ERR_UNSUPPORTED_DIR_IMPORT'
|
|
|
|
// Didn't work, try with extensions
|
|
for (const ext of extensions) {
|
|
try {
|
|
return await nextResolve(specifier + ext)
|
|
} catch (e) {
|
|
if (!throwableError) {
|
|
throwableError = e
|
|
}
|
|
}
|
|
}
|
|
|
|
// If it was a dir import also, try that with extensions
|
|
specifier = isDirImport ? specifier.replace(/\/$/, '') + '/index' : specifier
|
|
for (const ext of extensions) {
|
|
try {
|
|
return await nextResolve(specifier + ext)
|
|
} catch (e) {
|
|
if (!throwableError) {
|
|
throwableError = e
|
|
}
|
|
}
|
|
}
|
|
|
|
throw throwableError
|
|
}
|