Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-source-map-support

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-source-map-support

A Babel plugin which automatically makes stack traces source-map aware

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
118K
increased by1.72%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status NPM Version

NAME

babel-plugin-source-map-support - a Babel plugin which automatically makes stack traces source-map aware

INSTALL

$ npm install source-map-support --save
$ npm install babel-plugin-source-map-support --save-dev

SYNOPSIS

$ cat test.js

import foo from 'foo';
import bar from 'bar';

foo(bar);

$ babel --plugins source-map-support test.js

import 'source-map-support/register';
import foo from 'foo';
import bar from 'bar';

foo(bar);

DESCRIPTION

This is a Babel plugin which prepends the following statement to source files:

import 'source-map-support/register';

In conjunction with the source-map-support module, which must be installed separately, this statement hooks into the v8 stack-trace API to translate call sites in the transpiled code back to their corresponding locations in the original code.

Note: this only works in environments which support the v8 stack-trace API (e.g. Node.js and Chrome), though it's harmless in other environments.

The source-map-support module only needs to be registered in the top-level file(s) of an application, but it no-ops if it has already been loaded, so there's no harm in registering it in every file.

You probably don't want to use this plugin when compiling code for the web because you probably don't want to bundle source-maps and the source-map-support module in minified code. An easy way to limit the plugin's scope to development/test builds is to use Babel's env option, e.g.:

{
    env: {
        development: {
            sourceMaps: 'inline',
            plugins: ['source-map-support', ...]
        }
    },

    presets: [ ... ]
}

Note that source-maps don't need to be inlined in each file. They can be externalised by using the { sourceMaps: true } option. This adds a link to the bottom of each file which points to its generated source-map, e.g.:

{
    env: {
        development: {
            sourceMaps: true,
            plugins: ['source-map-support', ...]
        }
    },
}
// index.js footer:
//# sourceMappingURL=index.js.map

DEVELOPMENT

NPM Scripts

The following NPM scripts are available:

  • build - compile the plugin and save it to the dist directory
  • build:doc - generate the README's TOC (table of contents)
  • clean - remove the dist directory and other build artifacts
  • rebuild - clean the build artifacts and recompile the code
  • test - rebuild the plugin and run the test suite
  • test:debug - run the test script in debug mode, which dumps each transformed test case
  • test:prod - run the test suite in production mode
  • test:run - run the test suite

COMPATIBILITY

SEE ALSO

VERSION

2.2.0

AUTHOR

chocolateboy

Copyright © 2015-2022 by chocolateboy.

This module is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.

Keywords

FAQs

Package last updated on 22 Jun 2022

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