Skip to content
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

[2.0] Major package upgrades, better TypeScript support, smaller build #413

Merged
merged 9 commits into from
Jan 27, 2025

Conversation

SanderMuller
Copy link
Contributor

This PR modernizing the library with upgraded dependencies, enhanced TypeScript support, and improved compatibility with modern Node.js environments.


Key Changes

  1. Node.js Version Upgrade:

    • Dropped support for Node.js 10.
    • Laravel Echo now requires Node.js 20+.
  2. TypeScript Enhancements:

    • Upgraded TypeScript from V4 to the latest V5.7
    • Refined type definitions for Pusher, Socket.IO, and custom broadcasters.
    • Improved IntelliSense and stricter type checking for better developer experience.
    • Requires TypeScript 5.7+.
  3. Dependency Upgrades:

    • Updated several dependencies to their latest secure versions, addressing vulnerabilities in older packages such as glob.
    • Upgraded Rollup, ESLint, and related plugins for improved performance and maintainability. This includes an upgrade to the ESlint flat file config system.
    • Made sure external optional dependencies like vue, axios, jquery, and @hotwired/turbo are not bundled.
  4. Modernized Build Process:

    • Optimized Rollup configuration for ES modules and CommonJS outputs.
    • Added support for dynamic imports to handle optional dependencies gracefully.
  5. Developer Experience Improvements:

    • Updated ESLint configuration to use the flat config system in ESLint 9.
    • Streamlined TypeScript and build setups for faster iterations.

Breaking Changes (Contributor only)

  1. Node.js Requirement (Contributor only):

    • Minimum Node.js version: 20+.
    • Consumers using the distributed package (NPM / dist/) are unaffected.
  2. TypeScript Compatibility (Contributor only):

    • TypeScript 5.7 or newer is required for compatibility with updated type definitions.
    • The compiled output remains compatible with earlier TypeScript versions.
  3. ESLint Config (Contributor only):

    • Migrated to ESLint 9's flat configuration system, which may require adjustments in custom setups.

Benefits

  • Improved Type Safety: Better typings for broadcasters and optional dependencies.
  • Faster Builds: Optimized Rollup configuration and dependency updates.
  • Reduced Bundle Sizes: Rollup upgrade & configuration and Typescript import as type improvements result in reduced bundle size (151KB -> 140KB for the entire dist folder, 43KB -> 29KB for echo.iife.js).
  • Security Improvements: Vulnerable packages like glob have been updated to secure versions as well as Eslint major upgrade.
  • Future-Proofed: Compatibility with modern Node.js and TypeScript environments.

Testing done

  1. Jest still passes.
  2. I have tested the above changes on a Pusher and Reverb setup locally in two big projects leveraging websockets. Both using Webpack with Laravel Mix.
  3. Eslint and TypeScript have way better coverage now as well.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@SanderMuller SanderMuller marked this pull request as ready for review January 26, 2025 18:00
return new NullChannel();
}

/**
* Get a channel instance by name.
*/
channel(name: string): NullChannel {
channel(_name: string): NullChannel {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these need to be renamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tells ESlint that it's an unused argument

@taylorotwell taylorotwell merged commit 55f6de3 into laravel:master Jan 27, 2025
4 checks passed
@taylorotwell
Copy link
Member

Thanks @SanderMuller!

@SanderMuller SanderMuller deleted the pusher-and-socketio-types branch January 27, 2025 21:45
@nandi95
Copy link

nandi95 commented Feb 13, 2025

@SanderMuller Thanks for doing this!
Can you perhaps look at this PR see if anything is usable from it here? https://github.com/laravel/echo/pull/356/files

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.

None yet

3 participants