-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
dnt.ts
134 lines (125 loc) · 3.36 KB
/
dnt.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { build, emptyDir } from "@deno/dnt";
import { copy } from "@std/fs";
import { join } from "@std/path";
await emptyDir("./npm");
await emptyDir("./npm/esm/codegen");
const denoJson = join(import.meta.dirname!, "deno.json");
const metadata = JSON.parse(await Deno.readTextFile(denoJson));
const excludedExports = ["./x/denokv", "./x/fresh"];
const entryPoints = Object.entries(metadata.exports as Record<string, string>)
.map(([name, path]) => ({ name, path }))
.filter(({ name }) => !excludedExports.includes(name));
const testExports = [];
for (const { name } of entryPoints) {
const match = name.match(/^\.\/([^/]+)/);
if (match && match[1] != "x") testExports.push(match[1]);
}
const importMap = ".dnt-import-map.json";
await Deno.writeTextFile(
importMap,
JSON.stringify({
imports: {
...metadata.imports,
"@logtape/logtape": metadata.imports["@logtape/logtape"]
.replace(/^jsr:/, "npm:"),
},
}),
);
await build({
package: {
// package.json properties
name: "@fedify/fedify",
version: Deno.args[0] ?? metadata.version,
description: "An ActivityPub server framework",
keywords: ["ActivityPub", "fediverse"],
license: "AGPL-3.0",
author: {
name: "Hong Minhee",
email: "hong@minhee.org",
url: "https://hongminhee.org/",
},
homepage: "https://fedify.dev/",
repository: {
type: "git",
url: "git+https://github.com/dahlia/fedify.git",
},
bugs: {
url: "https://github.com/dahlia/fedify/issues",
},
},
outDir: "./npm",
entryPoints,
importMap,
scriptModule: false,
shims: {
deno: true,
crypto: true,
custom: [
{
package: {
name: "urlpattern-polyfill",
version: "~10.0.0",
},
globalNames: [
{
name: "URLPattern",
exportName: "URLPattern",
},
],
},
{
package: {
name: "@js-temporal/polyfill",
version: "^0.4.4",
},
globalNames: [
{
name: "Temporal",
exportName: "Temporal",
},
],
},
],
customDev: [
{
module: "./shim/event.ts",
globalNames: ["addEventListener"],
},
],
},
typeCheck: "both",
declaration: "separate",
declarationMap: true,
compilerOptions: {
target: "ES2022",
},
// deno-lint-ignore no-explicit-any
filterDiagnostic(diagnostic: any) {
if (
diagnostic.file?.fileName.endsWith("2KNRVU.ts")
) {
return false; // ignore all diagnostics in this file
}
// etc... more checks here
return true;
},
testPattern: `{${testExports.join(",")}}/**/*.test.ts`,
async postBuild() {
await copy(
"testing/fixtures",
"npm/esm/testing/fixtures",
{ overwrite: true },
);
for await (const entry of Deno.readDir("vocab")) {
if (!entry.isFile || !entry.name.endsWith(".yaml")) continue;
await Deno.copyFile(`vocab/${entry.name}`, `npm/esm/vocab/${entry.name}`);
}
await Deno.copyFile("codegen/schema.yaml", "npm/esm/codegen/schema.yaml");
await Deno.copyFile("CHANGES.md", "npm/CHANGES.md");
await Deno.copyFile("LICENSE", "npm/LICENSE");
await Deno.copyFile("logo.svg", "npm/logo.svg");
await Deno.copyFile("README.md", "npm/README.md");
},
});
await Deno.remove(importMap);
// cSpell: ignore Minhee 2KNRVU