aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/ts/ts_next.conf
blob: e41f08182fd941e5cd82e020aa48d2eed32de70a (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
TS_NEXT_CONFIG_PATH=next.config.js
TS_NEXT_COMMAND=build

### @usage: TS_NEXT_CONFIG(ConfigPath)
###
### Macro sets the config path for TS_NEXT module.
###
### - ConfigPath - config path. Default value: next.config.js
###
### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/TS_NEXT#ts-next-config
macro TS_NEXT_CONFIG(ConfigPath) {
    SET(TS_NEXT_CONFIG_PATH $ConfigPath)
}


TS_NEXT_OUTPUT_DIR=.next

### @usage: TS_NEXT_OUTPUT(DirName)
###
### Macro sets the output directory name for TS_NEXT module.
###
### - DirName - output directory name. Default value: .next.
###
### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/TS_NEXT#ts-next-output
macro TS_NEXT_OUTPUT(DirName) {
    SET(TS_NEXT_OUTPUT_DIR $DirName)
}

macro TS_NEXT_EXPERIMENTAL_COMPILE() {
    SET(TS_NEXT_COMMAND experimental-compile)
}

TS_NEXT_CMD=$TOUCH_UNIT \
    && $_TS_FILES_COPY_CMD \
    && $ADD_VCS_INFO_FILE_CMD \
    && $NOTS_TOOL $NOTS_TOOL_BASE_ARGS build-next $NOTS_TOOL_COMMON_BUILDER_ARGS \
      --ts-next-command ${TS_NEXT_COMMAND} \
      --bundler-config-path ${input:TS_NEXT_CONFIG_PATH} \
      --output-dirs ${TS_NEXT_OUTPUT_DIR} \
    $_NODE_MODULES_INOUTS ${hide:PEERS} \
    ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES) \
    ${output;hide:"package.json"} \
    ${kv;hide:"pc magenta"} ${kv;hide:"p TS_NXT"}

### @usage: TS_NEXT([name])
###
### NextJS app, built with `next build`. Requires sources to be under /src folder.
### /pages and /app on the root level ar not supported.
### Build results are output.tar.
###
### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/TS_NEXT
###
### @example
###
###     TS_NEXT()
###     END()
###
multimodule TS_NEXT {
    module BUILD: _TS_BASE_UNIT {
        .CMD=TS_NEXT_CMD
        .EPILOGUE=_TS_CONFIG_EPILOGUE
        .PEERDIRSELF=TS_PREPARE_DEPS

        # by default multimodule overrides inherited MODULE_TAG to submodule name (BUILD in this case)
        # but we have to set it to TS for include processor to work
        SET(MODULE_TAG TS)
        SET(MODULE_LANG TS)

        _PEERDIR_TS_RESOURCE(next)

        DISABLE(TS_CONFIG_DEDUCE_OUT)
        DISABLE(TS_CONFIG_USE_OUTDIR)

        _TS_CONFIGURE()

        SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/package.json ${CURDIR}/pnpm-lock.yaml ${CURDIR}/${TS_CONFIG_PATH})
        _TS_ADD_NODE_MODULES_FOR_BUILDER()
    }

    module TS_PREPARE_DEPS: _PREPARE_DEPS_BASE {

    }
}