smart-source-map-loader
A Smart Source Map Loader for Webpack
Last updated 4 months ago by alexanderomara .
MPL-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install smart-source-map-loader 
SYNC missed versions from official npm registry.

Smart Source Map Loader

A Smart Source Map Loader for Webpack

npm node

dependencies size downloads

travis-ci

Overview

This is a module which will read any existing source maps on a file and pass them to Webpack. In this way compiled code can be bundled with source maps to the original source files.

It is similar in concept to the source-map-loader module, but with several major usability improvements. These improvements mainly center around the issue where that module does not correctly resolve the original source paths in most cases, leading to conflicting or wrong paths in the resulting source maps. In order to solve these and several other minor issues, a smarter loader had to be written, and so this loader was created.

Features

  • Correctly resolves the path of the original source files relative to the source maps to avoid conflicts and wrong paths in the resulting bundle.
  • Only accepts well-formed source map comments (with one exception for path encoding) at the end of the file (other comments are almost always extraneous).
  • Handles both spec-compliant encoded and unencoded comment paths (for compatibility with the rest of the ecosystem, typically a non-issue).
  • Correctly handles external and data URI source maps.
  • Correctly handles the indexed format and reading source contents from disk when needed.
  • Avoids adding absolute paths where possible.
  • Strong error handling to produce helpful warning messages when a source map is invalid.
  • Well-tested against the real Webpack module.

Usage

Requires Webpack 4+.

Just add the dependency with npm:

npm i -D smart-source-map-loader

Or yarn:

yarn add -D smart-source-map-loader

And configure it to parse your source files (.js and .mjs in this example):

module.exports = {
  module: {
    rules: [
      {
        test: /\.m?js$/i,
        use: ['smart-source-map-loader'],
        enforce: 'pre'
      }
    ]
  }
};

For performance reasons you may wish to exclude node_modules in your setup.

Bugs

If you find a bug or have compatibility issues, please open a ticket under issues section for this repository.

License

Copyright (c) 2018-2020 Alexander O'Mara

Licensed under the Mozilla Public License, v. 2.0.

If this license does not work for you, feel free to contact me.

Current Tags

  • 1.1.1                                ...           latest (4 months ago)

3 Versions

  • 1.1.1                                ...           4 months ago
  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 9
This Month 9
Last Day 2
Last Week 9
Last Month 21
Dependencies (2)
Dev Dependencies (26)

Copyright 2014 - 2016 © taobao.org |