-
Notifications
You must be signed in to change notification settings - Fork 98
/
lib.js
26 lines (24 loc) · 739 Bytes
/
lib.js
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
const { build } = require("esbuild");
const { resolve } = require("path");
const { existsSync } = require("fs");
const dependencies = require("./package.json").dependencies
const points = Object.keys(dependencies).reduce((point, dependency) => {
const main = require(`./node_modules/${dependency}/package.json`).main ?? "index.js";
const mainAbsPath = resolve(`./node_modules/${dependency}`, main);
if (existsSync(mainAbsPath)) {
point[dependency] = mainAbsPath;
}
return point;
}, {})
console.log(points)
build({
entryPoints: points,
bundle: true,
outdir: "out/lib",
format: 'cjs',
platform: 'node',
minify: true,
treeShaking: true,
metafile: true,
external: ['vscode']
})