|
19 | 19 | fs.writeFileSync(path.join(strictDir, 'package.json'), '{"private":true}'); |
20 | 20 | execFileSync('npm', ['install', '--ignore-scripts', '--no-audit', '--no-fund', '--prefer-online', '--omit=dev', '--omit=optional', tarball], { cwd: strictDir, stdio: 'inherit' }); |
21 | 21 | const installedBytes = sizeOf(path.join(strictDir, 'node_modules')); |
22 | | - if (installedBytes > 55 * MiB) throw new Error(`Strict production install is ${(installedBytes / MiB).toFixed(2)} MiB; limit is 55 MiB.`); |
| 22 | + if (installedBytes > 24 * MiB) throw new Error(`Strict production install is ${(installedBytes / MiB).toFixed(2)} MiB; limit is 24 MiB.`); |
23 | 23 | const native = filesUnder(path.join(strictDir, 'node_modules')).filter((file) => file.endsWith('.node')); |
24 | 24 | if (native.length) throw new Error(`Strict production install contains native binaries:\n${native.join('\n')}`); |
25 | 25 | const installScripts = filesUnder(path.join(strictDir, 'node_modules')).filter((file) => file.endsWith('package.json')).flatMap((file) => { |
|
44 | 44 | fs.writeFileSync(path.join(defaultDir, 'package.json'), '{"private":true}'); |
45 | 45 | execFileSync('npm', ['install', '--ignore-scripts', '--no-audit', '--no-fund', '--prefer-online', '--omit=dev', tarball], { cwd: defaultDir, stdio: 'inherit' }); |
46 | 46 | const defaultBytes = sizeOf(path.join(defaultDir, 'node_modules')); |
| 47 | + if (defaultBytes > 30 * MiB) throw new Error(`Default production install is ${(defaultBytes / MiB).toFixed(2)} MiB; limit is 30 MiB.`); |
47 | 48 | const defaultNative = filesUnder(path.join(defaultDir, 'node_modules')).filter((file) => file.endsWith('.node')).length; |
| 49 | + if (defaultNative) throw new Error('Default installation must not pull in native canvas extensions.'); |
| 50 | + for (const directory of [strictDir, defaultDir]) { |
| 51 | + const files = filesUnder(path.join(directory, 'node_modules')); |
| 52 | + if (files.some(file => /node_modules[\\/](@napi-rs[\\/]|pdfjs-dist[\\/])/.test(file))) { |
| 53 | + throw new Error('PDF parsing must use the embedded runtime, without a separate canvas/PDF.js dependency.'); |
| 54 | + } |
| 55 | + } |
| 56 | + const defaultCli = path.join(defaultDir, 'node_modules', '.bin', 'deckops'); |
| 57 | + const defaultOutput = path.join(workspace, 'default-pdf-smoke'); |
| 58 | + const defaultSmoke = JSON.parse(execFileSync(defaultCli, ['parse', path.join(root, 'tests/generated/test.pdf'), |
| 59 | + '--engine', 'local', '--preflight', 'off', '--output', defaultOutput, '--json'], {encoding:'utf8'})); |
| 60 | + if (!defaultSmoke.ok || defaultSmoke.engine !== 'local') throw new Error('Default production install failed the local PDF smoke test.'); |
| 61 | + const ir = JSON.parse(fs.readFileSync(path.join(defaultOutput, 'ir.json'), 'utf8')); |
| 62 | + const parserVersion = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).dependencies['pdf-lite-parse']; |
| 63 | + if (ir.producer.version !== parserVersion) throw new Error('Installed PDF parser version does not match the dependency pin.'); |
48 | 64 | process.stdout.write(`tarball ${(item.size / MiB).toFixed(2)} MiB; strict install ${(installedBytes / MiB).toFixed(2)} MiB; default install ${(defaultBytes / MiB).toFixed(2)} MiB (${defaultNative} native binaries); cold-start P95 ${p95.toFixed(0)} ms; PDF RSS ${(measured.maxRssBytes / MiB).toFixed(2)} MiB; files >1 MiB ${large.length}\n`); |
49 | 65 | } finally { |
50 | 66 | if (tarball) fs.rmSync(tarball, { force: true }); |
|
0 commit comments