**feat: add browser-compatible build configuration and environment detection**
### Changes: - Added `rollup.unified.js` for building a unified bundle with environment detection (Node.js, Browser, Serverless). - Added `rollup_config.js` for browser-specific bundle configurations. - Created `tsconfig.browser.json` for browser builds and `tsconfig.unified.json` for unified builds. - Implemented custom Rollup plugins: - **`fixThisReferences`**: Resolves `this` reference issues in TensorFlow files. - **`nodeModuleShims`**: Provides empty shims for Node.js built-in modules in browser environments. - Updated dependencies in `package-lock.json` to include Rollup plugins and updated `buffer` dependency for polyfills. - Created `src/unified.ts` as the unified library entry point with dynamic environment detection. ### Purpose: - Introduced a unified and browser-compatible build pipeline to ensure `Brainy` can seamlessly operate across multiple environments (Node.js, Browser, Serverless). - Resolved compatibility issues with Node.js modules and specific library builds. - Enhanced flexibility and usability for developers working in diverse runtime environments.
This commit is contained in:
parent
6cedde94b0
commit
8eaf9f67cb
8 changed files with 1125 additions and 46 deletions
30
tsconfig.browser.json
Normal file
30
tsconfig.browser.json
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"declaration": false,
|
||||
"outDir": "./dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ESNext"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": false,
|
||||
"preserveConstEnums": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"examples/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"**/*.test.ts"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue