Skip to content

Conversation

@martijnrusschen
Copy link
Member

Summary

  • Use a variable for the module name in the dynamic require to prevent webpack from statically analyzing it
  • This eliminates the "Module not found: Error: Can't resolve 'date-fns-tz'" warning when the optional peer dependency is not installed

Root Cause

The require("date-fns-tz") statement used a string literal, which webpack's static analysis detected and flagged as a missing module—even though it was wrapped in a try-catch and date-fns-tz is listed as optional in peerDependenciesMeta.

Fix

Changed from:

dateFnsTz = require("date-fns-tz") as DateFnsTz;

To:

const dateFnsTzModuleName = "date-fns-tz";
dateFnsTz = require(dateFnsTzModuleName) as DateFnsTz;

This prevents webpack from statically analyzing the require and showing warnings.

Fixes #6154

Test plan

  • All existing tests pass (1445 tests)
  • Verified the built output uses the variable pattern
  • Linter passes

🤖 Generated with Claude Code

Use a variable for the module name in the dynamic require to prevent
webpack from statically analyzing it and showing "Module not found"
warnings when the optional date-fns-tz peer dependency is not installed.

Fixes #6154

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.25%. Comparing base (403732b) to head (78b9dfc).
⚠️ Report is 34 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6155      +/-   ##
==========================================
+ Coverage   99.18%   99.25%   +0.07%     
==========================================
  Files          30       30              
  Lines        3782     3783       +1     
  Branches     1644     1647       +3     
==========================================
+ Hits         3751     3755       +4     
+ Misses         29       27       -2     
+ Partials        2        1       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martijnrusschen martijnrusschen merged commit 7650a75 into main Dec 17, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v.9.0.0 webpack warning

2 participants