ts.conf 4.9 KB

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