ts.conf 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. NODEJS_ROOT=
  2. NODEJS_BIN=$NODEJS_ROOT/node
  3. TS_TRACE=no
  4. TS_LOCAL_CLI=no
  5. TS_YNDEXING=no
  6. # Use outdir defined in tsconfig (actual not for bundlers, they use own way to define output directory)
  7. TS_CONFIG_USE_OUTDIR=
  8. TS_USE_PREBUILT_NOTS_TOOL=yes
  9. NOTS_TOOL=${tool:"devtools/frontend_build_platform/nots/builder"}
  10. TS_CONFIG_PATH=tsconfig.json
  11. ### @usage: TS_CONFIG(ConfigPath)
  12. ###
  13. ### Macro sets the path for "TypeScript Config".
  14. ###
  15. ### - ConfigPath - config path (one at least)
  16. ###
  17. ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-config
  18. macro TS_CONFIG(FirstConfigPath, ConfigPath...) {
  19. SET(TS_CONFIG_PATH $FirstConfigPath $ConfigPath)
  20. }
  21. # Arguments for the all commands of the `nots/builder`, passed before the command
  22. NOTS_TOOL_BASE_ARGS=\
  23. --arcadia-root $ARCADIA_ROOT \
  24. --arcadia-build-root $ARCADIA_BUILD_ROOT \
  25. --moddir $MODDIR \
  26. --local-cli $TS_LOCAL_CLI \
  27. --nodejs-bin $NODEJS_BIN \
  28. --pm-script $PM_SCRIPT \
  29. --pm-type $PM_TYPE \
  30. --contribs $NPM_CONTRIBS_PATH \
  31. --trace $TS_TRACE \
  32. --verbose $TS_LOG \
  33. $_YATOOL_PREBUILDER_ARG
  34. NOTS_TOOL_BUILD_ENV=
  35. # All variable that potentially can affect CMD are listed for UID generation
  36. # Requirements does not have effect on output
  37. # By adding __NO_UID__ suffix we show that this variable is not a part of the UID
  38. NOTS_TOOL_BUILD_REQUIREMENTS__NO_UID__=
  39. when($AUTOCHECK == "yes") {
  40. # we don't want to have requirements for local runs
  41. NOTS_TOOL_BUILD_REQUIREMENTS__NO_UID__=${requirements;hide:"cpu:4"}
  42. }
  43. # Arguments for builders' commands, passed after the command
  44. NOTS_TOOL_COMMON_BUILDER_ARGS=\
  45. --output-file ${output:TS_OUTPUT_FILE} ${output;hide:TS_OUTPUT_FILE_UUID} \
  46. --tsconfigs $TS_CONFIG_PATH \
  47. --vcs-info "${VCS_INFO_FILE}" \
  48. $NOTS_TOOL_BUILD_REQUIREMENTS__NO_UID__ \
  49. $NOTS_TOOL_BUILD_ENV
  50. ERM_PACKAGES_PATH=devtools/frontend_build_platform/erm/erm-packages.json
  51. TS_OUTPUT_FILE=output.tar
  52. TS_OUTPUT_FILE_UUID=output.tar.uuid
  53. TS_EXCLUDE_DIR_GLOB=(.idea|.vscode|node_modules)/**/*
  54. TS_COMMON_OUTDIR_GLOB=(build|dist|bundle|\${join=|:WEBPACK_OUTPUT_DIR}|$TS_NEXT_OUTPUT_DIR|$VITE_OUTPUT_DIR)/**/*
  55. TS_GLOB_EXCLUDE_ADDITIONAL=
  56. ### @usage: TS_EXCLUDE_FILES_GLOB(GlobExpression)
  57. ###
  58. ### Macro sets glob to mark some files to ignore while building.
  59. ### These files won't be copied to BINDIR.
  60. ###
  61. ### - GlobExpression - glob expression
  62. ###
  63. ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-exclude-files-glob
  64. macro TS_EXCLUDE_FILES_GLOB(GlobExpression) {
  65. SET(TS_GLOB_EXCLUDE_ADDITIONAL $GlobExpression)
  66. }
  67. module _TS_BASE_UNIT: _BARE_UNIT {
  68. # Propagates peers to related modules
  69. .PEERDIR_POLICY=as_build_from
  70. .NODE_TYPE=Bundle
  71. # Needed for DEPENDS in tests to choose right submodule from multimodule
  72. .FINAL_TARGET=yes
  73. # use TS_FILES instead of FILES
  74. .ALIASES=FILES=TS_FILES
  75. # .NODE_TYPE=Bundle is required for peers propagation, but it also affects
  76. # how merging of pic/nopic graphs. Here we can override this merging behaviour
  77. SET(MODULE_TYPE LIBRARY)
  78. # Include processor works only for TS tag
  79. SET(MODULE_TAG TS)
  80. SET(MODULE_LANG TS)
  81. # TS should peer to TS
  82. SET(PEERDIR_TAGS TS TS_PROTO)
  83. # .fake tells builder to not materialize it in results
  84. SET(MODULE_SUFFIX .ts.fake)
  85. # We read erm-packages.json during configuration, so we have to include it to configuration cache key
  86. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH)
  87. # PEERDIR that reads required version of tool from package.json
  88. _PEERDIR_TS_RESOURCE(nodejs)
  89. _SET_PACKAGE_MANAGER()
  90. }
  91. # tag:test
  92. ESLINT_CONFIG_PATH=.eslintrc.js
  93. ### @usage: TS_ESLINT_CONFIG(ConfigPath)
  94. ###
  95. ### Macro sets the path for ESLint config file.
  96. ###
  97. ### - ConfigPath - config path
  98. ###
  99. ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-eslint-config
  100. macro TS_ESLINT_CONFIG(ConfigName) {
  101. SET(ESLINT_CONFIG_PATH $ConfigName)
  102. }
  103. _TS_LINT_SRCS_VALUE=
  104. ### _TS_CONFIG_EPILOGUE() # internal
  105. ###
  106. ### This macro executes macros which should be invoked after all user specified macros in the ya.make file
  107. macro _TS_CONFIG_EPILOGUE() {
  108. ### Fill $TS_GLOB_FILES with potential inputs.
  109. ### It will be reduced later in _TS_CONFIGURE based on `tsconfig.json` rules.
  110. _GLOB(TS_GLOB_FILES $TS_GLOB_INCLUDE EXCLUDE $TS_GLOB_EXCLUDE)
  111. _GLOB(_TS_LINT_SRCS_VALUE **/*.(ts|tsx|js|jsx) EXCLUDE $TS_EXCLUDE_DIR_GLOB $TS_COMMON_OUTDIR_GLOB $TS_GLOB_EXCLUDE_ADDITIONAL)
  112. _SETUP_BUILD_ENV()
  113. }
  114. TSYNDEXER_OUTPUT_FILE=tsyndex.ydx.pb2
  115. TSYNDEXER_TOOL=${tool:"devtools/codenav/typescript"}
  116. TSYNDEXER_CMD=${cwd:ARCADIA_BUILD_ROOT} \
  117. $TSYNDEXER_TOOL -m ${CURDIR} -o ${output:TSYNDEXER_OUTPUT_FILE} -r ${ARCADIA_ROOT} \
  118. ${kv;hide:"pc magenta"} ${kv;hide:"p YTS"} $_AS_HIDDEN_INPUTS(IN $_TS_LINT_SRCS_VALUE)
  119. ### _DO_TS_YNDEXING() # internal
  120. ###
  121. ### Adds a command-node for TS-modules codenavigation indexing.
  122. ### Output ydx.pb2 file will be processed along with other indexes for other modules and
  123. ### other languages in ya-bin.
  124. ### (see _gen_merge_node, _gen_upload_node in devtools/ya/build/graph.py) for details.
  125. ### The macro is called from nots.py plugin in case we have `TS_YNDEXING=yes` flag set.
  126. macro _DO_TS_YNDEXING() {
  127. .CMD=$TSYNDEXER_CMD
  128. }
  129. # Used as inputs in TS_COMPILE through `$_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES)`
  130. TS_INPUT_FILES=
  131. # List of the files, filled in _TS_CONFIG_EPILOGUE. Will be reduced in _TS_CONFIGURE macro to TS_INPUT_FILES.
  132. TS_GLOB_FILES=
  133. # Hardcoded "include" list (all other files will be ignored)
  134. TS_GLOB_INCLUDE=**/*
  135. # Hardcoded "exclude" list (reasonable default).
  136. TS_GLOB_EXCLUDE=$TS_CONFIG_PATH \
  137. ya.make a.yaml \
  138. $TS_EXCLUDE_DIR_GLOB \
  139. $TS_COMMON_OUTDIR_GLOB \
  140. $TS_GLOB_EXCLUDE_ADDITIONAL \
  141. package.json pnpm-lock.yaml .* \
  142. tests/**/* **/*.(test|spec).(ts|tsx|js|jsx)
  143. # Ugly hack for using inputs from the variable
  144. macro _AS_HIDDEN_INPUTS(IN{input}[]) {
  145. # "context=TEXT" exclude file from the "include processing"
  146. .CMD=${input;hide;context=TEXT:IN}
  147. }
  148. _TS_FILES_COPY_CMD=
  149. ### TS_FILES(Files...)
  150. ###
  151. ### Adds files to output as is. Similar to FILES but works for TS build modules
  152. macro TS_FILES(Files...) {
  153. _TS_FILES($Files)
  154. }
  155. ### TS_FILES_GLOB(Glob...)
  156. ###
  157. ### Adds files to output by glob, e.g. TS_FILES_GLOB(**/*.css)
  158. macro TS_FILES_GLOB(Glob...) {
  159. _GLOB(FILES_BY_GLOB ${Glob})
  160. TS_FILES(${FILES_BY_GLOB})
  161. }
  162. @import "${CONF_ROOT}/conf/ts/node_modules.conf"
  163. @import "${CONF_ROOT}/conf/ts/ts_next.conf"
  164. @import "${CONF_ROOT}/conf/ts/ts_package.conf"
  165. @import "${CONF_ROOT}/conf/ts/ts_proto.conf"
  166. @import "${CONF_ROOT}/conf/ts/ts_test.conf"
  167. @import "${CONF_ROOT}/conf/ts/ts_tsc.conf"
  168. @import "${CONF_ROOT}/conf/ts/ts_vite.conf"
  169. @import "${CONF_ROOT}/conf/ts/ts_webpack.conf"