ProjectEvergreen/greenwood

static router outputting a `<script>` tag with a path of `/undefined` (when an SSR route is present?)

Open

#1,051 opened on Feb 5, 2023

 (1 comment) (0 reactions) (0 assignees)JavaScript (15 forks)auto 404
CLIRouterbuggood first issue

Repository metrics

Stars
 (132 stars)
PR merge metrics
 (PR metrics pending)

Description

Type of Change

Bug

Summary

Noticed that although the specs are passing, the generated output from the test produces a <script> and <link> preload tag with src and href respectively with a value of /undefined.

<!DOCTYPE html>
  <html lang="en" prefix="og:http://ogp.me/ns#">


  <head>
    <link rel="modulepreload" href="/undefined" as="script">
    ...
    
    <script type="module" src="/undefined"></script>

    <script>window.__greenwood = window.__greenwood || {}; window.__greenwood.currentTemplate = "page";</script>
  </head>

  <body>
    ...
  </body>

</html>

Details

I notice in the test case build.config.static-router.spec.js that it also contains an SSR route, so that is what could be accounting for this errant <script> tag?

Would be good to make sure fix this and adjust the specs accordingly. My guess is to start in the bundle lifecycle and see what resource are being tracked.

Contributor guide