aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorzaverden <zaverden@yandex-team.com>2023-09-07 11:21:16 +0300
committerzaverden <zaverden@yandex-team.com>2023-09-07 12:03:28 +0300
commit447ddf2e497321c9b1236eb5fc733a2d0955d49e (patch)
treee3b66635caf03b3ac6a7a0459ee3e4362cd6686e /build
parent7007b60c42dfde3bb60eeef4f3114e8a91e9b711 (diff)
downloadydb-447ddf2e497321c9b1236eb5fc733a2d0955d49e.tar.gz
feat(TS_PACKAGE): implement modules
Diffstat (limited to 'build')
-rw-r--r--build/conf/ts/ts.conf1
-rw-r--r--build/conf/ts/ts_package.conf44
-rw-r--r--build/plugins/nots.py13
3 files changed, 58 insertions, 0 deletions
diff --git a/build/conf/ts/ts.conf b/build/conf/ts/ts.conf
index 71d3286fe8e..2812035788a 100644
--- a/build/conf/ts/ts.conf
+++ b/build/conf/ts/ts.conf
@@ -57,5 +57,6 @@ macro TS_FILES(Files...) {
@import "${CONF_ROOT}/conf/ts/ts_bundle.conf"
@import "${CONF_ROOT}/conf/ts/ts_library.conf"
@import "${CONF_ROOT}/conf/ts/ts_next.conf"
+@import "${CONF_ROOT}/conf/ts/ts_package.conf"
@import "${CONF_ROOT}/conf/ts/ts_test.conf"
@import "${CONF_ROOT}/conf/ts/ts_vite_bundle.conf"
diff --git a/build/conf/ts/ts_package.conf b/build/conf/ts/ts_package.conf
new file mode 100644
index 00000000000..3e94a73d50d
--- /dev/null
+++ b/build/conf/ts/ts_package.conf
@@ -0,0 +1,44 @@
+_COPY_NODE_MODULES_BUNDLE_CMD=
+
+TS_PACK=$TOUCH_UNIT \
+ && $_COPY_NODE_MODULES_BUNDLE_CMD \
+ && $COPY_CMD ${input:"package.json"} ${output:"package.json"} \
+ && $_TS_FILES_COPY_CMD \
+ ${kv;hide:"p TSP"} ${kv;hide:"pc magenta"}
+
+### @usage: TS_PACKAGE()
+###
+### The TypeScript/JavaScript library module, that does not need any compilation,
+### and is just a set of files and NPM dependencies. List required files in TS_FILES macro.
+### `package.json` is included by default.
+###
+### @example
+###
+### TS_PACKAGE()
+### TS_FILES(
+### eslint.config.json
+### prettierrc.json
+### )
+### END()
+###
+multimodule TS_PACKAGE {
+ module BUILD: _TS_BASE_UNIT {
+ .CMD=TS_PACK
+ .PEERDIRSELF=NODE_MODULES
+ .ALLOWED=TS_FILES
+ .ALIASES=FILES=TS_FILES SRCS=TS_FILES
+
+ # by default multimodule overrides inherited MODULE_TAG to submodule name (BUILD in this case)
+ # but we have to set it to TS for include processor to work
+ SET(MODULE_TAG TS)
+
+ # we should set _COPY_NODE_MODULES_BUNDLE_CMD conditionally,
+ # based on whether module has deps or doesn't have
+ _SET_COPY_NODE_MODULES_BUNDLE_CMD()
+ }
+
+ module NODE_MODULES: _NODE_MODULES_BASE {
+ .ALLOWED=TS_FILES
+ .ALIASES=FILES=TS_FILES SRCS=TS_FILES
+ }
+}
diff --git a/build/plugins/nots.py b/build/plugins/nots.py
index 0f7350c64bf..740b0423768 100644
--- a/build/plugins/nots.py
+++ b/build/plugins/nots.py
@@ -524,3 +524,16 @@ def on_ts_files(unit, *files):
if all_cmds:
new_cmds.insert(0, all_cmds)
unit.set(["_TS_FILES_COPY_CMD", " && ".join(new_cmds)])
+
+
+@_with_report_configure_error
+def on_set_copy_node_modules_bundle_cmd(unit):
+ pm = _create_pm(unit)
+ pj = pm.load_package_json_from_dir(pm.sources_path)
+ if pj.has_dependencies():
+ unit.set(
+ [
+ "_COPY_NODE_MODULES_BUNDLE_CMD",
+ '$COPY_CMD ${input:"node_modules.tar"} ${output:"workspace_node_modules.tar"}',
+ ]
+ )