11
22# VARIABLES #
33
4- # Define the executable to start a browser REPL environment:
5- REPL_BROWSER ?= $(SRC_DIR ) /@stdlib/repl/scripts/browser_run
4+ # Define the path to the `browserify` executable:
5+ BROWSERIFY ?= $(BIN_DIR ) /browserify
6+
7+ # Define the command to create a disposable HTTP server:
8+ repl_tmp_http_server := $(NODE ) $(SRC_DIR ) /@stdlib/tools/disposable-http-server/bin/cli
9+
10+ # Define the source file to bundle:
11+ REPL_BROWSER_SRC ?= $(SRC_DIR ) /@stdlib/repl/scripts/browser.js
12+
13+ # Define command-line options when generating a `browserify` bundle:
14+ REPL_BROWSERIFY_FLAGS ?=
15+
16+ # Define the output directory for a browser bundle:
17+ REPL_BROWSER_BUNDLE_OUT ?= $(BUILD_DIR ) /repl
18+
19+ # Define the output file:
20+ REPL_BROWSER_BUNDLE ?= $(REPL_BROWSER_BUNDLE_OUT ) /bundle.js
621
722
823# TARGETS #
@@ -11,7 +26,35 @@ REPL_BROWSER ?= $(SRC_DIR)/@stdlib/repl/scripts/browser_run
1126#
1227# This target starts a browser REPL environment.
1328
14- repl-browser : $(NODE_MODULES ) $(REPL_BROWSER )
15- $(QUIET ) NODE_ENV=$(NODE_ENV_REPL ) $(NODE ) $(REPL_BROWSER )
29+ repl-browser : $(NODE_MODULES )
30+ $(QUIET ) NODE_ENV=$(NODE_ENV_REPL ) $(BROWSERIFY ) \
31+ $(REPL_BROWSERIFY_FLAGS ) \
32+ $(REPL_BROWSER_SRC ) \
33+ | DEBUG=* $(repl_tmp_http_server ) \
34+ --stdin javascript \
35+ --open
1636
1737.PHONY : repl-browser
38+
39+
40+ # Generate a browser bundle.
41+ #
42+ # This target generates a browser bundle for a browser REPL environment.
43+
44+ repl-browser-bundle : $(NODE_MODULES )
45+ $(QUIET ) $(MKDIR_RECURSIVE ) $(REPL_BROWSER_BUNDLE_OUT )
46+ $(QUIET ) NODE_ENV=$(NODE_ENV_REPL ) $(BROWSERIFY ) \
47+ $(REPL_BROWSERIFY_FLAGS ) \
48+ $(REPL_BROWSER_SRC ) > $(REPL_BROWSER_BUNDLE )
49+
50+ .PHONY : repl-browser-bundle
51+
52+
53+ # Remove browser bundle.
54+ #
55+ # This target removes previously generated browser bundles.
56+
57+ clean-repl-browser-bundle :
58+ $(QUIET ) $(DELETE ) $(DELETE_FLAGS ) $(REPL_BROWSER_BUNDLE_OUT )
59+
60+ .PHONY : clean-repl-browser-bundle
0 commit comments