123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- NODEJS_ROOT=
- NODEJS_BIN=$NODEJS_ROOT/node
- TS_TRACE=no
- TS_LOCAL_CLI=no
- TS_YNDEXING=no
- # Use outdir defined in tsconfig (actual not for bundlers, they use own way to define output directory)
- TS_CONFIG_USE_OUTDIR=
- TS_USE_PREBUILT_NOTS_TOOL=yes
- NOTS_TOOL=${tool:"devtools/frontend_build_platform/nots/builder"}
- TS_CONFIG_PATH=tsconfig.json
- ### @usage: TS_CONFIG(ConfigPath)
- ###
- ### Macro sets the path for "TypeScript Config".
- ###
- ### - ConfigPath - config path (one at least)
- ###
- ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-config
- macro TS_CONFIG(FirstConfigPath, ConfigPath...) {
- SET(TS_CONFIG_PATH $FirstConfigPath $ConfigPath)
- }
- # Arguments for the all commands of the `nots/builder`, passed before the command
- NOTS_TOOL_BASE_ARGS=\
- --arcadia-root $ARCADIA_ROOT \
- --arcadia-build-root $ARCADIA_BUILD_ROOT \
- --moddir $MODDIR \
- --local-cli $TS_LOCAL_CLI \
- --nodejs-bin $NODEJS_BIN \
- --pm-script $PM_SCRIPT \
- --pm-type $PM_TYPE \
- --trace $TS_TRACE \
- --verbose $TS_LOG \
- $_YATOOL_PREBUILDER_ARG
- NOTS_TOOL_BUILD_ENV=
- # All variable that potentially can affect CMD are listed for UID generation
- # Requirements does not have effect on output
- # By adding __NO_UID__ suffix we show that this variable is not a part of the UID
- NOTS_TOOL_BUILD_REQUIREMENTS__NO_UID__=
- when($AUTOCHECK == "yes") {
- # we don't want to have requirements for local runs
- NOTS_TOOL_BUILD_REQUIREMENTS__NO_UID__=${requirements;hide:"cpu:4"}
- }
- # Arguments for builders' commands, passed after the command
- NOTS_TOOL_COMMON_BUILDER_ARGS=\
- --output-file ${output:TS_OUTPUT_FILE} ${hide;output:TS_OUTPUT_FILE_UUID} \
- --tsconfigs $TS_CONFIG_PATH \
- --vcs-info "${VCS_INFO_FILE}" \
- $NOTS_TOOL_BUILD_REQUIREMENTS__NO_UID__ \
- $NOTS_TOOL_BUILD_ENV
- ERM_PACKAGES_PATH=devtools/frontend_build_platform/erm/erm-packages.json
- TS_OUTPUT_FILE=output.tar
- TS_OUTPUT_FILE_UUID=output.tar.uuid
- TS_EXCLUDE_DIR_GLOB=(.idea|.vscode|node_modules)/**/*
- TS_COMMON_OUTDIR_GLOB=(build|dist|bundle|\${join=|:WEBPACK_OUTPUT_DIR}|$TS_NEXT_OUTPUT_DIR|$VITE_OUTPUT_DIR)/**/*
- TS_GLOB_EXCLUDE_ADDITIONAL=
- ### @usage: TS_EXCLUDE_FILES_GLOB(GlobExpression)
- ###
- ### Macro sets glob to mark some files to ignore while building.
- ### These files won't be copied to BINDIR.
- ###
- ### - GlobExpression - glob expression
- ###
- ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-exclude-files-glob
- macro TS_EXCLUDE_FILES_GLOB(GlobExpression) {
- SET(TS_GLOB_EXCLUDE_ADDITIONAL $GlobExpression)
- }
- module _TS_BASE_UNIT: _BARE_UNIT {
- # Propagates peers to related modules
- .PEERDIR_POLICY=as_build_from
- .NODE_TYPE=Bundle
- # Needed for DEPENDS in tests to choose right submodule from multimodule
- .FINAL_TARGET=yes
- # use TS_FILES instead of FILES
- .ALIASES=FILES=TS_FILES
- # .NODE_TYPE=Bundle is required for peers propagation, but it also affects
- # how merging of pic/nopic graphs. Here we can override this merging behaviour
- SET(MODULE_TYPE LIBRARY)
- # Include processor works only for TS tag
- SET(MODULE_TAG TS)
- SET(MODULE_LANG TS)
- # TS should peer to TS
- SET(PEERDIR_TAGS TS TS_PROTO)
- # .fake tells builder to not materialize it in results
- SET(MODULE_SUFFIX .ts.fake)
- # We read erm-packages.json during configuration, so we have to include it to configuration cache key
- SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH)
- # PEERDIR that reads required version of tool from package.json
- _PEERDIR_TS_RESOURCE(nodejs)
- _SET_PACKAGE_MANAGER()
- }
- # tag:test
- ESLINT_CONFIG_PATH=.eslintrc.js
- ### @usage: TS_ESLINT_CONFIG(ConfigPath)
- ###
- ### Macro sets the path for ESLint config file.
- ###
- ### - ConfigPath - config path
- ###
- ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-eslint-config
- macro TS_ESLINT_CONFIG(ConfigName) {
- SET(ESLINT_CONFIG_PATH $ConfigName)
- }
- _TS_LINT_SRCS_VALUE=
- ### _TS_CONFIG_EPILOGUE() # internal
- ###
- ### This macro executes macros which should be invoked after all user specified macros in the ya.make file
- macro _TS_CONFIG_EPILOGUE() {
- ### Fill $TS_GLOB_FILES with potential inputs.
- ### It will be reduced later in _TS_CONFIGURE based on `tsconfig.json` rules.
- _GLOB(TS_GLOB_FILES $TS_GLOB_INCLUDE EXCLUDE $TS_GLOB_EXCLUDE)
- _GLOB(_TS_LINT_SRCS_VALUE **/*.(ts|tsx|js|jsx) EXCLUDE $TS_EXCLUDE_DIR_GLOB $TS_COMMON_OUTDIR_GLOB $TS_GLOB_EXCLUDE_ADDITIONAL)
- _SETUP_BUILD_ENV()
- }
- TSYNDEXER_OUTPUT_FILE=tsyndex.ydx.pb2
- TSYNDEXER_TOOL=${tool:"devtools/codenav/typescript"}
- TSYNDEXER_CMD=${cwd:ARCADIA_BUILD_ROOT} \
- $TSYNDEXER_TOOL -m ${CURDIR} -o ${output:TSYNDEXER_OUTPUT_FILE} -r ${ARCADIA_ROOT} \
- ${hide;kv:"pc magenta"} ${hide;kv:"p YTS"} $_AS_HIDDEN_INPUTS(IN $_TS_LINT_SRCS_VALUE)
- ### _DO_TS_YNDEXING() # internal
- ###
- ### Adds a command-node for TS-modules codenavigation indexing.
- ### Output ydx.pb2 file will be processed along with other indexes for other modules and
- ### other languages in ya-bin.
- ### (see _gen_merge_node, _gen_upload_node in devtools/ya/build/graph.py) for details.
- ### The macro is called from nots.py plugin in case we have `TS_YNDEXING=yes` flag set.
- macro _DO_TS_YNDEXING() {
- .CMD=$TSYNDEXER_CMD
- }
- # Used as inputs in TS_COMPILE through `$_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES)`
- TS_INPUT_FILES=
- # List of the files, filled in _TS_CONFIG_EPILOGUE. Will be reduced in _TS_CONFIGURE macro to TS_INPUT_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 \
- $TS_EXCLUDE_DIR_GLOB \
- $TS_COMMON_OUTDIR_GLOB \
- $TS_GLOB_EXCLUDE_ADDITIONAL \
- package.json pnpm-lock.yaml .* \
- tests/**/* **/*.(test|spec).(ts|tsx|js|jsx)
- # Ugly hack for using inputs from the variable
- macro _AS_HIDDEN_INPUTS(IN{input}[]) {
- # "context=TEXT" exclude file from the "include processing"
- .CMD=${hide;context=TEXT;input:IN}
- }
- _TS_FILES_COPY_CMD=
- ### TS_FILES(Files...)
- ###
- ### Adds files to output as is. Similar to FILES but works for TS build modules
- ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/TS_PACKAGE#ts-files
- macro TS_FILES(Files...) {
- # TODO: FBP-1795
- _TS_FILES($Files)
- }
- ### TS_FILES_GLOB(Glob...)
- ###
- ### Adds files to output by glob, e.g. TS_FILES_GLOB(**/*.css)
- ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/TS_PACKAGE#ts-files-glob
- macro TS_FILES_GLOB(Glob...) {
- _GLOB(FILES_BY_GLOB ${Glob})
- TS_FILES(${FILES_BY_GLOB})
- }
- ### @usage TS_LARGE_FILES(DESTINATION dest_dir Files...)
- ###
- ### Use large file ether from working copy or from remote storage via placeholder <File>.external
- ### If <File> is present locally (and not a symlink!) it will be copied to build directory.
- ### Otherwise macro will try to locate <File>.external, parse it retrieve ot during build phase.
- ###
- ### Then file will be copied to DESTINATION folder preserving file structure.
- ### Copied file becomes output of TS_PACKAGE
- ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/TS_PACKAGE#ts-large-files
- macro TS_LARGE_FILES(DESTINATION="~~required~~", FILES...) {
- LARGE_FILES($FILES)
- # TODO: FBP-1795
- _TS_LARGE_FILES($DESTINATION $FILES)
- }
- @import "${CONF_ROOT}/conf/ts/node_modules.conf"
- @import "${CONF_ROOT}/conf/ts/ts_next.conf"
- @import "${CONF_ROOT}/conf/ts/ts_package.conf"
- @import "${CONF_ROOT}/conf/ts/ts_proto.conf"
- @import "${CONF_ROOT}/conf/ts/ts_test.conf"
- @import "${CONF_ROOT}/conf/ts/ts_tsc.conf"
- @import "${CONF_ROOT}/conf/ts/ts_vite.conf"
- @import "${CONF_ROOT}/conf/ts/ts_webpack.conf"
|