
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
babel-plugin-transform-commonjs
Advanced tools
A Babel plugin transform to convert CommonJS to ES modules
A Babel 7 compatible transform to convert Node-style CommonJS modules into the ES module specification. This was created specifically for an experimental module bundler, but has many uses outside of that initial use case. All major browsers have shipped support for ESM and Node currently has experimental support behind a flag. Babel offers a bridge to bring the old to the new, which is humorous given the origins of Babel which brought the new to the old. This module can reconcile differences as best as possible without resorting to hacks.
The goal of this transform is to produce spec-compliant code. Any behavior that diverges will throw by default. There are escape hatches however, if you know what they do.
This module will ignore ESM by default, so long as they do not reference:
require
, module.exports
, or exports
.
What to expect:
module.exports
intact, no tricks to separate this objectWhat not to expect:
require.extensions
support, as this is a runtime concernNotable features not supported:
exports["I'mateapot"]
) will only be available on the default exportNotable features supported:
this
npm install --save-dev babel-plugin-transform-commonjs
Update your babel configuration:
{
"plugins": ["transform-commonjs"]
}
Now code like this:
var { readFileSync } = require('path');
exports.readFileSync = readFileSync;
Will turn into this:
import { readFileSync as _readFileSync } from "path";
var module = {
exports: {}
};
exports.readFileSync = _readFileSync;
export const readFileSync = _readFileSync;
export default module.exports;
synchronousImport
- Convert non-static require to a compatible dynamic
import. If the bundler can inline and link synchronously, this should be
okay, although this will produce invalid code for any other case. Use with
caution!
{
"plugins": [
["transform-commonjs", { "synchronousImport": true }]
]
}
exportsOnly
- Keep require
calls and process exports only.
{
"plugins": [
["transform-commonjs", { "onlyExports": true }]
]
}
FAQs
A Babel plugin transform to convert CommonJS to ES modules
The npm package babel-plugin-transform-commonjs receives a total of 3,946 weekly downloads. As such, babel-plugin-transform-commonjs popularity was classified as popular.
We found that babel-plugin-transform-commonjs 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
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.