Problem
Platform.Bible's extension host blocks most Node built-ins at runtime with:
Error: Requiring other than papi is not allowed in extensions! Rejected require('fs').
Try using papi.storage or bundling the module into your code with a build tool like webpack
The webpack config comment in webpack.config.base.ts mentions a wiki page on module import restrictions but does not state which built-ins are allowed. Developers naturally add blocked modules to externals (because webpack accepts them without complaint), only to hit a runtime crash after a successful build.
Currently crypto is listed in externals as the one allowed built-in, but there is no list of what else is or isn't available.
Suggested Improvements
- Add a comment to
webpack.config.base.ts next to the externals array:
// Built-in Node modules available at runtime (all others are blocked):
// - crypto
// Do NOT add fs, os, path, etc. — they will compile fine but crash at runtime.
'crypto',
- Add a section to the wiki page on module import restrictions listing:
- Which Node built-ins are available
- The recommended alternative for common patterns (e.g.
papi.storage instead of fs, papi.network instead of raw http)
Context
Discovered while implementing port-file discovery in paratext-copilot. Added fs and os to externals, got a clean build, then hit a runtime crash. The fix (remove them and use fetch-based probing instead) was non-obvious.
Problem
Platform.Bible's extension host blocks most Node built-ins at runtime with:
The webpack config comment in
webpack.config.base.tsmentions a wiki page on module import restrictions but does not state which built-ins are allowed. Developers naturally add blocked modules toexternals(because webpack accepts them without complaint), only to hit a runtime crash after a successful build.Currently
cryptois listed inexternalsas the one allowed built-in, but there is no list of what else is or isn't available.Suggested Improvements
webpack.config.base.tsnext to theexternalsarray:papi.storageinstead offs,papi.networkinstead of rawhttp)Context
Discovered while implementing port-file discovery in paratext-copilot. Added
fsandostoexternals, got a clean build, then hit a runtime crash. The fix (remove them and usefetch-based probing instead) was non-obvious.