From 1221aad973ef9ffe38d5aa713dd7a397b21f60e0 Mon Sep 17 00:00:00 2001 From: Tornado Contrib Date: Mon, 6 May 2024 15:52:06 +0000 Subject: [PATCH] Added script to patch old vuex package --- package.json | 7 ++++--- scripts/vuex.js | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 scripts/vuex.js diff --git a/package.json b/package.json index d9b73b0..7c8a693 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,11 @@ "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", "precommit": "yarn lint", "test": "jest", + "fix:vuex": "node ./scripts/vuex.js", "dev": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" nuxt", - "dev:lts": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt", + "dev:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt", "build": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" nuxt build", - "build:lts": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt build", + "build:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt build", "start": "nuxt start", "update:zip": "node -r esm scripts/updateZip.js", "update:events": "node -r esm scripts/updateEvents.js --network", @@ -18,7 +19,7 @@ "update:tree": "node -r esm scripts/updateTree.js --network", "update:copy": "node -r esm scripts/copyFile.js dist/404.html dist/ipfs-404.html", "generate": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" nuxt generate && yarn update:copy", - "generate:lts": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt generate && yarn update:copy", + "generate:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt generate && yarn update:copy", "check:sync": "node -r esm scripts/checkEventsSync.js", "ipfsUpload": "node scripts/ipfsUpload.js", "deploy:ipfs": "yarn generate && yarn ipfsUpload" diff --git a/scripts/vuex.js b/scripts/vuex.js new file mode 100644 index 0000000..145f80c --- /dev/null +++ b/scripts/vuex.js @@ -0,0 +1,24 @@ +/** + * Manually patch vuex to support Node.js >= 18.x + * + * See issue https://github.com/vuejs/vuex/issues/2160 + * https://github.com/vuejs/vuex/commit/397e9fba45c8b4ec0c4a33d2578e34829bd348d7 + */ +const fs = require('fs') + +const pkgJson = JSON.parse(fs.readFileSync('./node_modules/vuex/package.json', { encoding: 'utf8' })) +const backupJson = JSON.stringify(pkgJson, null, 2) + +let changes = false + +if (!pkgJson.exports['./*']) { + pkgJson.exports['./*'] = './*' + + changes = true +} + + +if (changes) { + fs.writeFileSync('./node_modules/vuex/package.backup.json', backupJson + '\n') + fs.writeFileSync('./node_modules/vuex/package.json', JSON.stringify(pkgJson, null, 2) + '\n') +}