Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/@vitejs/plugin-react/dist/index.mjs

    rd565449 r0c6b92a  
    5555  window.$RefreshSig$ = prevRefreshSig;
    5656}`;
    57 const sharedFooter = `
     57const sharedFooter = (id) => `
    5858if (import.meta.hot && !inWebWorker) {
    5959  RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
    60     RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
     60    RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
     61  id
     62)}, currentExports);
    6163    import.meta.hot.accept((nextExports) => {
    6264      if (!nextExports) return;
    63       const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports);
     65      const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
     66  id
     67)}, currentExports, nextExports);
    6468      if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
    6569    });
     
    6771}`;
    6872function 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);
    7074}
    7175function addClassComponentRefreshWrapper(code, id) {
    72   return sharedHeader + code + sharedFooter.replace("__SOURCE__", JSON.stringify(id));
     76  return sharedHeader + code + sharedFooter(id);
    7377}
    7478
     
    187191        // This crates issues the react compiler because the re-order is too important
    188192        // 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",
    190194        parserOpts: {
    191195          ...babelOptions.parserOpts,
     
    196200        generatorOpts: {
    197201          ...babelOptions.generatorOpts,
     202          // import attributes parsing available without plugin since 7.26
     203          importAttributesKeyword: "with",
    198204          decoratorsBeforeExport: true
    199205        },
     
    214220    }
    215221  };
    216   const dependencies = ["react", jsxImportDevRuntime, jsxImportRuntime];
     222  const dependencies = [
     223    "react",
     224    "react-dom",
     225    jsxImportDevRuntime,
     226    jsxImportRuntime
     227  ];
    217228  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);
    220233  }
    221234  const viteReactRefresh = {
     
    261274        return;
    262275      }
     276      if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
     277        return;
     278      }
    263279      if (userConfig.build?.rollupOptions?.onwarn) {
    264280        userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
     
    299315  return value !== void 0;
    300316}
    301 function hasCompiler(plugins) {
    302   return plugins.some(
     317function getReactCompilerPlugin(plugins) {
     318  return plugins.find(
    303319    (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler"
    304320  );
    305321}
    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   );
     322function 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;
    310332}
    311333
Note: See TracChangeset for help on using the changeset viewer.