Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
babel-plugin-transform-define
Advanced tools
Babel plugin that replaces member expressions and typeof statements with strings
$ npm install --save-dev babel-plugin-transform-define
.babelrc
{
"plugins": [
["transform-define", {
"process.env.NODE_ENV": "production",
"typeof window": "object"
}]
]
}
.babelrc.js
// E.g., any dynamic logic with JS, environment variables, etc.
const overrides = require("./another-path.js");
module.exports = {
plugins: [
["transform-define", {
"process.env.NODE_ENV": "production",
"typeof window": "object",
...overrides
}]
]
};
babel-plugin-transform-define
can transform certain types of code as a babel transformation.
Identifiers
.babelrc
{
"plugins": [
["transform-define", {
"VERSION": "1.0.0",
}]
]
}
Source Code
VERSION;
window.__MY_COMPANY__ = {
version: VERSION
};
Output Code
"1.0.0";
window.__MY_COMPANY__ = {
version: "1.0.0"
};
Member Expressions
.babelrc
{
"plugins": [
["transform-define", {
"process.env.NODE_ENV": "production"
}]
]
}
Source Code
if (process.env.NODE_ENV === "production") {
console.log(true);
}
Output Code
if (true) {
console.log(true);
}
Unary Expressions
.babelrc
{
"plugins": [
["transform-define", {
"typeof window": "object"
}]
]
}
Source Code
typeof window;
typeof window === "object";
Output Code
'object';
true;
FAQs
Babel plugin that replaces member expressions and typeof statements with strings
The npm package babel-plugin-transform-define receives a total of 96,473 weekly downloads. As such, babel-plugin-transform-define popularity was classified as popular.
We found that babel-plugin-transform-define demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 open source maintainers 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.