Skip to content

Create a bundle for browsers that includes the Wasm code? #408

@rauschma

Description

@rauschma

Suggestion: source-map would be easier to use if it completely hid the fact that it internally uses Wasm.

  • For browsers, you can do that by distributing a bundle, as shown below.
  • For Node.js, this should be even simpler.

webpack.config.js:

const path = require('path');

module.exports = {
  // ···
  module: {
    rules: [
      {
        test: /\.wasm$/,
        type: 'javascript/auto',
        loader: 'arraybuffer-loader', // installed via npm
      },    
    ],
  },
};

Setup code (when used outside the library):

import arrayBuffer from 'source-map/lib/mappings.wasm';
SourceMapConsumer.initialize({
  'lib/mappings.wasm': arrayBuffer,
});

AFAICT, .initialize() is not in the .d.ts file. Maybe add it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featNew feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions