diff --git a/examples/cmdline/duk_cmdline.c b/examples/cmdline/duk_cmdline.c index 4f3c1318..fbade8ae 100644 --- a/examples/cmdline/duk_cmdline.c +++ b/examples/cmdline/duk_cmdline.c @@ -12,6 +12,10 @@ * - To enable Duktape.Logger, define DUK_CMDLINE_LOGGING_SUPPORT * and add extras/logging/duk_logging.c to compilation. * + * - To enable Duktape 1.x module loading support (require(), + * Duktape.modSearch() etc), define DUK_CMDLINE_MODULE_SUPPORT and add + * extras/module-duktape/duk_module_duktape.c to compilation. + * * - To enable linenoise and other fancy stuff, compile with -DDUK_CMDLINE_FANCY. * It is not the default to maximize portability. You can also compile in * support for example allocators, grep for DUK_CMDLINE_*. @@ -60,6 +64,9 @@ #if defined(DUK_CMDLINE_LOGGING_SUPPORT) #include "duk_logging.h" #endif +#if defined(DUK_CMDLINE_MODULE_SUPPORT) +#include "duk_module_duktape.h" +#endif #if defined(DUK_CMDLINE_FILEIO) #include #endif @@ -1133,6 +1140,11 @@ static duk_context *create_duktape_heap(int alloc_provider, int debugger, int aj duk_logging_init(ctx, 0 /*flags*/); #endif + /* Register require() (removed in Duktape 2.x). */ +#if defined(DUK_CMDLINE_MODULE_SUPPORT) + duk_module_duktape_init(ctx); +#endif + #if defined(DUK_CMDLINE_FILEIO) duk_push_c_function(ctx, fileio_read_file, 1 /*nargs*/); duk_put_global_string(ctx, "readFile");