feat: ✨ add options to use Next Script Component or a regular script tag#163
Conversation
There was a problem hiding this comment.
PR Overview
This PR adds the option to choose between the Next.js Script Component and a regular <script> tag in order to work around a Sentry timing issue related to runtime environment initialization.
- Added two new optional props (withNextScriptComponent and nextScriptComponentProps) to EnvScript for toggling component usage and customizing the Next.js Script Component.
- Updated the component implementation to conditionally render either a Next.js Script or a regular <script> tag.
- Extended test coverage in env-script.spec.tsx to verify the new behavior for both rendering strategies.
Reviewed Changes
| File | Description |
|---|---|
| src/script/env-script.tsx | Introduces new props and conditional rendering to support two modes. |
| src/script/env-script.spec.tsx | Adds tests to ensure correct attribute propagation and behavior. |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
02ed4d6 to
68e7fe5
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## development #163 +/- ##
=============================================
Coverage 100.00% 100.00%
=============================================
Files 12 12
Lines 89 95 +6
Branches 14 17 +3
=============================================
+ Hits 89 95 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
68e7fe5 to
3feb6c0
Compare
|
🎉 This PR is included in version 3.3.0-alpha.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 3.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
When using Sentry and
next-runtime-env, we ran into a race condition with Sentry's client side configurationsentry.client.config.ts:sentry.client.config.tsruns before our<PublicEnvScript />, and looks forenv('DEPLOYMENT_ENV'), but these values areundefined"beforeInteractive"and adds the runtime variables towindow.__ENVafter Sentry's init.For now, the quickest solution is to enable users to use both Next.js Script Component and a regular script tag.