Skip to content

Commit

Permalink
patch safe buffer to use cjs imports between tauri packaging on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeepee committed Oct 22, 2023
1 parent 6416a1a commit fc40fe8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"tauri": "tauri",
"eject": "vite eject",
"build": "vite build",
"package-ad4m": "yarn run build && yarn tauri build --verbose"
"package-ad4m": "run-script-os",
"package-ad4m:windows": "yarn run build && yarn tauri build --verbose",
"package-ad4m:macos": "yarn run build && yarn tauri build --verbose",
"package-ad4m:linux": "yarn run build && ./scripts/path-safe-buffer.sh && yarn tauri build --verbose && ./scripts/reverse-path-safe-buffer.sh"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -62,7 +65,8 @@
"customize-cra": "1.0.0",
"react-app-rewired": "^2.2.1",
"react-error-overlay": "6.0.9",
"vite": "^4.0.1"
"vite": "^4.0.1",
"run-script-os": "^1.1.6"
},
"resolutions": {
"react-error-overlay": "6.0.9"
Expand Down
3 changes: 3 additions & 0 deletions ui/scripts/patch-safe-buffer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sed "s/import buffer from 'node:buffer';/const buffer = require('buffer');/" ../node_modules/safe-buffer/index.js

sed "s/import buffer from 'node:buffer'/const buffer = require('buffer');/" ../node_modules/safer-buffer/safer.js
3 changes: 3 additions & 0 deletions ui/scripts/reverse-path-safe-buffer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sed "s/const buffer = require('buffer');/import buffer from 'node:buffer';/" ../node_modules/safe-buffer/index.js

sed "s/const buffer = require('buffer');/import buffer from 'node:buffer';/" ../node_modules/safer-buffer/safer.js

0 comments on commit fc40fe8

Please sign in to comment.