aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/ts/ts.conf
blob: c97de7323250c7fa521e3b98108e17d14f56ac7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
NODEJS_ROOT=
NODEJS_BIN=$NODEJS_ROOT/node

TS_TRACE=no
TS_LOCAL_CLI=no
# Use outdir defined in tsconfig
TS_CONFIG_USE_OUTDIR=

NOTS_TOOL=${tool:"devtools/frontend_build_platform/nots/builder"}

# 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 \
  --pnpm-script $PNPM_SCRIPT \
  --contribs $NPM_CONTRIBS_PATH \
  --trace $TS_TRACE \
  --verbose $TS_LOG \
  $_YATOOL_PREBUILDER_ARG

# Arguments for builders' commands, passed after the command
NOTS_TOOL_COMMON_BUILDER_ARGS=\
  --output-file ${output:TS_OUTPUT_FILE} ${output;hide:TS_OUTPUT_FILE_UUID} \
  --tsconfigs $TS_CONFIG_PATH \
  --vcs-info "${VCS_INFO_FILE}"

ERM_PACKAGES_PATH=devtools/frontend_build_platform/erm/erm-packages.json

TS_CONFIG_PATH=tsconfig.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|$WEBPACK_OUTPUT_DIR|$TS_NEXT_OUTPUT_DIR|$VITE_OUTPUT_DIR)/**/*
TS_GLOB_EXCLUDE_ADDITIONAL=

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

    # TODO: remove this. YMAKE-1096 / FBP-1184
    _NEVERCACHE()

    # .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)
    # 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 pnpm)
}


# tag:test
ESLINT_CONFIG_PATH=.eslintrc.js
_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_EXTRACT_NODE_MODULES_RECIPE(${MODDIR})
}

# 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=${input;hide;context=TEXT:IN}
}


_TS_FILES_COPY_CMD=

### TS_FILES(Files...)
###
### Adds files to output as is. Similar to FILES but works for TS build modules
macro TS_FILES(Files...) {
    _TS_FILES($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"