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

build: transfer to esbuild for building pipeline #224

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

tharropoulos
Copy link
Contributor

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.

build: add tsup build system

Modernize build system and package configuration

- Migrate from webpack to tsup for improved build process.
- Update package.json with new exports configuration and dependencies.
- Add tsup.config.ts for flexible bundling options.
- Target both cjs and esm.
- Use minified versions of bundle by default.

build: add cjs plugin or esbuild

fix: import from cjs on `require`

build: add esbuild options for bundling UMD dependencies

- `loglevel` is written as a UMD module and has to be handled
  differently from axios

fix: avoid reusing logger import from `loglevel`

chore: remove uneeded common-js dependency for esbuild

chore: remove build artifacts from source control

chore: remove build artifact folders

chore: add prepare script to run before package publishing

chore: update package-lock based on changes
@tharropoulos tharropoulos marked this pull request as draft August 26, 2024 14:56
tharropoulos and others added 20 commits August 28, 2024 13:39
- Implement singleton SimpleLogger class with configurable log levels
- Provide console output methods for different log severities
- Define type-safe interfaces for log levels and their mappings
- Remove need for dependency on external 'loglevel' library
- Remove uses of loglevel dependency for built-in logging
- Implement comprehensive test suite for SimpleLogger class.
- Cover default log level, setLogLevel functionality, and message filtering
based on log levels.
- Ensure proper console method calls for each
log level using chai-spies.
- Introduce the `drop_tokens_mode` parameter to the
`SearchParams` interface, allowing more fine-grained control over token
dropping behavior during search operations.
- Enhance the `SearchParams` interface in `Documents.ts` by adding the
`override_tags` option. This option allows specifying tags for overriding
search behavior, providing greater flexibility in query customization.
build: add tsup build system

Modernize build system and package configuration

- Migrate from webpack to tsup for improved build process.
- Update package.json with new exports configuration and dependencies.
- Add tsup.config.ts for flexible bundling options.
- Target both cjs and esm.
- Use minified versions of bundle by default.

build: add cjs plugin or esbuild

fix: import from cjs on `require`

build: add esbuild options for bundling UMD dependencies

- `loglevel` is written as a UMD module and has to be handled
  differently from axios

fix: avoid reusing logger import from `loglevel`

chore: remove uneeded common-js dependency for esbuild

chore: remove build artifacts from source control

chore: remove build artifact folders

chore: add prepare script to run before package publishing

chore: update package-lock based on changes
- Avoid build discrepancies between authors and users when installing
  from source control directly, by using the last build produced by a
  maintainer
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.

4 participants