Skip to content

These docs are for Miniflare 2 which is no longer supported apart from critical security updates.
Please see the migration guide to upgrade to Miniflare 3, and the updated API docs.

Miniflare
Visit Miniflare on GitHub
Set theme to dark (โ‡ง+D)

๐Ÿ—บ Source Maps

Source maps allow error stack traces to include the actual location in the source an error occurred, as opposed to somewhere in the bundled output. See this page for more details.

Enabling Source Map Support

When using the CLI, source map support is always enabled automatically. ๐ŸŽ‰

When using the API, source map support can be enabled with the sourceMap option. Note this will install support globally in your entire application:

const mf = new Miniflare({
sourceMap: true,
});

Outputting Source Maps

How you generate source maps depends on your build tool. Here's how to do it for some popular tools:

esbuild

Use the --sourcemap flag or the sourcemap option.

Webpack

See the devtool configuration option. Note that eval is unsupported in workers. For the error page to correctly resolve your source files, you must set devtoolModuleFilenameTemplate to [absolute-resource-path]:

module.exports = {
entry: "./src/index.js",
devtool: "cheap-module-source-map",
output: {
devtoolModuleFilenameTemplate: "[absolute-resource-path]",
},
};

Rollup

Use the --sourcemap flag or the output.sourcemap option.

TypeScript

Use the --sourceMap flag or the sourceMap option.