-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
70 lines (64 loc) · 1.64 KB
/
rollup.config.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
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
/*
I stole this from https://github.com/colyseus/colyseus.js/blob/master/rollup.config.js
I might change it later, but for now it works.
*/
import typescript from "@rollup/plugin-typescript";
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import pkg from "./package.json";
const external = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
const banner = `// paketto.js`;
export default [
// https://github.com/microsoft/TypeScript/issues/18442#issuecomment-749896695
{
input: ["src/index.ts"],
output: [
{
banner,
preserveModules: true,
dir: "build/esm",
format: "esm",
entryFileNames: "[name].mjs",
sourcemap: true,
},
],
external,
plugins: [typescript({ tsconfig: "./tsconfig/tsconfig.esm.json" })],
},
{
input: ["src/index.ts"],
output: [
{
banner,
preserveModules: true,
dir: "build/cjs",
format: "cjs",
entryFileNames: "[name].js",
sourcemap: true,
},
],
external,
plugins: [typescript({ tsconfig: "./tsconfig/tsconfig.cjs.json" })],
},
// browser/embedded dependencies
{
input: ["src/index.ts"],
output: [
{
banner,
preserveModules: false,
dir: "dist",
name: "paketto",
format: "umd",
entryFileNames: "paketto.js",
sourcemap: true,
amd: { id: pkg.name },
},
],
plugins: [
typescript({ tsconfig: "./tsconfig/tsconfig.cjs.json" }),
commonjs(),
nodeResolve({ browser: true, preferBuiltins: false }),
],
},
];