Commit graph

1 commit

Author SHA1 Message Date
bbcecea9d7 **chore: introduce unified Rollup configuration for browser and Node.js builds**
### Changes:
- Added `rollup.config.js` with custom build logic for unified and browser builds:
  - Included TypeScript support with separate configurations (`tsconfig.unified.json` and `tsconfig.browser.json`).
  - Consolidated environment detection logic with `globalThis.__ENV__` for browser, Node.js, and serverless environments.
  - Provided global Buffer polyfill for browser environments.
  - Enabled `inlineDynamicImports` for module compatibility.
- Introduced custom Rollup plugins:
  - Shims for Node.js built-in modules to ensure compatibility in browsers.
  - Fixes for `this` references in TensorFlow.js layers causing errors in browser environments.
- Enabled environment-specific replacements for `process.env.NODE_ENV` during builds.
- Configured outputs for both non-minified and minified builds (`.js` and `.min.js` files).
- Excluded specific dependencies from the bundle to optimize build size.

### Purpose:
Added a versatile Rollup configuration to streamline the build process for both browser and Node.js environments. This setup enhances cross-environment compatibility, reduces redundancy, and ensures better maintainability with unified build logic.
2025-06-19 16:05:59 -07:00