aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/ts/ts_vite_bundle.conf
blob: 4c6590b6871e507aeab238219e0c737771c6790e (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
# VITE_ROOT is defined by _PEERDIR_TS_RESOURCE(vite)
VITE_ROOT=
VITE_OUTPUT_DIR=dist
VITE_CONFIG_PATH=vite.config.ts

TS_BUNDLE_VITE=$TOUCH_UNIT \
    && $_TS_FILES_COPY_CMD \
    && $ADD_VCS_INFO_FILE_CMD \
    && ${cwd:BINDIR} $NOTS_TOOL bundle-vite $NOTS_TOOL_BASE_ARGS \
      --moddir $MODDIR \
      --ts-config ${input:TS_CONFIG_PATH} \
      --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \
      --vite-resource $VITE_ROOT \
      --vite-config ${input:VITE_CONFIG_PATH} \
      --vcs-info "${VCS_INFO_FILE}" \
      --output-dir ${VITE_OUTPUT_DIR} \
    ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \
    ${output;hide:"package.json"} ${output;hide:"output.tar"} \
    ${kv;hide:"p TSVB"} ${kv;hide:"pc magenta"}

### @usage: VITE_OUTPUT(DirName)
###
### Macro sets the output directory name for TS_VITE_BUNDLE module.
###
### - DirName - output directory name ("dist" by default).
macro VITE_OUTPUT(DirName) {
    SET(VITE_OUTPUT_DIR $DirName)
}

### @usage: TS_VITE_BUNDLE([name])
###
### The Vite bundle, bundles JavaScript code.
### Build results are packed as `output.tar`.
###
### @example
###
###     TS_VITE_BUNDLE()
###         SRCS(src/index.ts)
###     END()
###
multimodule TS_VITE_BUNDLE {
    module BUILD: _TS_BASE_UNIT {
        .CMD=TS_BUNDLE_VITE
        .PEERDIRSELF=NODE_MODULES
        # epilogue is not inherited from TS_LIBRARY
        .EPILOGUE=_TS_CONFIG_EPILOGUE

        # 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)

        _PEERDIR_TS_RESOURCE(vite)
        SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json)
        SET(TS_CONFIG_DEDUCE_OUT no)

        _TS_GLOB()
        _TS_CONFIGURE($TS_CONFIG_PATH)

        # we should set NODE_MODULES_BUNDLE_AS_OUTPUT conditionally,
        # based on whether module has deps or doesn't have
        _SET_NODE_MODULES_BUNDLE_AS_OUTPUT()
    }

    module NODE_MODULES: _NODE_MODULES_BASE {
    }
}