Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
babel-plugin-source-map-support
Advanced tools
A Babel plugin which automatically makes stack traces source-map aware
babel-plugin-source-map-support - a Babel plugin which automatically makes stack traces source-map aware
$ npm install source-map-support --save
$ npm install babel-plugin-source-map-support --save-dev
$ 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);
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
The following NPM scripts are available:
dist
directorydist
directory and other build artifactstest
script in debug mode, which dumps each transformed test case2.2.0
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.
2.2.0 - 2022-06-22
FAQs
A Babel plugin which automatically makes stack traces source-map aware
The npm package babel-plugin-source-map-support receives a total of 93,477 weekly downloads. As such, babel-plugin-source-map-support popularity was classified as popular.
We found that babel-plugin-source-map-support demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.