File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,7 @@ export default defineNuxtModule<ModuleOptions>({
5858 const serverConfigFile = findDefaultSdkInitFile ( 'server' ) ;
5959
6060 if ( serverConfigFile ) {
61- // todo: check when this is needed - seems to be needed for sentry-release-injection-file
62- if ( ! moduleOptions . autoInjectServerSentry ) {
61+ if ( moduleOptions . autoInjectServerSentry !== 'experimental_dynamic-import' ) {
6362 // Inject the server-side Sentry config file with a side effect import
6463 addPluginTemplate ( {
6564 mode : 'server' ,
Original file line number Diff line number Diff line change @@ -84,11 +84,21 @@ export function addServerConfigToBuild(
8484 */
8585export function addSentryTopImport ( moduleOptions : SentryNuxtModuleOptions , nitro : Nitro ) : void {
8686 nitro . hooks . hook ( 'close' , async ( ) => {
87- const fileName = nitro . options . commands . preview && getFilenameFromPath ( nitro . options . commands . preview ) ;
88- const serverEntry = fileName ? fileName : 'index.mjs' ;
87+ const fileNameFromCommand = nitro . options . commands . preview && getFilenameFromPath ( nitro . options . commands . preview ) ;
88+
89+ // other presets ('node-server' or 'vercel') have an index.mjs
90+ const presetsWithServerFile = [ 'netlify' ] ;
91+
92+ const entryFileName = fileNameFromCommand
93+ ? fileNameFromCommand
94+ : typeof nitro . options . rollupConfig ?. output . entryFileNames === 'string'
95+ ? nitro . options . rollupConfig ?. output . entryFileNames
96+ : presetsWithServerFile . includes ( nitro . options . preset )
97+ ? 'server.mjs'
98+ : 'index.mjs' ;
8999
90100 const serverDirResolver = createResolver ( nitro . options . output . serverDir ) ;
91- const entryFilePath = serverDirResolver . resolve ( serverEntry ) ;
101+ const entryFilePath = serverDirResolver . resolve ( entryFileName ) ;
92102
93103 try {
94104 fs . readFile ( entryFilePath , 'utf8' , ( err , data ) => {
You can’t perform that action at this time.
0 commit comments