Files
zeekayandHanzo Dev 751ef5c778 rename the framework to @hanzo/gui and the loader to @hanzogui/loader
Both old names are owned by a different npm account (artemis-prime), so
publishing them returns 403 — which is how this surfaced: the 8.0.0 run
shipped @hanzogui/logo and @hanzogui/demos depending on [email protected], a
version that cannot be published and therefore does not exist. Those two
were uninstallable.

@hanzo/gui and @hanzogui/* are ours, so the framework now carries the name
it is imported by everywhere downstream, and the loader moves under the
scope we control.

The rewrite is limited to package references. `DEBUG?.startsWith('hanzogui')`
is a log-namespace filter and join(dir, 'hanzogui') is a path — rewriting
either would change behaviour, so both are untouched.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-30 20:23:18 -07:00

68 lines
2.4 KiB
JavaScript

const { getDefaultConfig } = require('expo/metro-config')
const path = require('path')
const { withGui } = require('@hanzogui/metro-plugin')
// Find the project and workspace directories
const projectRoot = __dirname
// This can be replaced with `find-yarn-workspace-root`
const monorepoRoot = path.resolve(projectRoot, '../..')
const config = getDefaultConfig(projectRoot)
config.resolver.unstable_enablePackageExports =
process.env.GUI_PACKAGE_EXPORTS !== 'false'
// watchman is flaky locally and adds nothing for ci - disable
config.resolver.useWatchman = false
// block unnecessary directories from metro file crawling
config.resolver.blockList = [
/code\/hanzogui\.dev\//,
/code\/.*\/__tests__\//,
/code\/.*\/\.maestro\//,
]
// 1. Watch all files within the monorepo
config.watchFolders = [monorepoRoot]
// 2. Let Metro know where to resolve packages and in what order
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, 'node_modules'),
path.resolve(monorepoRoot, 'node_modules'),
]
// 3. Metro seems to be ignoring nested node_modules for packages in monorepo
// root node_modules (e.g. importing `entities` from
// `node_modules/parse5/...` should resolve to
// `node_modules/parse5/node_modules/entities/...` but Metro resolves it to
// `node_modules/entities/...` instead). This is a workaround to fix it.
config.resolver.resolveRequest = (context, moduleName, platform) => {
try {
return context.resolveRequest(context, moduleName, platform)
} catch (e) {
// This isn't 100% safe, it only fixes build-time errors, but it cannot
// fix runtime errors occurred due to incorrect resolution.
const hierarchicalNodeModulesPaths = path
.dirname(context.originModulePath)
.split(path.sep)
.map((_, i, parts) =>
path.join('/', ...parts.slice(1, parts.length - i), 'node_modules')
)
console.info(
`Metro failed to resolve "${moduleName}" from "${context.originModulePath}": ${e.message}. Retrying with manually specifying hierarchical node_modules paths: ${hierarchicalNodeModulesPaths.join(', ')}`
)
return context.resolveRequest(
{
...context,
nodeModulesPaths: [...hierarchicalNodeModulesPaths, ...context.nodeModulesPaths],
},
moduleName,
platform
)
}
}
module.exports = withGui(config, {
components: ['@hanzo/gui'],
config: './src/hanzogui.config.ts',
})