**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
53
package.json
53
package.json
|
|
@ -2,15 +2,18 @@
|
|||
"name": "@soulcraft/brainy",
|
||||
"version": "0.8.11",
|
||||
"description": "A vector graph database using HNSW indexing with Origin Private File System storage",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/unified.js",
|
||||
"module": "dist/unified.js",
|
||||
"types": "dist/unified.d.ts",
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
"import": "./dist/unified.js",
|
||||
"types": "./dist/unified.d.ts"
|
||||
},
|
||||
"./min": {
|
||||
"import": "./dist/unified.min.js"
|
||||
},
|
||||
"./types/graphTypes": {
|
||||
"import": "./dist/types/graphTypes.js",
|
||||
|
|
@ -26,16 +29,18 @@
|
|||
},
|
||||
"scripts": {
|
||||
"prebuild": "node scripts/generate-version.js",
|
||||
"build": "tsc",
|
||||
"test": "jest",
|
||||
"start": "node dist/index.js",
|
||||
"build:tsc": "tsc -p tsconfig.unified.json",
|
||||
"build:browser": "rollup -c rollup_config.js",
|
||||
"build:unified": "rollup -c rollup.unified.js",
|
||||
"build": "npm run build:unified",
|
||||
"build:all": "npm run build:tsc && npm run build:browser && npm run build:unified",
|
||||
"start": "node dist/unified.js",
|
||||
"demo": "npm run build:all && npx http-server -o /examples/demo.html",
|
||||
"cli": "node ./cli-wrapper.js",
|
||||
"cli:version": "node ./cli-wrapper.js --version",
|
||||
"cli:v": "node ./cli-wrapper.js -V",
|
||||
"version:patch": "npm version patch",
|
||||
"version:minor": "npm version minor",
|
||||
"version:major": "npm version major",
|
||||
"deploy": "npm run build && npm publish",
|
||||
"deploy": "npm run build:all && npm publish",
|
||||
"postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'"
|
||||
},
|
||||
"bin": {
|
||||
|
|
@ -66,6 +71,11 @@
|
|||
"README.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-replace": "^5.0.5",
|
||||
"@rollup/plugin-typescript": "^11.1.6",
|
||||
"@types/jest": "^29.5.3",
|
||||
"@types/node": "^20.4.5",
|
||||
"@types/omelette": "^0.4.5",
|
||||
|
|
@ -74,19 +84,23 @@
|
|||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"eslint": "^8.45.0",
|
||||
"jest": "^29.6.2",
|
||||
"rollup": "^4.12.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"ts-jest": "^29.1.1",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.427.0",
|
||||
"buffer": "^6.0.3",
|
||||
"commander": "^14.0.0",
|
||||
"omelette": "^0.4.17",
|
||||
"uuid": "^9.0.0",
|
||||
"@tensorflow-models/universal-sentence-encoder": "^1.3.3",
|
||||
"@tensorflow/tfjs": "^4.22.0",
|
||||
"@tensorflow/tfjs-backend-cpu": "^4.22.0",
|
||||
"@tensorflow/tfjs-core": "^4.22.0",
|
||||
"@tensorflow/tfjs-layers": "^4.22.0",
|
||||
"commander": "^14.0.0",
|
||||
"omelette": "^0.4.17",
|
||||
"uuid": "^9.0.0"
|
||||
"@tensorflow/tfjs-layers": "^4.22.0"
|
||||
},
|
||||
"prettier": {
|
||||
"arrowParens": "always",
|
||||
|
|
@ -112,6 +126,7 @@
|
|||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
|
|
@ -120,14 +135,12 @@
|
|||
"argsIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": [
|
||||
"error",
|
||||
"never"
|
||||
]
|
||||
],
|
||||
"no-extra-semi": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue