diff options
author | khoden <khoden@yandex-team.com> | 2023-09-08 15:29:00 +0300 |
---|---|---|
committer | khoden <khoden@yandex-team.com> | 2023-09-08 15:56:50 +0300 |
commit | 1327369eb8af90ffcedd1ea4f256c374c52097e1 (patch) | |
tree | a9c6154771777732ad4d1e568ca0de9b38dfab12 /build/conf/ts | |
parent | 2a4344f50e5d190be68407dca1cada777cb04c45 (diff) | |
download | ydb-1327369eb8af90ffcedd1ea4f256c374c52097e1.tar.gz |
Изменить логику дискаверинга исходников для TS_*
### Принцип работы:
1. В переменную с помощью `_GLOB` записываем все файлы (*.ts *.tsx *.js *.jsx *.json) проекта, кроме дефолтного списка исключений (типа `node_modules`, `dist/build`, `a.yaml`, `ya.make`, `package.json`, `pnpm-lock.yaml` и подобные)
2. Вызываем плагин (`_TS_CONFIGURE`), где удаляем из этого списка файлы, не покрываемые `tsconfig.json`
3. Получившееся значение используем в качестве источника инпутов для таргета
Diffstat (limited to 'build/conf/ts')
-rw-r--r-- | build/conf/ts/ts.conf | 34 | ||||
-rw-r--r-- | build/conf/ts/ts_bundle.conf | 18 | ||||
-rw-r--r-- | build/conf/ts/ts_library.conf | 16 | ||||
-rw-r--r-- | build/conf/ts/ts_next.conf | 23 | ||||
-rw-r--r-- | build/conf/ts/ts_vite_bundle.conf | 18 |
5 files changed, 80 insertions, 29 deletions
diff --git a/build/conf/ts/ts.conf b/build/conf/ts/ts.conf index 2812035788..dbf05d48b0 100644 --- a/build/conf/ts/ts.conf +++ b/build/conf/ts/ts.conf @@ -6,6 +6,8 @@ NOTS_TOOL_BASE_ARGS=--build-root $ARCADIA_BUILD_ROOT --bindir $BINDIR --curdir $ NOTS_TOOL_NODE_MODULES_BUNDLE=$BINDIR/node_modules.tar ERM_PACKAGES_PATH=devtools/frontend_build_platform/erm/erm-packages.json +TS_CONFIG_PATH=tsconfig.json + module _TS_BASE_UNIT: _BARE_UNIT { # Propagates peers to related modules .PEERDIR_POLICY=as_build_from @@ -44,6 +46,38 @@ macro _TS_CONFIG_EPILOGUE() { _SETUP_EXTRACT_NODE_MODULES_RECIPE(${MODDIR}) } + +# List of the inputs, filled in _TS_GLOB. Will be reduced in _TS_CONFIGURE macro. +# Used as inputs in TS_COMPILE through `$_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES)` +TS_GLOB_FILES= + +# Hardcoded "include" list (all other files will be ignored) +TS_GLOB_INCLUDE=**/* + +# Hardcoded "exclude" list (reasonable default). +TS_GLOB_EXCLUDE=$TS_CONFIG_PATH \ + ya.make a.yaml \ + (.code|.idea)/**/* \ + (build|dist|bundle|.*|$TS_NEXT_OUTPUT_DIR)/**/* \ + node_modules/**/* package.json pnpm-lock.yaml .* \ + tests/**/* **/*.(test|spec).(ts|tsx|js|jsx) + + +### _TS_GLOB() # internal +### +### Fill $TS_GLOB_FILES with potential inputs. +### It will be reduced later in _TS_CONFIGURE based on `tsconfig.json` rules. +### So it is important to call _TS_CONFIGURE() with _TS_GLOB()! +macro _TS_GLOB() { + _GLOB(TS_GLOB_FILES $TS_GLOB_INCLUDE EXCLUDE $TS_GLOB_EXCLUDE) +} + +# Ugly hack for using inputs from the variable +macro _TS_GLOB_AS_INPUTS(IN{input}[]) { + .CMD=${input;hide:IN} +} + + _TS_FILES_COPY_CMD= ### TS_FILES(Files...) diff --git a/build/conf/ts/ts_bundle.conf b/build/conf/ts/ts_bundle.conf index 370e5be750..0c455cff20 100644 --- a/build/conf/ts/ts_bundle.conf +++ b/build/conf/ts/ts_bundle.conf @@ -6,12 +6,17 @@ WEBPACK_CONFIG_PATH=webpack.config.js TS_BUNDLE_WEBPACK=$TOUCH_UNIT \ && $_TS_FILES_COPY_CMD \ && $ADD_VCS_INFO_FILE_CMD \ - && ${cwd:BINDIR} $NOTS_TOOL bundle-webpack $NOTS_TOOL_BASE_ARGS --webpack-resource $WEBPACK_ROOT \ - --moddir $MODDIR --webpack-config ${input:WEBPACK_CONFIG_PATH} --ts-config ${input:TS_CONFIG_PATH} \ - --vcs-info "${VCS_INFO_FILE}" --output-dir ${WEBPACK_OUTPUT_DIR} \ - --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ - ${input;hide:"./package.json"} ${TS_CONFIG_FILES} ${output;hide:"output.tar"} \ - ${output;hide:"package.json"} ${kv;hide:"p TSWP"} ${kv;hide:"pc magenta"} + && ${cwd:BINDIR} $NOTS_TOOL bundle-webpack $NOTS_TOOL_BASE_ARGS \ + --moddir $MODDIR \ + --ts-config ${input:TS_CONFIG_PATH} \ + --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ + --webpack-resource $WEBPACK_ROOT \ + --webpack-config ${input:WEBPACK_CONFIG_PATH} \ + --vcs-info "${VCS_INFO_FILE}" \ + --output-dir ${WEBPACK_OUTPUT_DIR} \ + ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \ + ${output;hide:"package.json"} ${output;hide:"output.tar"} \ + ${kv;hide:"p TSWP"} ${kv;hide:"pc magenta"} ### @usage: WEBPACK_OUTPUT(DirName) ### @@ -48,6 +53,7 @@ multimodule TS_BUNDLE { SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json) SET(TS_CONFIG_DEDUCE_OUT no) + _TS_GLOB() _TS_CONFIGURE($TS_CONFIG_PATH) # we should set NODE_MODULES_BUNDLE_AS_OUTPUT conditionally, diff --git a/build/conf/ts/ts_library.conf b/build/conf/ts/ts_library.conf index d5675daf29..ed3a59fe96 100644 --- a/build/conf/ts/ts_library.conf +++ b/build/conf/ts/ts_library.conf @@ -1,12 +1,16 @@ # TYPESCRIPT_ROOT is defined by _PEERDIR_TS_RESOURCE(typescript) TYPESCRIPT_ROOT= -TS_CONFIG_PATH=tsconfig.json + TS_COMPILE=$TOUCH_UNIT \ && $_TS_FILES_COPY_CMD \ - && ${cwd:BINDIR} $NOTS_TOOL compile-ts $NOTS_TOOL_BASE_ARGS --tsc-resource $TYPESCRIPT_ROOT \ - --moddir $MODDIR --ts-config ${input:TS_CONFIG_PATH} --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE \ - $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} ${input;hide:"./package.json"} ${TS_CONFIG_FILES} \ - ${output;hide:"package.json"} ${output;hide:"output.tar"} ${kv;hide:"p TSC"} ${kv;hide:"pc magenta"} + && ${cwd:BINDIR} $NOTS_TOOL compile-ts $NOTS_TOOL_BASE_ARGS \ + --moddir $MODDIR \ + --ts-config ${input:TS_CONFIG_PATH} \ + --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ + --tsc-resource $TYPESCRIPT_ROOT \ + ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \ + ${output;hide:"package.json"} ${output;hide:"output.tar"} \ + ${kv;hide:"p TSC"} ${kv;hide:"pc magenta"} ### @usage: TS_LIBRARY([name]) ### @@ -40,6 +44,8 @@ multimodule TS_LIBRARY { # based on whether module has deps or doesn't have _SET_NODE_MODULES_BUNDLE_AS_OUTPUT() + _TS_GLOB() + _TS_CONFIGURE($TS_CONFIG_PATH) } diff --git a/build/conf/ts/ts_next.conf b/build/conf/ts/ts_next.conf index c9158d773c..bc66e176dc 100644 --- a/build/conf/ts/ts_next.conf +++ b/build/conf/ts/ts_next.conf @@ -2,18 +2,21 @@ NEXT_ROOT= TS_NEXT_OUTPUT_DIR=.next TS_NEXT_CONFIG_PATH=next.config.js -TS_NEXT_SRC_FILES= TS_NEXT_CMD=$TOUCH_UNIT \ && $_TS_FILES_COPY_CMD \ && $ADD_VCS_INFO_FILE_CMD \ && ${cwd:BINDIR} $NOTS_TOOL build-nextjs $NOTS_TOOL_BASE_ARGS \ - --moddir $MODDIR --nextjs-resource $NEXT_ROOT \ - --nextjs-config ${input:TS_NEXT_CONFIG_PATH} --ts-config ${input:TS_CONFIG_PATH} \ - --vcs-info "${VCS_INFO_FILE}" --output-dir ${TS_NEXT_OUTPUT_DIR} \ + --moddir $MODDIR \ + --ts-config ${input:TS_CONFIG_PATH} \ --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ - ${input;hide:"./package.json"} ${TS_CONFIG_FILES} ${output;hide:"output.tar"} \ - ${output;hide:"package.json"} ${kv;hide:"p TSNEXT"} ${kv;hide:"pc magenta"} + --nextjs-resource $NEXT_ROOT \ + --nextjs-config ${input:TS_NEXT_CONFIG_PATH} \ + --vcs-info "${VCS_INFO_FILE}" \ + --output-dir ${TS_NEXT_OUTPUT_DIR} \ + ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \ + ${output;hide:"output.tar"} ${output;hide:"package.json"} \ + ${kv;hide:"p TSNEXT"} ${kv;hide:"pc magenta"} ### @usage: TS_NEXT() ### @@ -31,7 +34,7 @@ multimodule TS_NEXT { .CMD=TS_NEXT_CMD .PEERDIRSELF=NODE_MODULES # epilogue is not inherited from TS_LIBRARY - .EPILOGUE=_TS_NEXT_EPILOG + .EPILOGUE=_TS_CONFIG_EPILOGUE # 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 @@ -41,6 +44,7 @@ multimodule TS_NEXT { SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json) SET(TS_CONFIG_DEDUCE_OUT no) + _TS_GLOB() _TS_CONFIGURE($TS_CONFIG_PATH) # we should set NODE_MODULES_BUNDLE_AS_OUTPUT conditionally, @@ -56,11 +60,6 @@ macro TS_NEXT_CONFIG(Path) { SET(TS_NEXT_CONFIG_PATH $Path) } -macro _TS_NEXT_EPILOG() { - _TS_CONFIG_EPILOGUE() - _GLOB(TS_NEXT_SRC_FILES ${CURDIR}/src/pages/**/* ${CURDIR}/pages/**/* ${CURDIR}/src/app/**/* ${CURDIR}/app/**/* ${CURDIR}/public/**/*) - SRCS($TS_NEXT_SRC_FILES) -} ### @usage: TS_NEXT_OUTPUT(DirName) ### diff --git a/build/conf/ts/ts_vite_bundle.conf b/build/conf/ts/ts_vite_bundle.conf index 74feb6cfd6..4c6590b687 100644 --- a/build/conf/ts/ts_vite_bundle.conf +++ b/build/conf/ts/ts_vite_bundle.conf @@ -6,12 +6,17 @@ VITE_CONFIG_PATH=vite.config.ts TS_BUNDLE_VITE=$TOUCH_UNIT \ && $_TS_FILES_COPY_CMD \ && $ADD_VCS_INFO_FILE_CMD \ - && ${cwd:BINDIR} $NOTS_TOOL bundle-vite $NOTS_TOOL_BASE_ARGS --vite-resource $VITE_ROOT \ - --moddir $MODDIR --vite-config ${input:VITE_CONFIG_PATH} --ts-config ${input:TS_CONFIG_PATH} \ - --vcs-info "${VCS_INFO_FILE}" --output-dir ${VITE_OUTPUT_DIR} \ - --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ - ${input;hide:"./package.json"} ${TS_CONFIG_FILES} ${output;hide:"output.tar"} \ - ${output;hide:"package.json"} ${kv;hide:"p VB"} ${kv;hide:"pc magenta"} + && ${cwd:BINDIR} $NOTS_TOOL bundle-vite $NOTS_TOOL_BASE_ARGS \ + --moddir $MODDIR \ + --ts-config ${input:TS_CONFIG_PATH} \ + --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ + --vite-resource $VITE_ROOT \ + --vite-config ${input:VITE_CONFIG_PATH} \ + --vcs-info "${VCS_INFO_FILE}" \ + --output-dir ${VITE_OUTPUT_DIR} \ + ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \ + ${output;hide:"package.json"} ${output;hide:"output.tar"} \ + ${kv;hide:"p TSVB"} ${kv;hide:"pc magenta"} ### @usage: VITE_OUTPUT(DirName) ### @@ -48,6 +53,7 @@ multimodule TS_VITE_BUNDLE { SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json) SET(TS_CONFIG_DEDUCE_OUT no) + _TS_GLOB() _TS_CONFIGURE($TS_CONFIG_PATH) # we should set NODE_MODULES_BUNDLE_AS_OUTPUT conditionally, |