Open letmaik opened 3 years ago
I was able to solve the problem by calling the node-resolve plugin like so:
nodeResolve({
preferBuiltins: false
})
Without that I believe the resolution stopped too early before the polyfills plugin has a chance to resolve it.
I seem to be having the same issue but using preferBuiltins: false doesnt resolve my issue. I am simply trying to use bip39 with rollup in my project.
rollup.config.js
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import nodePolyfills from "rollup-plugin-polyfill-node";
import babel from "@rollup/plugin-babel";
const extensions = [".js", ".ts"];
export default [
{
input: "src/index.ts",
output: [
{
file: "dist/index.esm.js",
format: "esm",
},
],
plugins: [
nodePolyfills({
include: ["buffer", "stream", "events"],
}),
nodeResolve({
extensions,
browser: true,
preferBuiltins: false,
}),
commonjs({
include: "node_modules/**",
extensions,
}),
babel({
exclude: "node_modules/**",
babelHelpers: "bundled",
extensions,
}),
],
},
];
index.ts
import * as tt from "bip39";
export function testMe() {
const mnemonic = tt.entropyToMnemonic('00000000000000000000000000000000')
console.log("mnemonic: ", mnemonic)
}
I keep getting "uncaught ReferenceError: Buffer is not defined".
Running everything in webpack works perfectly fine...
The rollup output has some things polyfilled (like
buffer
,global
, andprocess
) butcrypto
andutil
remain. According to the README and a quick look at the code they should be supported, but somewhere there's an issue.Versions: