I figured it out. In case any one is interested, here is my rollup.config.js:
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
import { terser } from "rollup-plugin-terser";
import pkg from "./package.json";
babel({
babelrc: false,
exclude: "node_modules/**",
runtimeHelpers: true,
presets: [
[
"@babel/preset-env",
{
modules: false,
useBuiltIns: "usage"
}
]
],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
});
export default [
// CommonJS (for Node)
{
input: "src/index.js",
output: [{ file: pkg.main, format: "cjs", exports: "default" }],
plugins: [
babelPlugin,
resolve(),
commonjs(),
//terser(),
]
},
// ES module (for bundlers)
{
input: "src/index.js",
output: [{ file: pkg.module, format: "es", exports: "default" }],
plugins: [
babelPlugin,
//terser()
]
}
];
My goal was to create a esm, cjs, and umd (not shown on the config) version of the library. The source uses features like async/await and class properties. After minimal initial testing, things look good. I think the issue originally was not that async/await wasn't handled properly, but that my version of Node wasn't supporting new Url(). After upgrading to v10, it worked fine. The tricky part here is that the source of the library needs to be isomorphic. I used isomorphic-unfetch and the newest version of Node to solve the issues I was having.