-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gatsby-script): Script component #35403
Conversation
Quick question, why a different e2e test and not using production-runtime for this? |
Separation of concerns, @pieh mentioned this as well and we thought if the extra setup cost of a separate suite becomes a problem we can move these into production runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some remarks but overall looks good
* test(gatsby-script): e2e test scaffolding * test(gatsby-script): Test pre-hydrate strategy * test(gatsby-script): Refactor resource record command * test(gatsby-script): Test post-hydrate strategy * test(gatsby-script): Test idle strategy * test(gatsby-script): Update readme, npm scripts * test(gatsby-script): Remove unnecessary dev Cypress config * test(gatsby-script): DRY middleware intercepts * chore(gatsby-script): e2e circle ci config * chore(gatsby-script): Add e2e to circle ci jobs * chore(gatsby-script): Use published package so e2e tests can resolve it * test(gatsby-script): Add missing network waits to e2e tests
* feat(gatsby-script): Implement inline scripts * test(gatsby-script): Inline scripts unit tests * test(gatsby-script): Set up for e2e tests * test(gatsby-script): Display scripts with sources strategy * test(gatsby-script): dangerouslySetInnerHTML e2e tests * test(gatsby-script): Template literals e2e tests * chore(gatsby-script): Update package readme * chore(gatsby-script): Install latest canary to run in CI * chore(gatsby-script): Try waitForRouteChange to fix inconsistent Cypress network waits * chore(gatsby-script): Try delaying responses so Cypress has time to set up network waits * chore(gatsby-script): Try increasing network response delay even further * chore(gatsby-script): Remove unreliable Cypress network waits entirely
* feat(gatsby-script): Normal attribute implementation * chore(gatsby-script): Bump default command timeout
* feat(gatsy-script): Initial on load callback implementation * test(gatsby-script): Refactor e2e test structure * refactor(gatsby-script): Fix eslint, ts errors * feat(gatsby-script): Handle edge cases from Gatsby link navigation * test(gatsby-script): Adjust e2e tests so they run successfully again * feat(gatsby-script): On load callback e2e tests * test(gatsby-script): Scripts with sources navigation e2e tests * test(gatsby-script): Inline scripts navigation e2e tests * test(gatsby-script): Adjust e2e tests, add comment on edge case * test(gatsby-script): Fix unit tests
* feat(gatsby-script): On error callback * test(gatsby-script): Update on error callback e2e test logic * chore(gatsby-script): Skip inline scripts gatsby link nav test
* feat(gatsby): initial support for off-main-thread in develop Co-authored-by: tyhopp <[email protected]> * feat(gatsby): Refactor partytown local proxy logic * Use origin instead of host in serve/develop proxy Co-authored-by: Michal Piechowiak <[email protected]>
…me suites (#35663) * test(gatsby-script): Production runtime * Develop runtime
* test(gatsby-script): SSR and browser APIs Co-authored-by: Jude Agboola <[email protected]> * Development runtime Co-authored-by: Jude Agboola <[email protected]>
* test(gatsby-script): e2e off-main-thread develop runtime * Test in CI * Production runtime * Update load plugins snapshots again * Post install Chromium for Playwright * Fix tests
* add shim and test * add develop and prod run time e2e tests * review updates * Fix imports * Fix prod runtime imports * Namespace tests Co-authored-by: tyhopp <[email protected]>
…cripts (#35692) * feat(gatsby-script): Apply crossorigin anonymous on off-main-thread scripts * Fix offline test flake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ship it.
There is follow up to do (handling onLoad
and onError
callbacks on duplicate scripts as well as some additional warnings for DX - this will be handled in #35610 that aim to be merged before next stable release)
import proxy from "express-http-proxy" | ||
import type { RequestHandler } from "express" | ||
|
||
export const partytownProxyPath = `/__partytown-proxy` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call it something in this vein
export const partytownProxyPath = `/__partytown-proxy` | |
export const partytownProxyPath = `/__thirdparty-proxy` |
} | ||
} | ||
} else { | ||
console.log(`unexpected shape of forward`, newScript) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only log in develop
console.log(`unexpected shape of forward`, newScript) | |
if (process.env.NODE_ENV === 'development') { | |
console.log(`unexpected shape of forward`, newScript) | |
} |
cy.get(`table[id=script-mark-records] tbody`) | ||
.children() | ||
.should(`have.length`, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This counts the rows of the table, and this is how you know how many scripts got loaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part assertion and I think part flake potential removal as this will (potentially?) wait for expected amount of scripts to report their status before doing assertion on those individual ones
@@ -0,0 +1,3 @@ | |||
{ | |||
"presets": [["babel-preset-gatsby-package", { "browser": true }], "@babel/preset-typescript"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need esm to be true too, to make sure it's going to output smaller bundle size
"presets": [["babel-preset-gatsby-package", { "browser": true }], "@babel/preset-typescript"] | |
"presets": [["babel-preset-gatsby-package", { "browser": true, "esm": true }], "@babel/preset-typescript"] |
}) | ||
break | ||
case ScriptStrategy.offMainThread: | ||
if (typeof window !== `undefined` && collectScript) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useEffects only run on the client so window is always defined.
if (typeof window !== `undefined` && collectScript) { | |
if (collectScript) { |
return ( | ||
<script | ||
type="text/partytown" | ||
async |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async |
return ( | ||
<script | ||
type="text/partytown" | ||
async |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async |
We will address Ward's comments in follow up as they are not blocking. Merging |
refactor(gatsby,gatsby-script): Misc comments from Ward in #35403 Co-authored-by: Michal Piechowiak <[email protected]>
Description
Link to RFC
Merged into this branch
Documentation
#35647