Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/@vitejs/plugin-react/dist/index.cjs
rd565449 r0c6b92a 63 63 window.$RefreshSig$ = prevRefreshSig; 64 64 }`; 65 const sharedFooter = `65 const sharedFooter = (id) => ` 66 66 if (import.meta.hot && !inWebWorker) { 67 67 RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => { 68 RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports); 68 RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify( 69 id 70 )}, currentExports); 69 71 import.meta.hot.accept((nextExports) => { 70 72 if (!nextExports) return; 71 const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports); 73 const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify( 74 id 75 )}, currentExports, nextExports); 72 76 if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage); 73 77 }); … … 75 79 }`; 76 80 function addRefreshWrapper(code, id) { 77 return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter .replace("__SOURCE__", JSON.stringify(id));81 return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter(id); 78 82 } 79 83 function addClassComponentRefreshWrapper(code, id) { 80 return sharedHeader + code + sharedFooter .replace("__SOURCE__", JSON.stringify(id));84 return sharedHeader + code + sharedFooter(id); 81 85 } 82 86 … … 195 199 // This crates issues the react compiler because the re-order is too important 196 200 // People should use @babel/plugin-transform-react-jsx-development to get back good line numbers 197 retainLines: hasCompiler(plugins)? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",201 retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic", 198 202 parserOpts: { 199 203 ...babelOptions.parserOpts, … … 204 208 generatorOpts: { 205 209 ...babelOptions.generatorOpts, 210 // import attributes parsing available without plugin since 7.26 211 importAttributesKeyword: "with", 206 212 decoratorsBeforeExport: true 207 213 }, … … 222 228 } 223 229 }; 224 const dependencies = ["react", jsxImportDevRuntime, jsxImportRuntime]; 230 const dependencies = [ 231 "react", 232 "react-dom", 233 jsxImportDevRuntime, 234 jsxImportRuntime 235 ]; 225 236 const staticBabelPlugins = typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : []; 226 if (hasCompilerWithDefaultRuntime(staticBabelPlugins)) { 227 dependencies.push("react/compiler-runtime"); 237 const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins); 238 if (reactCompilerPlugin != null) { 239 const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin); 240 dependencies.push(reactCompilerRuntimeModule); 228 241 } 229 242 const viteReactRefresh = { … … 269 282 return; 270 283 } 284 if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) { 285 return; 286 } 271 287 if (userConfig.build?.rollupOptions?.onwarn) { 272 288 userConfig.build.rollupOptions.onwarn(warning, defaultHandler); … … 307 323 return value !== void 0; 308 324 } 309 function hasCompiler(plugins) {310 return plugins. some(325 function getReactCompilerPlugin(plugins) { 326 return plugins.find( 311 327 (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler" 312 328 ); 313 329 } 314 function hasCompilerWithDefaultRuntime(plugins) { 315 return plugins.some( 316 (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler" && p[1]?.runtimeModule === void 0 317 ); 330 function getReactCompilerRuntimeModule(plugin) { 331 let moduleName = "react/compiler-runtime"; 332 if (Array.isArray(plugin)) { 333 if (plugin[1]?.target === "17" || plugin[1]?.target === "18") { 334 moduleName = "react-compiler-runtime"; 335 } else if (typeof plugin[1]?.runtimeModule === "string") { 336 moduleName = plugin[1]?.runtimeModule; 337 } 338 } 339 return moduleName; 318 340 } 319 341
Note:
See TracChangeset
for help on using the changeset viewer.