fix: resolve Webpack aliases across Bun installs
This commit is contained in:
parent
ea27d83ea9
commit
6ca4239f16
@ -1,3 +1,5 @@
|
||||
import { existsSync } from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import type { NextConfig } from 'next'
|
||||
@ -5,7 +7,16 @@ import type { NextConfig } from 'next'
|
||||
const configuredBasePath = process.env.NEXT_PUBLIC_PASCAL_BASE_PATH?.trim() ?? ''
|
||||
const basePath = configuredBasePath ? `/${configuredBasePath.replace(/^\/+|\/+$/g, '')}` : undefined
|
||||
const pascalRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
|
||||
const workspaceModule = (name: string) => path.resolve(pascalRoot, 'node_modules', name)
|
||||
const resolveFromEditor = createRequire(import.meta.url).resolve
|
||||
|
||||
function workspaceModule(name: string) {
|
||||
let directory = path.dirname(resolveFromEditor(name))
|
||||
while (directory !== path.dirname(directory)) {
|
||||
if (existsSync(path.join(directory, 'package.json'))) return directory
|
||||
directory = path.dirname(directory)
|
||||
}
|
||||
throw new Error(`Could not resolve package root for ${name}`)
|
||||
}
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
basePath,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user