@@ -22,6 +22,7 @@ import { createLogger, Logger } from "./sentry/logger";
2222import { InternalOptions , normalizeUserOptions , validateOptions } from "./options-mapping" ;
2323import { getSentryCli } from "./sentry/cli" ;
2424import { Hub , makeMain } from "@sentry/node" ;
25+ import path from "path" ;
2526
2627// We prefix the polyfill id with \0 to tell other plugins not to try to load or transform it.
2728// This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
@@ -205,29 +206,34 @@ const unplugin = createUnplugin<Options>((options, unpluginMetaContext) => {
205206 transformInclude ( id ) {
206207 logger . debug ( 'Called "transformInclude":' , { id } ) ;
207208
209+ // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
210+ // a windows style path to `releaseInjectionTargets`
211+ const normalizedId = path . normalize ( id ) ;
212+
208213 // We don't want to transform our injected code.
209- if ( id === RELEASE_INJECTOR_ID ) {
214+ if ( normalizedId === RELEASE_INJECTOR_ID ) {
210215 return false ;
211216 }
212217
213218 if ( internalOptions . releaseInjectionTargets ) {
214219 // If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
215220 if ( typeof internalOptions . releaseInjectionTargets === "function" ) {
216- return internalOptions . releaseInjectionTargets ( id ) ;
221+ return internalOptions . releaseInjectionTargets ( normalizedId ) ;
217222 }
218223
219224 return internalOptions . releaseInjectionTargets . some ( ( entry ) => {
220225 if ( entry instanceof RegExp ) {
221- return entry . test ( id ) ;
226+ return entry . test ( normalizedId ) ;
222227 } else {
223- return id === entry ;
228+ const normalizedEntry = path . normalize ( entry ) ;
229+ return normalizedId === normalizedEntry ;
224230 }
225231 } ) ;
226232 } else {
227- const pathIsOrdinary = ! id . includes ( "?" ) && ! id . includes ( "#" ) ;
233+ const pathIsOrdinary = ! normalizedId . includes ( "?" ) && ! normalizedId . includes ( "#" ) ;
228234
229235 const pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS . some (
230- ( allowedFileEnding ) => id . endsWith ( allowedFileEnding )
236+ ( allowedFileEnding ) => normalizedId . endsWith ( allowedFileEnding )
231237 ) ;
232238
233239 return pathIsOrdinary && pathHasAllowedFileEnding ;
0 commit comments