ethers.js/rollup-tests.config.js

63 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2019-11-23 21:15:06 +09:00
"use strict";
2020-11-14 17:42:36 -05:00
import commonjs from '@rollup/plugin-commonjs';
//import inject from '@rollup/plugin-inject';
import resolveNode from "@rollup/plugin-node-resolve";
2019-11-23 21:15:06 +09:00
2020-11-14 17:42:36 -05:00
import nodePolyfills from "rollup-plugin-node-polyfills";
2019-11-23 21:15:06 +09:00
2020-11-14 17:42:36 -05:00
import json from "@rollup/plugin-json";
2019-11-23 21:15:06 +09:00
2020-11-16 21:20:35 -05:00
function getConfig(format) {
// ESM config
let input = "./packages/tests/lib.esm/index.js";
let mainFields = undefined;
let globals = undefined;
if (format === "umd") {
input = "./packages/tests/lib/index.js";
mainFields = [ "browser", "main" ];
globals = { ethers: "ethers" };
}
2019-11-23 21:15:06 +09:00
const plugins = [
json(),
2020-11-14 17:42:36 -05:00
/*
inject({
modules: {
Buffer: [ "buffer", "Buffer" ],
},
include: "* * /test-utils.js"
}),
*/
commonjs({
}),
nodePolyfills({
assert: true
}),
2020-11-17 20:36:19 -05:00
resolveNode({ mainFields }),
2019-11-23 21:15:06 +09:00
];
return {
input: input,
output: {
file: ("./packages/tests/dist/tests." + format + ".js"),
2020-11-16 21:20:35 -05:00
name: "testing",
format,
globals
2019-11-23 21:15:06 +09:00
},
2020-09-05 01:14:25 -04:00
context: "window",
2019-11-23 21:15:06 +09:00
treeshake: false,
2020-11-16 21:20:35 -05:00
external: [ "ethers" ],
2019-11-23 21:15:06 +09:00
plugins: plugins
};
}
2020-11-14 17:42:36 -05:00
const configs = [
2020-11-16 21:20:35 -05:00
getConfig("umd"),
getConfig("esm"),
2020-11-14 17:42:36 -05:00
];
export default configs;