-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.ts
70 lines (67 loc) · 1.86 KB
/
build.ts
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
import { build, emptyDir } from 'https://deno.land/x/dnt@0.39.0/mod.ts';
import pnpmPkg from './package.json' with { type: 'json' };
const OUTPUT_DIR = './dist';
if (import.meta.main) {
await emptyDir(OUTPUT_DIR);
await build({
entryPoints: [
'./src/mod.ts',
{
name: './adaptors',
path: './src/adaptors/mod.ts',
},
{
name: './namespace',
path: './src/namespace/mod.ts',
},
{
name: './nfd-mgmt',
path: './src/nfd-mgmt/mod.ts',
},
{
name: './security',
path: './src/security/mod.ts',
},
{
name: './storage',
path: './src/storage/mod.ts',
},
{
name: './sync-agent',
path: './src/sync-agent/mod.ts',
},
{
name: './utils',
path: './src/utils/mod.ts',
},
{
name: './workspace',
path: './src/workspace/mod.ts',
},
],
outDir: OUTPUT_DIR,
shims: {
// Do not shim Deno. It conflicts with the browser.
deno: false,
custom: [{
module: './types/deno.d.ts',
globalNames: ['Deno'],
}],
},
test: false, // Required due to some dependencies do not include test files.
esModule: true,
typeCheck: false,
packageManager: 'pnpm',
// package.json properties
package: pnpmPkg,
postBuild() {
// steps to run after building and before running the tests
Deno.copyFileSync('LICENSE', `${OUTPUT_DIR}/LICENSE`);
Deno.copyFileSync('README.md', `${OUTPUT_DIR}/README.md`);
Deno.copyFileSync('.npmrc', `${OUTPUT_DIR}/.npmrc`);
const dntShim = new TextEncoder().encode('const Deno = globalThis.Deno;\nexport { Deno };');
Deno.writeFileSync(`${OUTPUT_DIR}/esm/_dnt.shims.js`, dntShim);
Deno.writeFileSync(`${OUTPUT_DIR}/script/_dnt.shims.js`, dntShim);
},
});
}