Can't enable plugin depending on readable-stream

New to Obsidian and only moderately experienced with Typescript, I’m trying to build a custom plugin using N3. I can build the plugin fine but it crashes on import in Obsidian’s desktop app. The problem seems to come from using the readable-stream dependency, and I managed to reproduce it without N3 and just this dependency alone simply doing const read = new Readable();. It can’t find “module ‘process/’” which is quite cryptic to me. Does anyone have an idea what could cause this issue?

This is a related upstream issue. Still unsure how to fix it for Obsidian.

And more information on the topic.

Dont understant why they use this "process/" too
guess they want to refer to “process” library in package.json

A esbuild plugin can fix this:

const replaceProcessSlash = {
	name: 'replaceProcessSlash',
	setup(build) {
		const processSlash = path.join(process.cwd(), "node_modules", "process", "index.js");
		build.onResolve({ filter: /^process\/$/ }, args => ({
			path: processSlash,
		}));
	}
}

await esbuild.build({
    ...
    plugins: [
        replaceProcessSlash
    ],
   ...
}

I also have tried “alias” and “define” options of esbuild but dont work, so a plugin may be the best choice.

1 Like

Just wanted to confirm that this works! Many thanks.