Sanshain / preact-boilerplate

preact boilerplate
0 stars 0 forks source link

Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer #4

Closed Sanshain closed 2 weeks ago

Sanshain commented 2 weeks ago

The trouble:

Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer

When: on compilation via nollup

Reason:

source-map package uses fetch on nodejs. The problem is that it supposes the environment is browser (uses read-wasm-browser script, bu it's wrong). In the read-wasm.js there is comment:

// Note: This file is replaced with "read-wasm-browser.js" when this module is // bundled with a packager that takes package.json#browser fields into account.

But somethink might went wrong even the field is blank or passed. may be it depends on packager or somethink else. So...

Solution:

I suppose that source-map somewhere within decides either browser or nor depending on existing fetch api in the environment. That way worked fine until node did not include fetch in its api since v16. The workaround would be to use flag node --no-experimental-fetch. For example:

node --no-experimental-fetch ./node_modules/nollup/lib/cli.js --environment NODE_ENV:development
I hope, It'll be help you in your way. Please put like if it is.