brainy/cli-package/rollup.config.js
David Snelling e3d7398022 **feat(patch): enhance TextEncoder/TextDecoder compatibility for TensorFlow.js**
- Refactored `applyTensorFlowPatch` in `textEncoding.ts` to introduce a unified `Platform` class supporting both Node.js and browser environments with native `TextEncoder`/`TextDecoder`.
- Modified global object handling to target `PlatformNode` in Node.js and `PlatformBrowser` in browser environments.
- Added `getTextEncoder` and `getTextDecoder` utility functions to simplify text encoding/decoding across platforms.
- Introduced `setup.ts` to apply environment patches before other modules load.
- Updated CLI entry points (`cli.ts`, `rollup.config.js`) to ensure patching precedes TensorFlow.js usage.
- Enhanced test coverage for TextEncoder compatibility with `test-fix.js`.
- Adjusted imports in `test-tensorflow-textencoder.ts` to align with the updated `./utils/textEncoding.js`.
- Streamlined constructor definitions in `Platform` for improved maintainability.

This update ensures robust compatibility for TensorFlow.js by patching and standardizing text encoding/decoding functionality across environments.
2025-07-11 12:15:11 -07:00

44 lines
984 B
JavaScript

import typescript from '@rollup/plugin-typescript'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import { terser } from 'rollup-plugin-terser'
// CLI configuration
export default {
input: 'src/cli.ts',
context: 'this', // Preserve 'this' context to fix TensorFlow.js issue
output: {
dir: 'dist',
entryFileNames: 'cli.js',
format: 'es',
sourcemap: true,
inlineDynamicImports: true
},
plugins: [
resolve({
browser: false,
preferBuiltins: true
}),
commonjs({
transformMixedEsModules: true
}),
json(),
typescript({
tsconfig: './tsconfig.json',
declaration: false,
declarationMap: false
})
],
external: [
// External dependencies that should not be bundled
'@soulcraft/brainy',
'commander',
'omelette',
'fs',
'path',
'url',
'child_process',
'worker_threads'
]
}