diff --git a/package-lock.json b/package-lock.json index 46c6975..435c3c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -200,6 +200,27 @@ } } }, + "node_modules/@rollup/plugin-replace": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.5.tgz", + "integrity": "sha512-rYO4fOi8lMaTg/z5Jb+hKnrHHVn8j2lwkqwyS4kTRhKyWOLf2wST2sWXr4WzWiTcoHTp2sTjqUbqIj2E39slKQ==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-terser": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", @@ -2768,6 +2789,16 @@ "resolve": "^1.22.1" } }, + "@rollup/plugin-replace": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.5.tgz", + "integrity": "sha512-rYO4fOi8lMaTg/z5Jb+hKnrHHVn8j2lwkqwyS4kTRhKyWOLf2wST2sWXr4WzWiTcoHTp2sTjqUbqIj2E39slKQ==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "magic-string": "^0.30.3" + } + }, "@rollup/plugin-terser": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", diff --git a/package.json b/package.json index 307d6a5..72cad9e 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-json": "^6.0.1", "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-replace": "^5.0.5", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.5", "@tensorflow/tfjs-backend-cpu": "^3.21.0", diff --git a/rollup.config.ts b/rollup.config.ts index 8b14153..e012e95 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -6,6 +6,7 @@ import { fileURLToPath } from 'node:url' import commonjs from '@rollup/plugin-commonjs' import json from '@rollup/plugin-json' import terser from '@rollup/plugin-terser' +import replace from '@rollup/plugin-replace' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const TSCONFIG = path.resolve(__dirname, 'tsconfig.esm.json') @@ -94,6 +95,10 @@ export default rollup.defineConfig([{ tsconfig: TSCONFIG }), commonjs(), - json() + json(), + replace({ + preventAssignment: true, + 'env().global.fetch != null': true // to remove the use of node-fetch in the browser + }) ] }])