-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
85 lines (79 loc) · 1.84 KB
/
Copy pathrollup.config.mjs
File metadata and controls
85 lines (79 loc) · 1.84 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { readdirSync as readdir, statSync as stat } from 'fs';
import { join } from 'path';
function walk(root, result=[]) {
const rootURL = new URL(root, import.meta.url);
const paths = readdir(rootURL);
for (const path of paths) {
const stats = stat(new URL(path, rootURL));
if (stats.isDirectory()) {
walk(`${root}${path}/`, result);
}
else {
result.push({
input: join(root, path),
dir: join('dist/', root)
});
}
}
return result;
}
function walkLib(config) {
// Build all lib files in a single pass
const files = walk('./lib/');
config.push({
input: files.map(f => f.input),
output: {
entryFileNames: '[name].js',
dir: 'dist/lib',
format: 'cjs',
preserveModules: true,
preserveModulesRoot: 'lib',
exports: 'auto'
},
external: [
'node:dgram',
'node:events',
'node:buffer',
'jspack',
'#decode'
]
});
}
function walkTest(config) {
// Build all test files in a single pass, excluding fixtures
const tests = walk('./test/').filter(t => {
// Normalize path separators to work on both Unix and Windows
const normalizedPath = t.input.replace(/\\/g, '/');
return !normalizedPath.includes('/fixtures/');
});
config.push({
input: tests.map(t => t.input),
plugins: [],
output: {
entryFileNames: '[name].js',
dir: 'dist/test',
format: 'cjs',
exports: 'auto',
preserveModules: true,
preserveModulesRoot: 'test'
},
external: [
'node:dgram',
'node:net',
'node:buffer',
'node:events',
'node:child_process',
'node:fs',
'node:path',
'node:url',
'node:timers/promises',
'node-osc',
'tap',
'#decode'
]
});
}
const config = [];
walkLib(config);
walkTest(config);
export default config;