Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/@vitejs/plugin-react/dist/index.mjs
rd565449 r0c6b92a 55 55 window.$RefreshSig$ = prevRefreshSig; 56 56 }`; 57 const sharedFooter = `57 const sharedFooter = (id) => ` 58 58 if (import.meta.hot && !inWebWorker) { 59 59 RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => { 60 RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports); 60 RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify( 61 id 62 )}, currentExports); 61 63 import.meta.hot.accept((nextExports) => { 62 64 if (!nextExports) return; 63 const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports); 65 const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify( 66 id 67 )}, currentExports, nextExports); 64 68 if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage); 65 69 }); … … 67 71 }`; 68 72 function addRefreshWrapper(code, id) { 69 return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter .replace("__SOURCE__", JSON.stringify(id));73 return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter(id); 70 74 } 71 75 function addClassComponentRefreshWrapper(code, id) { 72 return sharedHeader + code + sharedFooter .replace("__SOURCE__", JSON.stringify(id));76 return sharedHeader + code + sharedFooter(id); 73 77 } 74 78 … … 187 191 // This crates issues the react compiler because the re-order is too important 188 192 // People should use @babel/plugin-transform-react-jsx-development to get back good line numbers 189 retainLines: hasCompiler(plugins)? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",193 retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic", 190 194 parserOpts: { 191 195 ...babelOptions.parserOpts, … … 196 200 generatorOpts: { 197 201 ...babelOptions.generatorOpts, 202 // import attributes parsing available without plugin since 7.26 203 importAttributesKeyword: "with", 198 204 decoratorsBeforeExport: true 199 205 }, … … 214 220 } 215 221 }; 216 const dependencies = ["react", jsxImportDevRuntime, jsxImportRuntime]; 222 const dependencies = [ 223 "react", 224 "react-dom", 225 jsxImportDevRuntime, 226 jsxImportRuntime 227 ]; 217 228 const staticBabelPlugins = typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : []; 218 if (hasCompilerWithDefaultRuntime(staticBabelPlugins)) { 219 dependencies.push("react/compiler-runtime"); 229 const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins); 230 if (reactCompilerPlugin != null) { 231 const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin); 232 dependencies.push(reactCompilerRuntimeModule); 220 233 } 221 234 const viteReactRefresh = { … … 261 274 return; 262 275 } 276 if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) { 277 return; 278 } 263 279 if (userConfig.build?.rollupOptions?.onwarn) { 264 280 userConfig.build.rollupOptions.onwarn(warning, defaultHandler); … … 299 315 return value !== void 0; 300 316 } 301 function hasCompiler(plugins) {302 return plugins. some(317 function getReactCompilerPlugin(plugins) { 318 return plugins.find( 303 319 (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler" 304 320 ); 305 321 } 306 function hasCompilerWithDefaultRuntime(plugins) { 307 return plugins.some( 308 (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler" && p[1]?.runtimeModule === void 0 309 ); 322 function getReactCompilerRuntimeModule(plugin) { 323 let moduleName = "react/compiler-runtime"; 324 if (Array.isArray(plugin)) { 325 if (plugin[1]?.target === "17" || plugin[1]?.target === "18") { 326 moduleName = "react-compiler-runtime"; 327 } else if (typeof plugin[1]?.runtimeModule === "string") { 328 moduleName = plugin[1]?.runtimeModule; 329 } 330 } 331 return moduleName; 310 332 } 311 333
Note:
See TracChangeset
for help on using the changeset viewer.