-
-
Notifications
You must be signed in to change notification settings - Fork 81
Migrate build system to esbuild #261
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
base: master
Are you sure you want to change the base?
Conversation
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.
- `loglevel` is written as a UMD module and has to be handled differently from axios
- add type exports for all modules via `export type *` - fix browser polyfills by using `empty` modules for node builtins - fix output directories by swapping `lib` and `dist` outputs - update mainFields to prioritize browser field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Could you remove the typesense data dir from this commit:
-
Looks like the individual JS files, source maps and type files inside the
lib
directory are missing now. Could we add those back, so we don't break apps where users might be directly importing these individual files?
-
Could we also add the unminimized Typesense.js file back into
lib
? -
Could we keep the file names consistent with before (all lower case) inside the
dist
directory and also add back the unminified version as well?
7c502dd
to
8dea7d5
Compare
- add `Stemming`, `StemmingDictionaries`, and `StemmingDictionary` classes - implement dictionary CRUD operations with `upsert` and `retrieve` methods - add stemming property to main client class - add tests for stemming functionality
- refactor `StemmingDictionaryCreateSchema` to use single word-root pairs - update `upsert` method to handle JSONL format for dictionaries - fix typo in `StemmingDictionary` class name - change endpoint path from `/stemming/dictionary` to `/dictionaries` - add JSONL conversion for array inputs and string handling
- run `tsc` before `tsup` in `build` script - remove duplicate browser configuration from `tsup.config.ts` - simplify build process while maintaining browser compatibility
- update `.` export to use correct `import` and `require` fields - add `default` field for compatibiliy with typescript imports - rename `browser.ts` entry point to support module resolution - update build configuration to use new entry point
- split `tsconfig.json` into base, cjs and esm variants - update `build` script to use dedicated cjs config - simplify main tsconfig by extending from base config - configure tsup to use esm config for browser builds
- merge `browser.ts` exports into main `Typesense.ts` file - update tsup config to use single entry point - simplify export pattern for core modules - streamline type exports
- add explicit `treeshake` flag in tsup config - set browser-specific mainFields for module resolution - consolidate build optimization settings
- add `src` directory to published files in `package.json` - remove redundant browser file cleanup step - expand package export configuration in `package.json` to include unminified versions of the browser bundle
- add documentation for `SearchClient` browser usage - clarify commonjs and esm bundle formats - update build tool information from browserify to tsup
- avoid module resolution failures from parcel not respecting the `exports` field
- add test for empty array input - add test for empty string input - add test for null input - add test for undefined input
Done in bfdfee0, opted to use tsc for node-specific builds targeting CommonJS
The unminified bundle is now in ae7de6c. Users can access it by using the absolute node_modules path when importing. By default, it will use the minified version.
Changed the entrypoint name altogether in e5aaf4b, to address problems with module resolutions in bundlers like parcel. By default, parcel resolves paths in absolutely, so importing by "typesense/dist" doesn't work currently, as there isn't a "typesense/dist.js" file inside the "dist" bundle. It would only work with "typesense/dist/typesense". |
@jasonbosco I think we need to merge this in order to tackle #288. |
Change Summary
What is this?
This change modernizes the build system by migrating from webpack to tsup (powered by esbuild) for improved bundle generation. It enhances package exports configuration to better support both CommonJS and ESM environments while ensuring proper browser polyfills and type definitions.
Changes
Build System Updates:
tsup.config.ts
with configurations for browser and Node.js targets.mjs
/.js
extensionsPackage Configuration:
exports
field with conditional exports for CJS/ESMmain
,module
, andtypes
fieldscrypto
,http
, andhttps
Dependencies:
@babel/runtime
peer dependencybrowserslist
andbrowserslist-to-esbuild
for browser targetingesbuild-plugins-node-modules-polyfill
for Node.js built-instsup
for build systemType System Improvements:
src/Typesense.ts
:Code Improvements:
src/Typesense/Configuration.ts
:Context
This modernization effort improves the package's compatibility with modern JavaScript tooling while maintaining support for older environments. The migration to tsup provides faster builds and better tree-shaking capabilities, resulting in smaller bundle sizes.
PR Checklist