ts.conf 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. # Arguments for builders' commands, passed after the command
  36. NOTS_TOOL_COMMON_BUILDER_ARGS=\
  37. --output-file ${output:TS_OUTPUT_FILE} ${output;hide:TS_OUTPUT_FILE_UUID} \
  38. --tsconfigs $TS_CONFIG_PATH \
  39. --vcs-info "${VCS_INFO_FILE}" \
  40. $NOTS_TOOL_BUILD_ENV
  41. ERM_PACKAGES_PATH=devtools/frontend_build_platform/erm/erm-packages.json
  42. TS_OUTPUT_FILE=output.tar
  43. TS_OUTPUT_FILE_UUID=output.tar.uuid
  44. TS_EXCLUDE_DIR_GLOB=(.idea|.vscode|node_modules)/**/*
  45. TS_COMMON_OUTDIR_GLOB=(build|dist|bundle|\${join=|:WEBPACK_OUTPUT_DIR}|$TS_NEXT_OUTPUT_DIR|$VITE_OUTPUT_DIR)/**/*
  46. TS_GLOB_EXCLUDE_ADDITIONAL=
  47. ### @usage: TS_EXCLUDE_FILES_GLOB(GlobExpression)
  48. ###
  49. ### Macro sets glob to mark some files to ignore while building.
  50. ### These files won't be copied to BINDIR.
  51. ###
  52. ### - GlobExpression - glob expression
  53. ###
  54. ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-exclude-files-glob
  55. macro TS_EXCLUDE_FILES_GLOB(GlobExpression) {
  56. SET(TS_GLOB_EXCLUDE_ADDITIONAL $GlobExpression)
  57. }
  58. module _TS_BASE_UNIT: _BARE_UNIT {
  59. # Propagates peers to related modules
  60. .PEERDIR_POLICY=as_build_from
  61. .NODE_TYPE=Bundle
  62. # Needed for DEPENDS in tests to choose right submodule from multimodule
  63. .FINAL_TARGET=yes
  64. # use TS_FILES instead of FILES
  65. .ALIASES=FILES=TS_FILES
  66. # .NODE_TYPE=Bundle is required for peers propagation, but it also affects
  67. # how merging of pic/nopic graphs. Here we can override this merging behaviour
  68. SET(MODULE_TYPE LIBRARY)
  69. # Include processor works only for TS tag
  70. SET(MODULE_TAG TS)
  71. SET(MODULE_LANG TS)
  72. # TS should peer to TS
  73. SET(PEERDIR_TAGS TS TS_PROTO)
  74. # .fake tells builder to not materialize it in results
  75. SET(MODULE_SUFFIX .ts.fake)
  76. # We read erm-packages.json during configuration, so we have to include it to configuration cache key
  77. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH)
  78. # PEERDIR that reads required version of tool from package.json
  79. _PEERDIR_TS_RESOURCE(nodejs)
  80. _SET_PACKAGE_MANAGER()
  81. }
  82. # tag:test
  83. ESLINT_CONFIG_PATH=.eslintrc.js
  84. ### @usage: TS_ESLINT_CONFIG(ConfigPath)
  85. ###
  86. ### Macro sets the path for ESLint config file.
  87. ###
  88. ### - ConfigPath - config path
  89. ###
  90. ### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/macros#ts-eslint-config
  91. macro TS_ESLINT_CONFIG(ConfigName) {
  92. SET(ESLINT_CONFIG_PATH $ConfigName)
  93. }
  94. _TS_LINT_SRCS_VALUE=
  95. ### _TS_CONFIG_EPILOGUE() # internal
  96. ###
  97. ### This macro executes macros which should be invoked after all user specified macros in the ya.make file
  98. macro _TS_CONFIG_EPILOGUE() {
  99. ### Fill $TS_GLOB_FILES with potential inputs.
  100. ### It will be reduced later in _TS_CONFIGURE based on `tsconfig.json` rules.
  101. _GLOB(TS_GLOB_FILES $TS_GLOB_INCLUDE EXCLUDE $TS_GLOB_EXCLUDE)
  102. _GLOB(_TS_LINT_SRCS_VALUE **/*.(ts|tsx|js|jsx) EXCLUDE $TS_EXCLUDE_DIR_GLOB $TS_COMMON_OUTDIR_GLOB $TS_GLOB_EXCLUDE_ADDITIONAL)
  103. _SETUP_BUILD_ENV()
  104. }
  105. TSYNDEXER_OUTPUT_FILE=tsyndex.ydx.pb2
  106. TSYNDEXER_TOOL=${tool:"devtools/codenav/typescript"}
  107. TSYNDEXER_CMD=${cwd:ARCADIA_BUILD_ROOT} \
  108. $TSYNDEXER_TOOL -m ${CURDIR} -o ${output:TSYNDEXER_OUTPUT_FILE} -r ${ARCADIA_ROOT} \
  109. ${kv;hide:"pc magenta"} ${kv;hide:"p YTS"} $_AS_HIDDEN_INPUTS(IN $_TS_LINT_SRCS_VALUE)
  110. ### _DO_TS_YNDEXING() # internal
  111. ###
  112. ### Adds a command-node for TS-modules codenavigation indexing.
  113. ### Output ydx.pb2 file will be processed along with other indexes for other modules and
  114. ### other languages in ya-bin.
  115. ### (see _gen_merge_node, _gen_upload_node in devtools/ya/build/graph.py) for details.
  116. ### The macro is called from nots.py plugin in case we have `TS_YNDEXING=yes` flag set.
  117. macro _DO_TS_YNDEXING() {
  118. .CMD=$TSYNDEXER_CMD
  119. }
  120. # Used as inputs in TS_COMPILE through `$_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES)`
  121. TS_INPUT_FILES=
  122. # List of the files, filled in _TS_CONFIG_EPILOGUE. Will be reduced in _TS_CONFIGURE macro to TS_INPUT_FILES.
  123. TS_GLOB_FILES=
  124. # Hardcoded "include" list (all other files will be ignored)
  125. TS_GLOB_INCLUDE=**/*
  126. # Hardcoded "exclude" list (reasonable default).
  127. TS_GLOB_EXCLUDE=$TS_CONFIG_PATH \
  128. ya.make a.yaml \
  129. $TS_EXCLUDE_DIR_GLOB \
  130. $TS_COMMON_OUTDIR_GLOB \
  131. $TS_GLOB_EXCLUDE_ADDITIONAL \
  132. package.json pnpm-lock.yaml .* \
  133. tests/**/* **/*.(test|spec).(ts|tsx|js|jsx)
  134. # Ugly hack for using inputs from the variable
  135. macro _AS_HIDDEN_INPUTS(IN{input}[]) {
  136. # "context=TEXT" exclude file from the "include processing"
  137. .CMD=${input;hide;context=TEXT:IN}
  138. }
  139. _TS_FILES_COPY_CMD=
  140. ### TS_FILES(Files...)
  141. ###
  142. ### Adds files to output as is. Similar to FILES but works for TS build modules
  143. macro TS_FILES(Files...) {
  144. _TS_FILES($Files)
  145. }
  146. ### TS_FILES_GLOB(Glob...)
  147. ###
  148. ### Adds files to output by glob, e.g. TS_FILES_GLOB(**/*.css)
  149. macro TS_FILES_GLOB(Glob...) {
  150. _GLOB(FILES_BY_GLOB ${Glob})
  151. TS_FILES(${FILES_BY_GLOB})
  152. }
  153. @import "${CONF_ROOT}/conf/ts/node_modules.conf"
  154. @import "${CONF_ROOT}/conf/ts/ts_next.conf"
  155. @import "${CONF_ROOT}/conf/ts/ts_package.conf"
  156. @import "${CONF_ROOT}/conf/ts/ts_proto.conf"
  157. @import "${CONF_ROOT}/conf/ts/ts_test.conf"
  158. @import "${CONF_ROOT}/conf/ts/ts_tsc.conf"
  159. @import "${CONF_ROOT}/conf/ts/ts_vite.conf"
  160. @import "${CONF_ROOT}/conf/ts/ts_webpack.conf"