Skip to content

Commit

Permalink
fix: resolve aliases relative to module's dir (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored Apr 3, 2023
1 parent ad8eefd commit 94d7c90
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fileURLToPath } from 'url'
import { defu } from 'defu'
import { resolvePath } from 'mlly'
import type { SentryCliPluginOptions } from '@sentry/webpack-plugin'
Expand All @@ -13,6 +14,8 @@ export type { ModuleOptions, ModulePublicRuntimeConfig }

const logger = useLogger('nuxt:sentry')

const moduleDir = fileURLToPath(new URL('./', import.meta.url))

export default defineNuxtModule<ModuleConfiguration>({
meta: {
name: '@nuxtjs/sentry',
Expand Down Expand Up @@ -94,9 +97,9 @@ export default defineNuxtModule<ModuleConfiguration>({
...(options.tracing ? ['@sentry/tracing'] : []),
]
for (const dep of aliasedDependencies) {
nuxt.options.alias[`~${dep}`] = (await resolvePath(dep)).replace(/\/cjs\//, '/esm/')
nuxt.options.alias[`~${dep}`] = (await resolvePath(dep, { url: moduleDir })).replace(/\/cjs\//, '/esm/')
}
nuxt.options.alias['~@sentry/browser-sdk'] = (await resolvePath('@sentry/browser/esm/sdk'))
nuxt.options.alias['~@sentry/browser-sdk'] = (await resolvePath('@sentry/browser/esm/sdk', { url: moduleDir }))

if (serverSentryEnabled(options)) {
/**
Expand Down

0 comments on commit 94d7c90

Please sign in to comment.