idlize
/
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*/
15import nodeResolve from "@rollup/plugin-node-resolve";16import terser from "@rollup/plugin-terser";17import typescript from "@rollup/plugin-typescript";18import * as path from "path";19
20const ENABLE_SOURCE_MAPS = false; // Enable for debugging21
22/** @type {import("rollup").RollupOptions} */
23export default {24input: "./src/main.ts",25output: {26file: "./lib/index.js",27format: "commonjs",28sourcemap: ENABLE_SOURCE_MAPS,29sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {30// For some reason Rollup adds extra ../ to relativeSourcePath, remove it31let absolute = path.join(sourcemapPath, relativeSourcePath);32let relative = path.relative(path.dirname(sourcemapPath), absolute);33return relative34},35plugins: [36// terser()37],38banner: [39"#!/usr/bin/env node",40APACHE_LICENSE_HEADER()41].join("\n"),42},43external: ["commander", "typescript", "webidl2"],44plugins: [45typescript({46outputToFilesystem: false,47module: "ESNext",48sourceMap: ENABLE_SOURCE_MAPS,49declarationMap: false,50declaration: false,51composite: false,52}),53nodeResolve({54extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"]55}),56],57}
58
59function APACHE_LICENSE_HEADER() {60return `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