typesense-js icon indicating copy to clipboard operation
typesense-js copied to clipboard

build: transfer to esbuild for building pipeline

Open tharropoulos opened this issue 1 year ago • 0 comments

Enhance Typesense JS Library for Improved Usability and Maintainability

What is this?

This pull request introduces several improvements to the Typesense JS library's build system:

  1. Optimizing the library bundle size by leveraging esbuild and more specifically tsup.
  2. Improving the library's package structure and exports to provide a more intuitive and user-friendly API.
  3. Updating the documentation and examples to better guide developers in using the library.

These changes aim to make the Typesense JS library more accessible, efficient, and easier to integrate into web applications.

Changes

Added Features:

  1. New tsup configuration in tsup.config.ts:
    • Implemented a tsup configuration to build the library in a more efficient and optimized manner.
    • The configuration includes support for modern browser targets, minification, and separate module and CommonJS builds.
    • This change should result in a smaller bundle size and improved performance for users of the library.

Code Changes:

  1. In package.json:

    • Updated the main, module, and exports fields to reflect the new build targets and file names.
    • Added new development dependencies, including tsup, browserslist-to-esbuild, and esbuild-plugins-node-modules-polyfill, to enable the improved build process.
    • Updated the primary build script to use tsup.
    • Add a prepare script to build before installing new dependencies and publishing to an npm registry.
  2. In src/Typesense/Configuration.ts:

    • Refactored the Configuration class to use the loglevel library directly, rather than importing the entire module.
  3. Removing build artifacts:

    • Removed build artifacts from source control, as they are built upon push to upstream / build time before publishing to an npm registry.

Documentation Updates:

  1. In README.md:
    • Updated the installation and usage instructions to reflect the new build target and file names.

tharropoulos avatar Aug 21 '24 14:08 tharropoulos