forked from ethers-io/ethers.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
50 lines (45 loc) · 1.39 KB
/
rollup.config.mjs
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
import { nodeResolve } from '@rollup/plugin-node-resolve';
function getConfig(opts) {
if (opts == null) { opts = { }; }
const file = `./dist/ethers${ (opts.suffix || "") }.js`;
const exportConditions = [ "import", "default" ];
const mainFields = [ "module", "main" ];
if (opts.browser) { mainFields.unshift("browser"); }
return {
input: "./lib.esm/index.js",
output: {
file,
banner: "const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !== 'undefined' ? window: typeof global !== 'undefined' ? global: typeof self !== 'undefined' ? self: {});",
name: (opts.name || undefined),
format: (opts.format || "esm"),
sourcemap: true
},
context: "__$G",
treeshake: true,
plugins: [ nodeResolve({
exportConditions,
mainFields,
modulesOnly: true,
preferBuiltins: false
}) ],
};
}
export default [
getConfig({ browser: true }),
getConfig({ browser: true, suffix: ".umd", format: "umd", name: "ethers" }),
{
input: "./lib.esm/wordlists/wordlists-extra.js",
output: {
file: "./dist/wordlists-extra.js",
format: "esm",
sourcemap: true
},
treeshake: true,
plugins: [ nodeResolve({
exportConditions: [ "default", "module", "import" ],
mainFields: [ "browser", "module", "main" ],
modulesOnly: true,
preferBuiltins: false
}) ],
}
];