ts.conf 5.7 KB

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