From 922c53e0060ee03635c4e716477180d99bd809a2 Mon Sep 17 00:00:00 2001 From: Suixinlei Date: Sat, 16 Dec 2017 13:19:16 +0800 Subject: [PATCH] doc: add builtin module in building.md Fixes: https://github.com/nodejs/node/issues/12516 Refs: https://github.com/nodejs/node/pull/2497 --- BUILDING.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/BUILDING.md b/BUILDING.md index c459a867ba6096..70a5e93f87c282 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -385,3 +385,26 @@ and [user guide](https://openssl.org/docs/fips/UserGuide-2.0.pdf). `/usr/local/ssl/fips-2.0` 8. Build Node.js with `make -j` 9. Verify with `node -p "process.versions.openssl"` (for example `1.0.2a-fips`) + +## Building Node.js with external core modules + +It is possible to specify one or more JavaScript text files to be bundled in +the binary as builtin modules when building Node.js. + +### Unix / macOS + +This command will make `/root/myModule.js` available via +`require('/root/myModule')` and `./myModule2.js` available via +`require('myModule2')`. + +```console +$ ./configure --link-module '/root/myModule.js' --link-module './myModule2.js' +``` + +### Windows + +To make `./myCustomModule.js` available via `require('myCustomModule')`. + +```console +> .\vcbuild link-module './myCustomModule.js' +```