From d97c42af4bc2df3fd5eb85c19a80cc30b2e7ad81 Mon Sep 17 00:00:00 2001 From: Matt Sherman Date: Mon, 9 Dec 2024 16:38:51 -0500 Subject: [PATCH] Resolve monorepo package paths in esbuild --- apps/website/_config.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/website/_config.ts b/apps/website/_config.ts index 224e400..f6a91c3 100644 --- a/apps/website/_config.ts +++ b/apps/website/_config.ts @@ -1,3 +1,5 @@ +import { resolve } from 'jsr:@std/path'; + import lume from 'lume/mod.ts'; import date from 'lume/plugins/date.ts'; @@ -37,6 +39,22 @@ site.use( minify: false, platform: 'browser', target: 'esnext', + plugins: [ + { + name: 'import-map-alias', + setup(build) { + build.onResolve({ filter: /^@mg5dev\/(.+)$/ }, (args) => { + const packageName = args.path.replace('@mg5dev/', ''); + const resolvedPath = resolve( + '../../packages', + packageName, + 'mod.ts' + ); + return { path: resolvedPath, namespace: 'file' }; + }); + }, + }, + ], }, }) );