idlize

Форк
0
/
rollup.config.mjs 
78 строк · 2.6 Кб
1
/*
2
 * Copyright (c) 2024 Huawei Device Co., Ltd.
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License.
5
 * You may obtain a copy of the License at
6
 *
7
 * http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 * See the License for the specific language governing permissions and
13
 * limitations under the License.
14
 */
15
import nodeResolve from "@rollup/plugin-node-resolve";
16
import terser from "@rollup/plugin-terser";
17
import typescript from "@rollup/plugin-typescript";
18
import * as path from "path";
19

20
const ENABLE_SOURCE_MAPS = false;  // Enable for debugging
21

22
/** @type {import("rollup").RollupOptions} */
23
export default {
24
    input: "./src/main.ts",
25
    output: {
26
        file: "./lib/index.js",
27
        format: "commonjs",
28
        sourcemap: ENABLE_SOURCE_MAPS,
29
        sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
30
            // For some reason Rollup adds extra ../ to relativeSourcePath, remove it
31
            let absolute = path.join(sourcemapPath, relativeSourcePath);
32
            let relative = path.relative(path.dirname(sourcemapPath), absolute);
33
            return relative
34
        },
35
        plugins: [
36
            // terser()
37
        ],
38
        banner: [
39
            "#!/usr/bin/env node",
40
            APACHE_LICENSE_HEADER()
41
        ].join("\n"),
42
    },
43
    external: ["commander", "typescript", "webidl2"],
44
    plugins: [
45
        typescript({
46
            outputToFilesystem: false,
47
            module: "ESNext",
48
            sourceMap: ENABLE_SOURCE_MAPS,
49
            declarationMap: false,
50
            declaration: false,
51
            composite: false,
52
        }),
53
        nodeResolve({
54
            extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"]
55
        }),
56
    ],
57
}
58

59
function APACHE_LICENSE_HEADER() {
60
    return `
61
/**
62
* @license
63
* Copyright (c) ${new Date().getUTCFullYear()} Huawei Device Co., Ltd.
64
* Licensed under the Apache License, Version 2.0 (the "License");
65
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
67
*
68
* http://www.apache.org/licenses/LICENSE-2.0
69
*
70
* Unless required by applicable law or agreed to in writing, software
71
* distributed under the License is distributed on an "AS IS" BASIS,
72
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
73
* See the License for the specific language governing permissions and
74
* limitations under the License.
75
*/
76

77
`
78
}
79

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.