Skip to content

Commit 38827c7

Browse files
authored
fix: bundle face-detection into liveness (#6805)
* fix: consume face-detection from github * ping tensorflow deps to 4.11 * chore: use patch and bundle over repo
1 parent a58d113 commit 38827c7

File tree

9 files changed

+119
-32
lines changed

9 files changed

+119
-32
lines changed

.github/dependency-review/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ allow-licenses:
3535
- 'zlib-acknowledgement'
3636
- 'Zlib'
3737
- 'LicenseRef-scancode-unicode'
38+
- 'LicenseRef-scancode-public-domain'
3839
allow-dependencies-licenses:
3940
# These packages are needed for nextjs (more detailed sharp)
4041
# they are dynamic libraries and thus do not ship the underlying library

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
"**/react-native-vector-icons",
6969
"**/rollup",
7070
"**/@types/webgl-ext",
71-
"**/@types/webgl-ext/**"
71+
"**/@types/webgl-ext/**",
72+
"**/@tensorflow-models/face-detection"
7273
]
7374
},
7475
"resolutions": {
@@ -136,6 +137,7 @@
136137
"@changesets/changelog-github": "0.4.1",
137138
"@changesets/cli": "^2.27.10",
138139
"@rollup/plugin-commonjs": "^28.0.0",
140+
"@rollup/plugin-node-resolve": "~16.0.3",
139141
"@rollup/plugin-typescript": "^12.1.0",
140142
"@size-limit/preset-big-lib": "^11.2.0",
141143
"@testing-library/jest-dom": "^6.1.5",
@@ -176,4 +178,4 @@
176178
"rimraf": "5.0.0"
177179
}
178180
}
179-
}
181+
}

packages/react-liveness/package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"files": [
2828
"dist",
29-
"packed/tensorflow-models-face-detection-1.0.3.tgz",
29+
"patches",
3030
"LICENSE"
3131
],
3232
"scripts": {
@@ -36,7 +36,7 @@
3636
"clean": "rimraf dist node_modules",
3737
"dev": "yarn build:rollup --watch",
3838
"lint": "yarn typecheck && eslint .",
39-
"prebuild": "rimraf dist",
39+
"prebuild": "rimraf dist && patch-package",
4040
"size": "yarn size-limit",
4141
"test": "jest",
4242
"test:watch": "yarn test --watch",
@@ -48,9 +48,6 @@
4848
"react": "^16.14 || ^17 || ^18 || ^19",
4949
"react-dom": "^16.14 || ^17 || ^18 || ^19"
5050
},
51-
"bundledDependencies": [
52-
"@tensorflow-models/face-detection"
53-
],
5451
"dependencies": {
5552
"@aws-amplify/ui": "6.13.0",
5653
"@aws-amplify/ui-react": "6.13.2",
@@ -62,7 +59,6 @@
6259
"@smithy/signature-v4": "5.1.2",
6360
"@smithy/types": "^4.3.1",
6461
"@mediapipe/face_detection": "^0.4.1646425229",
65-
"@tensorflow-models/face-detection": "./packed/tensorflow-models-face-detection-1.0.3.tgz",
6662
"@tensorflow/tfjs-backend-cpu": "4.11.0",
6763
"@tensorflow/tfjs-backend-wasm": "4.11.0",
6864
"@tensorflow/tfjs-converter": "4.11.0",
@@ -73,20 +69,22 @@
7369
"xstate": "^4.33.6"
7470
},
7571
"devDependencies": {
72+
"@tensorflow-models/face-detection": "~1.0.3",
7673
"@types/jest-when": "^3.5.0",
7774
"blob-polyfill": "^7.0.20220408",
7875
"jest-canvas-mock": "^2.5.2",
7976
"jest-websocket-mock": "^2.4.1",
8077
"jest-when": "^3.5.1",
8178
"mock-socket": "^9.2.1",
79+
"patch-package": "~8.0.1",
8280
"web-streams-polyfill": "^3.2.1"
8381
},
8482
"size-limit": [
8583
{
8684
"name": "FaceLivenessDetector",
8785
"path": "dist/esm/index.mjs",
8886
"import": "{ FaceLivenessDetector }",
89-
"limit": "228 kB"
87+
"limit": "229 kB"
9088
}
9189
]
92-
}
90+
}

packages/react-liveness/packed/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.
Binary file not shown.

packages/react-liveness/patches/@tensorflow-models+face-detection+1.0.3.patch

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.

packages/react-liveness/rollup.config.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from 'rollup';
22
import typescript from '@rollup/plugin-typescript';
33
import commonjs from '@rollup/plugin-commonjs';
44
import styles from 'rollup-plugin-styles';
5+
import resolve from '@rollup/plugin-node-resolve';
56

67
import externals from 'rollup-plugin-node-externals';
78

@@ -28,7 +29,11 @@ const config = defineConfig([
2829
output: cjsOutput,
2930
plugins: [
3031
commonjs(),
31-
externals({ include: /^@aws-amplify/ }),
32+
externals({
33+
include: /^@aws-amplify/,
34+
exclude: '@tensorflow-models/face-detection',
35+
}),
36+
resolve(),
3237
typescript({ declarationDir: 'dist/types', sourceMap, tsconfig }),
3338
],
3439
},
@@ -44,7 +49,11 @@ const config = defineConfig([
4449
},
4550
plugins: [
4651
commonjs(),
47-
externals({ include: /^@aws-amplify/ }),
52+
externals({
53+
include: /^@aws-amplify/,
54+
exclude: '@tensorflow-models/face-detection',
55+
}),
56+
resolve(),
4857
typescript({
4958
outDir: 'dist/esm',
5059
declaration: false,

packed

Lines changed: 0 additions & 1 deletion
This file was deleted.

yarn.lock

Lines changed: 88 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)