Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read-wasm abstraction #372

Open
FranckFreiburger opened this issue Nov 23, 2018 · 2 comments
Open

read-wasm abstraction #372

FranckFreiburger opened this issue Nov 23, 2018 · 2 comments
Labels

Comments

@FranckFreiburger
Copy link

FranckFreiburger commented Nov 23, 2018

const readWasm = require("../lib/read-wasm");

Is it possible to make read-wasm abstract in order to allow users to implement their own version ?
I encounter some difficulties to bundle source-map in server-side code generated through webpack.

const wasmPath = path.join(__dirname, "mappings.wasm");
fs.readFile(wasmPath, null, (error, data) => {

has no sense in this context.

Thanks.

--edit--
Maybe you can allow #339 for node.js ?

@hbenl
Copy link

hbenl commented Aug 27, 2019

FYI: I managed to create a webpack bundle that includes the javascript part of source-map and loads mappings.wasm from a separate file. Here's the relevant portion from my webpack.config.js:

plugins: [
	new CopyPlugin([{
		from: path.resolve('node_modules/source-map/lib/mappings.wasm')
	}])
],
target: 'node',
node: {
	__dirname: false
}

The __dirname: false part tells webpack that __dirname should have its regular node.js behavior (instead of evaluating to '/', which is the webpack default) - that's all that is needed for the bundle to successfully load mappings.wasm.

Still, it would be nicer if mappings.wasm could be made part of the bundle (using wasm-loader). Using webpack for node.js projects is becoming increasingly popular, so this shouldn't require a hack like the one shown above.

@NaridaL
Copy link

NaridaL commented May 4, 2022

I solved the webpack bundling problem by using https://www.npmjs.com/package/source-map-js which is a js-only version of this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants