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;
Stable: Formidable is not planning to develop any new features for this project. We are still responding to bug reports and security concerns. We are still welcoming PRs for this project, but PRs that include new features should be small and easy to integrate and should not include breaking changes.
FAQs
Babel plugin that replaces member expressions and typeof statements with strings
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.