modosc/global-jsdom

example usage with webpack config

Closed this issue · 3 comments

such like

		fallback: {
			fs: false,
			child_process: false,
            net: false,
            tls: false,
			stream: false,
			assert: false,
			url: false,
			buffer: false,
			querystring: false,
			zlib: false,
			os: false,
			crypto: require.resolve("crypto-browserify")
        },
		mainFields: ['module', 'main'],

can you give me an example of when/why you'd use this with webpack?

I'm trying to make
jupyter vscode extension to work on the browser, which nbnote previewer requires, jsdom. which does not compiles via webpack. and searching for jsdom browserfy let me here.

https://github.com/bridgedxyz/github.surf/tree/main/extensions/jupyter-web
trying to make this work. https://github.surf/deepmind/deepmind-research/blob/HEAD/memo/load_memo_data.ipynb

so jsdom-global worked in a browser by exporting an empty function from the browser field of package.json. iirc the ordering of how webpack decides which of these to use was why i removed that support (see here and here. for now i don't want to add this functionality and i'd recommend using jsdom-global instead. if enough people wanted this to work i could add such a shim but pretending to provide a dom via jsdom when it's not necessary in a browser is a pretty small edge case imho.