Skip to content

Conversation

vaishcodescape
Copy link

Fix: Resolve build issues and improve stability

What?

This PR fixes several critical build issues in the Next.js codebase:

  • Fix TypeScript error in font loader by properly handling module imports
  • Fix NodeList iterator error in script component by using Array.from()
  • Clean up outdated TODO comments in third-party integrations
  • Add memory optimization to build script to prevent heap out of memory errors
  • Add security comments to clarify safe DOM usage patterns

Why?

The codebase was experiencing build failures due to:

  • JavaScript heap out of memory errors during compilation
  • TypeScript compilation errors preventing successful builds
  • Outdated code comments and import path issues
  • Security linter warnings that needed proper documentation

These issues were blocking development and causing inconsistent build behavior across different environments.

How?

  • Memory Optimization: Added NODE_OPTIONS="--max-old-space-size=8192" to the build script in package.json
  • TypeScript Fixes:
    • Font loader: Added as any type assertion for module imports
    • Script component: Used Array.from() to properly handle NodeList iteration
  • Import Paths: Fixed third-party package imports to point to correct source locations
  • Code Cleanup: Removed outdated TODO comments and added security documentation
  • Security: Added proper comments explaining safe DOM manipulation patterns

Files Changed

  • package.json - Added memory optimization
  • packages/next/src/build/webpack/loaders/next-font-loader/index.ts - Fixed module imports
  • packages/next/src/client/script.tsx - Fixed NodeList iterator and security comments
  • packages/next/src/client/set-attributes-from-props.ts - Added security documentation
  • packages/next/script.d.ts - Fixed import paths
  • packages/third-parties/src/google/ga.tsx - Removed outdated TODO
  • packages/third-parties/src/google/gtm.tsx - Removed outdated TODO
  • packages/third-parties/src/google/youtube-embed.tsx - Fixed import path

Testing

  • ✅ Full build completes successfully: pnpm build
  • ✅ TypeScript compilation passes: pnpm lint-typescript
  • ✅ No memory errors during build process
  • ✅ All packages build without issues

- Fix TypeScript error in font loader by properly handling module imports
- Fix NodeList iterator error in script component by using Array.from()
- Clean up outdated TODO comments in third-party integrations
- Add memory optimization to build script to prevent heap out of memory errors
- Add security comments to clarify safe DOM usage patterns
@ijjk
Copy link
Member

ijjk commented Jul 12, 2025

Allow CI Workflow Run

  • approve CI run for commit: ed5252a

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants