Gathering detailed insights and metrics for @oliver-schoendorn/babel-plugin-transform-define
Gathering detailed insights and metrics for @oliver-schoendorn/babel-plugin-transform-define
Gathering detailed insights and metrics for @oliver-schoendorn/babel-plugin-transform-define
Gathering detailed insights and metrics for @oliver-schoendorn/babel-plugin-transform-define
npm install @oliver-schoendorn/babel-plugin-transform-define
Typescript
Module System
Node Version
NPM Version
TypeScript (99.84%)
JavaScript (0.16%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
16 Commits
1 Watchers
13 Branches
1 Contributors
Updated on Apr 08, 2020
Latest Version
2.0.0
Package Id
@oliver-schoendorn/babel-plugin-transform-define@2.0.0
Unpacked Size
13.09 kB
Size
4.41 kB
File Count
7
NPM Version
6.5.0-next.0
Node Version
11.6.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This Babel plugin will take a set of config values (or load them from a file path) and replace all occurrences in the parsed scripts. This plugin is compatible with Babel 7. Other Babel versions have not been tested.
npm i -D @oliver-schoendorn/babel-plugin-transform-define
1{ 2 "plugins": [ 3 [ "@oliver-schoendorn/babel-plugin-transform-define", { 4 "values": { "your": "values" } 5 } ] 6 ] 7}
1{ 2 "plugins": [ 3 [ "@oliver-schoendorn/babel-plugin-transform-define", { 4 "file": "./src/config" 5 } ] 6 ] 7}
All of the following example will use these plugin config values:
1{ 2 "values": { 3 "process.env.NODE_ENV": "production", 4 "isProduction": true, 5 "CONFIG": { 6 "API_HOST": "https://your.domain/" 7 }, 8 "VAR": null, 9 "TEST_STUFF": "/^foo$/igm", 10 "didRTFM": true 11 } 12}
Input
1const initState = { initialized: true } 2const appState = { global: { ...CONFIG, isProduction }, ...initialized } 3const thisWorks = asWell = isProduction 4const VAR = { CONFIG }
Output
1const initState = { initialized: true } 2const appState = { global: { ...{ "API_HOST": "https://your.domain" } }, ...initialized } 3const thisWorks = asWell = true 4const VAR = { CONFIG: { "API_HOST": "https://your.domain" } }
Input
1const myObject = {}, isProduction = false 2myObject.foo = VAR 3myObject.isProduction = isProduction 4 5new RegExp(TEST_STUFF) 6 7Object.keys(CONFIG).map(key => console.log(key))
Output
1const myObject = {}, isProduction = false 2myObject.foo = null 3myObject.isProduction = isProduction 4 5new RegExp("/^foo$/igm") 6 7Object.keys({ "API_HOST": "https://your.domain" }).map(key => console.log(key))
Input
1export { CONFIG } 2export default isProduction
Output
1const CONFIG = { "API_HOST": "https://your.domain" } 2export { CONFIG } 3 4const isProduction = true 5export default isProduction
Input
1if (isProduction) { doThings() } 2else { doSomthingElse() } 3 4if (! isProduction) { whatEver() } 5else { sorcery() } 6 7const youAre = didRTFM ? 'awesome' : 'lazy' 8const complicated = didRTFM && ! isProduction 9 10const canNotEvaluate = didRTFM && require('./aScript')
Output
1{ doThings() } 2{ sorcery() } 3 4const youAre = 'awesome' 5const complicated = false 6const canNotEvaluate = true && require('./aScript')
Option key | Description | Type | Default value |
---|---|---|---|
values | Object with keys and values, that should be replaced. Please note that only the top level keys will be used for replacement. If you want to define process.env.NODE_ENV for instance, use { "process.env.NODE_ENV": "production" } | object | {} |
file | Instead of passing an object, you can also reference a file. The given path has to be relative to your babel config and should use module.exports = { API_HOST: "https://..." } | string | undefined |
memberExpressions | You can disable the processing of member expressions (node.env.NODE_ENV ). | boolean | true |
exportExpressions | Toggles the processing of export expressions (export { MY_CONFIG } or export default MY_CONFIG ). Note: If you enable this option, you will have to set the babel parser option allowUndeclaredExports to true . | boolean | true |
evaluateConditionals | Toggles the evaluation and simplification of If Statements, Unary Statements and so on. | boolean | true |
verbose | If set to true, some information about the replaced nodes and their types will be printed to the console. | boolean | false |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
44 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More