-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.vscode.config.mjs
47 lines (41 loc) · 1.49 KB
/
rollup.vscode.config.mjs
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
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import { swc } from "rollup-plugin-swc3";
import path from "path";
import fs from "fs";
const PACKAGE_ROOT_PATH = path.resolve(process.cwd(), "./packages");
const getVsCodeExtensionRollupConfig = (packageFolderName) => {
const packagePath = path.resolve(PACKAGE_ROOT_PATH, packageFolderName);
const packageJson = require(path.resolve(packagePath, "package.json"));
const { main } = packageJson;
const tsConfigJson = require(path.resolve(packagePath, "tsconfig.json"));
const indexPath = path.resolve(packagePath, "src/index.ts");
return [
{
input: indexPath,
output: {
dir: path.resolve(packagePath, main, "../"),
format: "cjs",
sourcemap: true,
preserveModules: true,
preserveModulesRoot: path.resolve(packagePath, "src"),
exports: "named",
},
external: [...Object.keys(packageJson.peerDependencies || {})],
plugins: [
nodeResolve(),
swc({
exclude: "**/node_modules/**",
tsconfig: path.resolve(packagePath, "tsconfig.json"),
sourceMaps: true,
}),
commonjs(),
],
},
];
};
const vscodePackages = fs.readdirSync(PACKAGE_ROOT_PATH).filter((name) => name.includes("vscode"));
const vscodeRollupConfigs = vscodePackages
.map((packageFolderName) => getVsCodeExtensionRollupConfig(packageFolderName))
.flat();
export default vscodeRollupConfigs;