diff --git a/CHANGELOG.md b/CHANGELOG.md index d4da256..def87fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # `v8-module-cache` Changelog +## Next + +* Fix segmentation fault with Rosetta on Apple Silicon [#45](https://github.com/zertosh/v8-compile-cache/pull/45). + ## 2021-03-05, Version 2.3.0 * Fix use require.main instead of module.parent [#34](https://github.com/zertosh/v8-compile-cache/pull/34). diff --git a/v8-compile-cache.js b/v8-compile-cache.js index f094da4..56fd061 100644 --- a/v8-compile-cache.js +++ b/v8-compile-cache.js @@ -319,12 +319,14 @@ function getCacheDir() { const dirname = typeof process.getuid === 'function' ? 'v8-compile-cache-' + process.getuid() : 'v8-compile-cache'; + // Avoid cache incompatibility issues with Rosetta on Apple Silicon. + const arch = process.arch; const version = typeof process.versions.v8 === 'string' ? process.versions.v8 : typeof process.versions.chakracore === 'string' ? 'chakracore-' + process.versions.chakracore : 'node-' + process.version; - const cacheDir = path.join(os.tmpdir(), dirname, version); + const cacheDir = path.join(os.tmpdir(), dirname, arch, version); return cacheDir; }