#preload-helper.js file

19 messages · Page 1 of 1 (latest)

bitter patrol
#

i have when i build file called preload-helper.{hash}.js

const f = "modulepreload",
  h = function (c) {
    return "/" + c;
  },
  l = {},
  v = function (a, s, p) {
    let i = Promise.resolve();
    if (s && s.length > 0) {
      document.getElementsByTagName("link");
      const r = document.querySelector("meta[property=csp-nonce]"),
        n = r?.nonce || r?.getAttribute("nonce");
      i = Promise.all(
        s.map((e) => {
          if (((e = h(e)), e in l)) return;
          l[e] = !0;
          const o = e.endsWith(".css"),
            u = o ? '[rel="stylesheet"]' : "";
          if (document.querySelector(`link[href="${e}"]${u}`)) return;
          const t = document.createElement("link");
          if (
            ((t.rel = o ? "stylesheet" : f),
            o || ((t.as = "script"), (t.crossOrigin = "")),
            (t.href = e),
            n && t.setAttribute("nonce", n),
            document.head.appendChild(t),
            o)
          )
            return new Promise((d, m) => {
              t.addEventListener("load", d),
                t.addEventListener("error", () =>
                  m(new Error(`Unable to preload CSS for ${e}`))
                );
            });
        })
      );
    }
    return i
      .then(() => a())
      .catch((r) => {
        const n = new Event("vite:preloadError", { cancelable: !0 });
        if (((n.payload = r), window.dispatchEvent(n), !n.defaultPrevented))
          throw r;
      });
  };
export { v as _ };

why it is there i did not added it

amber cape
bitter patrol
#
export default defineConfig({
  vite: {
    build: {
      modulePreload: false,
      polyfill: false
    }
  },
})

that is not working

amber cape
#

Try

export default defineConfig({
  vite: {
    build: {
      modulePreload: {
        polyfill: false
      }
    }
  },
})
bitter patrol
#

no that did't work

bitter patrol
#

i have been trying and i asked vite what should i do not to use astro ?
@amber cape

amber cape
bitter patrol
#

it have the same problem

amber cape
#

Hmmm I'll try and take a look. And is it creating that file in dist?

And also, is there a reason you don't want it?

bitter patrol
#

is it creating that file in dist ?
Yes
is there a reason you don't want it
yes
there is some how weird behavior i don't want + there's a console err because of it + i don't want unnecessary js in my docs

#

all of my js is high priority because of that

amber cape
#

Hmmmm I'm really not sure about this! I've never actually seen anything to do with vite module preload before, I've checked my projects and I actually don't see any with it even generated. Are you able to do astro info and post the results here? And maybe your astro config

Also if you do astro build && astro preview does it still load that file?

bitter patrol
#

it's based on dynamic import

#

when i do that it generates

bitter patrol
#

Astro v4.12.1
Node v20.14.0
System Windows (x64)
Package Manager pnpm
Output static
Adapter none
Integrations none

bitter patrol
#

@amber cape should i open a issue