@exodus/stasis 1.0.0-rc.3 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/scan.js +14 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/stasis",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
4
|
"description": "File-level source bundles and lockfiles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -120,10 +120,10 @@
|
|
|
120
120
|
"dependencies": {
|
|
121
121
|
"@babel/generator": "^7.29.7",
|
|
122
122
|
"@exodus/bytes": "^1.16.0",
|
|
123
|
-
"@exodus/stasis-core": "1.0.0-rc.
|
|
124
|
-
"@exodus/stasis-plugins": "1.0.0-rc.
|
|
123
|
+
"@exodus/stasis-core": "1.0.0-rc.4",
|
|
124
|
+
"@exodus/stasis-plugins": "1.0.0-rc.4",
|
|
125
125
|
"@preventive/archive": "^1.4.1",
|
|
126
|
-
"@preventive/deptree": "^1.5.
|
|
126
|
+
"@preventive/deptree": "^1.5.3",
|
|
127
127
|
"@preventive/lockfile": "^1.3.0",
|
|
128
128
|
"@preventive/rn": "1.0.0-alpha.8",
|
|
129
129
|
"@preventive/upstream": "^1.8.0",
|
package/src/scan.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { basename, dirname, extname, isAbsolute, join, resolve as resolvePath, relative } from 'node:path'
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
3
3
|
import { createRequire, isBuiltin } from 'node:module'
|
|
4
|
+
import { totalmem } from 'node:os'
|
|
4
5
|
import assert from 'node:assert/strict'
|
|
5
6
|
import { packageType } from '@exodus/stasis-core/bundle-util'
|
|
6
7
|
import { classifyExtension, classifyFormat, JS_EXTENSIONS, nestedMap, relativeEscapes } from '@exodus/stasis-core/util'
|
|
@@ -21,13 +22,23 @@ const JSX_EXTS = new Set(['.js', '.cjs', '.mjs'])
|
|
|
21
22
|
|
|
22
23
|
const TS_EXTS = new Set(['.ts', '.cts', '.mts', '.tsx'])
|
|
23
24
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
25
|
+
// Raw transfer reserves 6 GiB for the parser's buffer, of which a parse writes only what it takes. Linux refuses one
|
|
26
|
+
// mapping past its RAM and swap, so on a smaller machine (a 4 GiB function) that buffer can't be had: a RangeError on
|
|
27
|
+
// the main thread, and in a worker under Node 26 the worker terminated as out of heap, past any catch. The machine's
|
|
28
|
+
// memory, or its process's where that is less, is to hold that buffer and the rest of the process. Never on Vercel
|
|
29
|
+
// (VERCEL_ENV set, in its builds and functions alike), whose functions are that small machine.
|
|
30
|
+
const RAW_TRANSFER_MEMORY = 8 * 2 ** 30
|
|
31
|
+
export const rawTransferFits = (memory = Math.min(totalmem(), process.constrainedMemory() || Infinity), env = process.env) =>
|
|
32
|
+
env.VERCEL_ENV === undefined && memory >= RAW_TRANSFER_MEMORY
|
|
33
|
+
|
|
34
|
+
// Required lazily so non-JS bundlers don't load the native oxc parser. Raw transfer, where the platform takes it and
|
|
35
|
+
// its buffer fits, hands each AST over from the parser's own buffer rather than as JSON, which takes longer to parse
|
|
36
|
+
// than the source.
|
|
26
37
|
let _parser
|
|
27
38
|
export function getParser() {
|
|
28
39
|
if (_parser === undefined) {
|
|
29
40
|
const oxc = createRequire(import.meta.url)('oxc-parser')
|
|
30
|
-
_parser = oxc.rawTransferSupported() ? { ...oxc, parseSync: (file, source, options) => oxc.parseSync(file, source, { experimentalRawTransfer: true, ...options }) } : oxc
|
|
41
|
+
_parser = oxc.rawTransferSupported() && rawTransferFits() ? { ...oxc, parseSync: (file, source, options) => oxc.parseSync(file, source, { experimentalRawTransfer: true, ...options }) } : oxc
|
|
31
42
|
}
|
|
32
43
|
return _parser
|
|
33
44
|
}
|