From f7f8ffe689a6a475931355ae21897b8b48ca6ef3 Mon Sep 17 00:00:00 2001 From: Ty Hopp Date: Fri, 20 May 2022 20:46:09 +0800 Subject: [PATCH] refactor(gatsby,gatsby-script): Misc review comments (#35710) refactor(gatsby,gatsby-script): Misc comments from Ward in #35403 Co-authored-by: Michal Piechowiak --- packages/gatsby-script/.babelrc | 5 ++++- packages/gatsby-script/src/gatsby-script.tsx | 6 ++---- packages/gatsby/src/commands/serve.ts | 4 ++-- .../src/internal-plugins/partytown/gatsby-browser.tsx | 4 +++- .../gatsby/src/internal-plugins/partytown/gatsby-node.ts | 6 +++--- packages/gatsby/src/internal-plugins/partytown/proxy.ts | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/gatsby-script/.babelrc b/packages/gatsby-script/.babelrc index 12f6f4d21375b..ff76a7a2f0f3b 100644 --- a/packages/gatsby-script/.babelrc +++ b/packages/gatsby-script/.babelrc @@ -1,3 +1,6 @@ { - "presets": [["babel-preset-gatsby-package", { "browser": true }], "@babel/preset-typescript"] + "presets": [ + ["babel-preset-gatsby-package", { "browser": true, "esm": true }], + "@babel/preset-typescript" + ] } diff --git a/packages/gatsby-script/src/gatsby-script.tsx b/packages/gatsby-script/src/gatsby-script.tsx index 29cb0a3b23381..1e99100026696 100644 --- a/packages/gatsby-script/src/gatsby-script.tsx +++ b/packages/gatsby-script/src/gatsby-script.tsx @@ -67,7 +67,7 @@ export function Script(props: ScriptProps): ReactElement | null { }) break case ScriptStrategy.offMainThread: - if (typeof window !== `undefined` && collectScript) { + if (collectScript) { const attributes = resolveAttributes(props) collectScript(attributes) } @@ -101,7 +101,6 @@ export function Script(props: ScriptProps): ReactElement | null { return (