-
Notifications
You must be signed in to change notification settings - Fork 32
/
build.ts
79 lines (73 loc) · 1.97 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
71
72
73
74
75
76
77
78
79
import { build, emptyDir } from "https://deno.land/x/dnt/mod.ts";
const packageManager = "npm";
const outDir = "./dist";
await emptyDir(outDir);
await build({
packageManager,
entryPoints: ["src/mod.ts"],
outDir,
shims: {
deno: "dev",
crypto: "dev",
custom: [
/**
* Workaround for testing the build in nodejs
*/
{
package: { name: "@types/node", version: "latest" },
typesPackage: { name: "@types/node", version: "latest" },
globalNames: [],
},
],
},
typeCheck: false,
test: typeof Deno.env.get("TEST") !== "undefined",
package: {
// package.json properties
name: "@upstash/ratelimit",
version: Deno.args[0],
description: "A serverless ratelimiter built on top of Upstash REST API.",
repository: {
type: "git",
url: "git+https://github.com/upstash/ratelimiter.git",
},
keywords: ["rate", "limit", "redis", "serverless", "edge", "upstash"],
author: "Andreas Thomas <andreas.thomas@chronark.com>",
license: "MIT",
bugs: {
url: "https://github.com/upstash/ratelimiter/issues",
},
homepage: "https://github.com/upstash/ratelimiter#readme",
devDependencies: {
"size-limit": "latest",
"@size-limit/preset-small-lib": "latest",
"@upstash/redis": "1.3.3-alpha.1",
},
peerDependencies: {
"@upstash/redis": "^1.3.4",
},
"size-limit": [
{
path: "esm/mod.js",
limit: "15 KB",
},
{
path: "script/mod.js",
limit: "15 KB",
},
],
},
});
// post build steps
Deno.copyFileSync("LICENSE", `${outDir}/LICENSE`);
Deno.copyFileSync("README.md", `${outDir}/README.md`);
/**
* Workaround because currently deno can not typecheck the built modules without `@types/node` being installed as regular dependency
*
* This removes it after everything is tested.
*/
await Deno.run({
cwd: outDir,
cmd: [packageManager, "uninstall", "@types/node"],
stdout: "piped",
}).output();