Socket
Socket
Sign inDemoInstall

smart-source-map-loader

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-source-map-loader

A Smart Source Map Loader for Webpack


Version published
Weekly downloads
432
increased by9.09%
Maintainers
0
Weekly downloads
 
Created
Source

Smart Source Map Loader

A Smart Source Map Loader for Webpack

npm node

size downloads

Build Status

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.

If you do include them though they will have the correct path in the source map.

Bugs

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

License

Copyright (c) 2018-2024 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.

Keywords

FAQs

Package last updated on 04 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc