pax_global_header 0000666 0000000 0000000 00000000064 13106537162 0014516 g ustar 00root root 0000000 0000000 52 comment=43e7a1efa32e96aec0c9f408d77e41ae882e527f
babel-plugin-transform-define-1.3.0/ 0000775 0000000 0000000 00000000000 13106537162 0017321 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/.babelrc 0000664 0000000 0000000 00000000034 13106537162 0020711 0 ustar 00root root 0000000 0000000 {
"presets": ["es2015"]
}
babel-plugin-transform-define-1.3.0/.eslintrc 0000664 0000000 0000000 00000000267 13106537162 0021152 0 ustar 00root root 0000000 0000000 ---
"extends":
- "formidable/configurations/es6"
rules:
no-magic-numbers: OFF
max-statements: OFF
no-console: OFF
max-len:
- error
- 120
globals:
console: false
babel-plugin-transform-define-1.3.0/.gitignore 0000664 0000000 0000000 00000000004 13106537162 0021303 0 ustar 00root root 0000000 0000000 lib
babel-plugin-transform-define-1.3.0/.travis.yml 0000664 0000000 0000000 00000000153 13106537162 0021431 0 ustar 00root root 0000000 0000000 language: node_js
node_js:
- "4"
- "5"
- "6"
script: npm run check
branches:
only:
- master
babel-plugin-transform-define-1.3.0/CHANGELOG.md 0000664 0000000 0000000 00000002013 13106537162 0021126 0 ustar 00root root 0000000 0000000 ## 1.3.0 (2017-05-15)
#### User Facing Changes
* Support falsy replacement values [https://github.com/FormidableLabs/babel-plugin-transform-define/pull/33]
#### Internal
* Update eslint config and packages
* Update lodash version
## 1.2.0 (2016-08-25)
#### User Facing Changes
* Add the ability define config as a deep object
* Add a Code of Conduct
#### Internal
* Remove release scripts
* Rename `./modules` to `./src`
* Add keywords and contributors to `package.json`
* Remove author from `package.json` in favor of contributors
* Expand test coverage
## 1.1.0 (2016-08-19)
#### User Facing Changes
* Add the ability to get config from a file
* Add support for Identifiers
* Major improvements to the README.md
#### Internal
* Add tests
* Add lint
* Add JSDoc
* Add CI
* Add explicit LICENSE file
* Move dependencies into devDependencies
* Major refactors to DRY the code
## 1.0.0 (2016-03-21)
#### User Facing Changes
* Update README.md to reference Webpack's Define Plugin
## 1.0.0 (2016-03-21)
Initial Release
babel-plugin-transform-define-1.3.0/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000005765 13106537162 0022135 0 ustar 00root root 0000000 0000000 Contributor Covenant Code of Conduct
Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
Our Standards
Examples of behavior that contributes to creating a positive environment include:
Using welcoming and inclusive language
Being respectful of differing viewpoints and experiences
Gracefully accepting constructive criticism
Focusing on what is best for the community
Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
The use of sexualized language or imagery and unwelcome sexual attention or advances
Trolling, insulting/derogatory comments, and personal or political attacks
Public or private harassment
Publishing others' private information, such as a physical or electronic address, without explicit permission
Other conduct which could reasonably be considered inappropriate in a professional setting
Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [INSERT EMAIL ADDRESS]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4.
babel-plugin-transform-define-1.3.0/LICENSE 0000664 0000000 0000000 00000002064 13106537162 0020330 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2016 Formidable
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
babel-plugin-transform-define-1.3.0/README.md 0000664 0000000 0000000 00000004362 13106537162 0020605 0 ustar 00root root 0000000 0000000
babel-plugin-transform-define
Compile time code replacement for babel similar to Webpack's DefinePlugin
***
## Quick Start
```shell
npm install babel-plugin-transform-define
```
**.babelrc**
```json
{
"plugins": [
["transform-define", {
"process.env.NODE_ENV": "production",
"typeof window": "object"
}]
]
}
```
**.babelrc**
```json
{
"plugins": [
["transform-define", "./path/to/config/file.js"]
]
}
```
_Note_: Paths are relative to `process.cwd()``
## Reference Documentation
`babel-plugin-transform-define` can transform certain types of code as a babel transformation.
#####`Identifiers`
*.babelrc*
```json
{
"plugins": [
["transform-define", {
"VERSION": "1.0.0",
}]
]
}
```
*Source Code*
```js
VERSION;
window.__MY_COMPANY__ = {
version: VERSION
};
```
*Output Code*
```js
"1.0.0";
window.__MY_COMPANY__ = {
version: "1.0.0"
};
```
***
#####`Member Expressions`
*.babelrc*
```json
{
"plugins": [
["transform-define", {
"process.env.NODE_ENV": "production"
}]
]
}
```
*Source Code*
```js
if (process.env.NODE_ENV === "production") {
console.log(true);
}
```
*Output Code*
```js
if (true) {
console.log(true);
}
```
***
#####`Unary Expressions`
*.babelrc*
```json
{
"plugins": [
["transform-define", {
"typeof window": "object"
}]
]
}
```
*Source Code*
```js
typeof window;
typeof window === "object";
```
*Output Code*
```js
'object';
true;
```
***
## License
[MIT License](http://opensource.org/licenses/MIT)
babel-plugin-transform-define-1.3.0/package.json 0000664 0000000 0000000 00000003546 13106537162 0021617 0 ustar 00root root 0000000 0000000 {
"name" : "babel-plugin-transform-define",
"description" : "Babel plugin that replaces member expressions and typeof statements with strings",
"version" : "1.3.0",
"contributors": [
"Eric Baer (https://github.com/baer)",
"Michael Jackson (https://github.com/mjackson)",
"Andy Edwards (https://github.com/jedwards1211)"
],
"homepage" : "https://github.com/FormidableLabs/babel-plugin-transform-define",
"bugs": {
"url": "https://github.com/FormidableLabs/babel-plugin-transform-define/issues"
},
"repository" : "git://github.com/FormidableLabs/babel-plugin-transform-define.git",
"private" : false,
"dependencies": {
"lodash" : "4.17.4",
"traverse" : "0.6.6"
},
"devDependencies": {
"assert-transform" : "^1.0.0",
"babel-core" : "^6.13.2",
"babel-cli" : "^6.6.5",
"babel-eslint" : "6.1.2",
"babel-preset-es2015" : "^6.6.0",
"eslint-config-formidable" : "3.0.0",
"eslint-plugin-filenames" : "1.1.0",
"eslint-plugin-import" : "1.13.0",
"eslint" : "3.19.0",
"mocha" : "^3.0.2",
"rimraf" : "^2.5.2"
},
"main" : "lib",
"scripts": {
"build": "babel ./src -d lib",
"check": "npm run clean && npm run build && npm run test && npm run lint",
"clean": "rimraf lib/",
"lint": "eslint src",
"prepublish": "npm run clean && npm run build",
"release": "node ./scripts/release.js",
"test": "mocha ./test/index.js"
},
"engines":{
"node": ">= 4.x.x"
},
"license" : "MIT",
"keywords": [
"babel-plugin",
"babel-transform",
"babel",
"define",
"DefinePlugin",
"webpack"
]
}
babel-plugin-transform-define-1.3.0/src/ 0000775 0000000 0000000 00000000000 13106537162 0020110 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/src/index.js 0000664 0000000 0000000 00000010570 13106537162 0021560 0 ustar 00root root 0000000 0000000 const fs = require("fs");
const path = require("path");
const traverse = require("traverse");
const { get, has, find } = require("lodash");
/**
* Return an Array of every possible non-cyclic path in the object as a dot separated string sorted
* by length.
*
* Example:
* getSortedObjectPaths({ process: { env: { NODE_ENV: "development" } } });
* // => [ "process.env.NODE_ENV", "process.env" "process" ]
*
* @param {Object} obj A plain JavaScript Object
* @return {Array} Sorted list of non-cyclic paths into obj
*/
export const getSortedObjectPaths = (obj) => {
if (!obj) { return []; }
return traverse(obj)
.paths()
.filter((arr) => arr.length)
.map((arr) => arr.join("."))
.sort((elem) => elem.length);
};
/**
* `babel-plugin-transfor-define` take options of two types: static config and a path to a file that
* can define config in any way a user sees fit. getReplacements takes the options and will either
* return the static config or get the dynamic config from disk
* @param {Object|String} configOptions configuration to parse
* @return {Object} replacement object
*/
const getReplacements = (configOptions) => {
if (typeof configOptions === "object") { return configOptions; }
try {
const fullPath = path.join(process.cwd(), configOptions);
fs.accessSync(fullPath, fs.F_OK);
return require(fullPath);
} catch (err) {
console.error(`The nodePath: ${configOptions} is not valid.`); // eslint-disable-line
throw new Error(err);
}
};
/**
* Replace a node with a given value. If the replacement results in a BinaryExpression, it will be
* evaluated. For example, if the result of the replacement is `var x = "production" === "production"`
* The evaluation will make a second replacement resulting in `var x = true`
* @param {function} replaceFn The function used to replace the node
* @param {babelNode} nodePath The node to evaluate
* @param {*} replacement The value the node will be replaced with
* @return {undefined}
*/
const replaceAndEvaluateNode = (replaceFn, nodePath, replacement) => {
nodePath.replaceWith(replaceFn(replacement));
if (nodePath.parentPath.isBinaryExpression()) {
const result = nodePath.parentPath.evaluate();
if (result.confident) {
nodePath.parentPath.replaceWith(replaceFn(result.value));
}
}
};
/**
* Finds the first replacement in sorted object paths for replacements that causes comparator
* to return true. If one is found, replaces the node with it.
* @param {Object} replacements The object to search for replacements
* @param {babelNode} nodePath The node to evaluate
* @param {function} replaceFn The function used to replace the node
* @param {function} comparator The function used to evaluate whether a node matches a value in `replacements`
* @return {undefined}
*/
const processNode = (replacements, nodePath, replaceFn, comparator) => { // eslint-disable-line
const replacementKey = find(getSortedObjectPaths(replacements),
(value) => comparator(nodePath, value));
if (has(replacements, replacementKey)) {
replaceAndEvaluateNode(replaceFn, nodePath, get(replacements, replacementKey));
}
};
const memberExpressionComparator = (nodePath, value) => nodePath.matchesPattern(value);
const identifierComparator = (nodePath, value) => nodePath.node.name === value;
const unaryExpressionComparator = (nodePath, value) => nodePath.node.argument.name === value;
export default function ({ types: t }) {
return {
visitor: {
// process.env.NODE_ENV;
MemberExpression(nodePath, state) {
processNode(getReplacements(state.opts), nodePath, t.valueToNode, memberExpressionComparator);
},
// const x = { version: VERSION };
Identifier(nodePath, state) {
processNode(getReplacements(state.opts), nodePath, t.valueToNode, identifierComparator);
},
// typeof window
UnaryExpression(nodePath, state) {
if (nodePath.node.operator !== "typeof") { return; }
const replacements = getReplacements(state.opts);
const keys = Object.keys(replacements);
const typeofValues = {};
keys.forEach((key) => {
if (key.substring(0, 7) === "typeof ") {
typeofValues[key.substring(7)] = replacements[key];
}
});
processNode(typeofValues, nodePath, t.valueToNode, unaryExpressionComparator);
}
}
};
}
babel-plugin-transform-define-1.3.0/test/ 0000775 0000000 0000000 00000000000 13106537162 0020300 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/.eslintrc 0000664 0000000 0000000 00000000163 13106537162 0022124 0 ustar 00root root 0000000 0000000 ---
"extends":
- "formidable/configurations/es6-node-test"
rules:
no-magic-numbers: OFF
max-statements: OFF
babel-plugin-transform-define-1.3.0/test/0/ 0000775 0000000 0000000 00000000000 13106537162 0020437 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/0/actual.js 0000664 0000000 0000000 00000000174 13106537162 0022250 0 ustar 00root root 0000000 0000000 var x = PRODUCTION;
if (!PRODUCTION) {
console.log('Debug info');
}
if (PRODUCTION) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/0/expected.js 0000664 0000000 0000000 00000000160 13106537162 0022573 0 ustar 00root root 0000000 0000000 'use strict';
var x = 0;
if (!0) {
console.log('Debug info');
}
if (0) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/emptyString/ 0000775 0000000 0000000 00000000000 13106537162 0022625 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/emptyString/actual.js 0000664 0000000 0000000 00000000174 13106537162 0024436 0 ustar 00root root 0000000 0000000 var x = PRODUCTION;
if (!PRODUCTION) {
console.log('Debug info');
}
if (PRODUCTION) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/emptyString/expected.js 0000664 0000000 0000000 00000000163 13106537162 0024764 0 ustar 00root root 0000000 0000000 'use strict';
var x = '';
if (!'') {
console.log('Debug info');
}
if ('') {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/false/ 0000775 0000000 0000000 00000000000 13106537162 0021372 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/false/actual.js 0000664 0000000 0000000 00000000174 13106537162 0023203 0 ustar 00root root 0000000 0000000 var x = PRODUCTION;
if (!PRODUCTION) {
console.log('Debug info');
}
if (PRODUCTION) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/false/expected.js 0000664 0000000 0000000 00000000174 13106537162 0023533 0 ustar 00root root 0000000 0000000 'use strict';
var x = false;
if (!false) {
console.log('Debug info');
}
if (false) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/identifier/ 0000775 0000000 0000000 00000000000 13106537162 0022422 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/identifier/actual.js 0000664 0000000 0000000 00000000223 13106537162 0024226 0 ustar 00root root 0000000 0000000 VERSION;
var x = {
"version": VERSION
}
if (!PRODUCTION) {
console.log('Debug info');
}
if (PRODUCTION) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/identifier/expected.js 0000664 0000000 0000000 00000000227 13106537162 0024562 0 ustar 00root root 0000000 0000000 'use strict';
'1.0.0';
var x = {
"version": '1.0.0'
};
if (!true) {
console.log('Debug info');
}
if (true) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/index.js 0000664 0000000 0000000 00000012144 13106537162 0021747 0 ustar 00root root 0000000 0000000 "use strict";
const assertTransform = require("assert-transform");
const babel = require("babel-core");
const path = require("path");
const assert = require("assert");
const babelPluginTransformDefine = require("../lib/index.js");
const getBabelOps = (pluginOps) => {
return {
"presets": ["es2015"],
"plugins": [
[path.resolve(__dirname, "../lib/index.js"), pluginOps]
]
};
};
describe("babel-plugin-transform-define", () => {
before(function () {
// TODO: WTF babel needs to warm up! This is Bullshit!
this.timeout(10000); // eslint-disable-line
babel.transform("const x = 1;", getBabelOps());
});
describe("transformation tests", () => {
describe("Member Expressions", () => {
it("should transform with config defined by String keys", () => {
const babelOpts = getBabelOps({
"process.env.NODE_ENV": "development"
});
return assertTransform(
path.join(__dirname, "./member-expression/actual.js"),
path.join(__dirname, "./member-expression/expected.js"), babelOpts);
});
it("should transform with config defined by an Object", () => {
const babelOpts = getBabelOps({
"process": {
env: {
NODE_ENV: "development"
}
}
});
return assertTransform(
path.join(__dirname, "./member-expression/actual.js"),
path.join(__dirname, "./member-expression/expected.js"), babelOpts);
});
});
it("should transform Unary Expressions", () => {
const babelOpts = getBabelOps({
"typeof window": "object"
});
return assertTransform(
path.join(__dirname, "./unary-expression/actual.js"),
path.join(__dirname, "./unary-expression/expected.js"), babelOpts);
});
it("should transform Identifiers", () => {
const babelOpts = getBabelOps({
"VERSION": "1.0.0",
"PRODUCTION": true
});
return assertTransform(
path.join(__dirname, "./identifier/actual.js"),
path.join(__dirname, "./identifier/expected.js"), babelOpts);
});
it("should transform false", () => {
const babelOpts = getBabelOps({
"PRODUCTION": false
});
return assertTransform(
path.join(__dirname, "./false/actual.js"),
path.join(__dirname, "./false/expected.js"), babelOpts);
})
it("should transform 0", () => {
const babelOpts = getBabelOps({
"PRODUCTION": 0
});
return assertTransform(
path.join(__dirname, "./0/actual.js"),
path.join(__dirname, "./0/expected.js"), babelOpts);
})
it("should transform empty string", () => {
const babelOpts = getBabelOps({
"PRODUCTION": ''
});
return assertTransform(
path.join(__dirname, "./emptyString/actual.js"),
path.join(__dirname, "./emptyString/expected.js"), babelOpts);
})
it("should transform null", () => {
const babelOpts = getBabelOps({
"PRODUCTION": null
});
return assertTransform(
path.join(__dirname, "./null/actual.js"),
path.join(__dirname, "./null/expected.js"), babelOpts);
})
it("should transform undefined", () => {
const babelOpts = getBabelOps({
"PRODUCTION": undefined
});
return assertTransform(
path.join(__dirname, "./undefined/actual.js"),
path.join(__dirname, "./undefined/expected.js"), babelOpts);
})
it("should transform code from config in a file", () => {
const babelOpts = getBabelOps("./test/load-config-file/config.js");
return assertTransform(
path.join(__dirname, "./load-config-file/actual.js"),
path.join(__dirname, "./load-config-file/expected.js"), babelOpts);
});
});
describe("unit tests", () => {
describe("getSortedObjectPaths", () => {
it("should return an array", () => {
let objectPaths = babelPluginTransformDefine.getSortedObjectPaths(null);
assert(Array.isArray(objectPaths));
objectPaths = babelPluginTransformDefine.getSortedObjectPaths(undefined);
assert(Array.isArray(objectPaths));
objectPaths = babelPluginTransformDefine.getSortedObjectPaths();
assert(Array.isArray(objectPaths));
objectPaths = babelPluginTransformDefine.getSortedObjectPaths({});
assert(Array.isArray(objectPaths));
objectPaths = babelPluginTransformDefine.getSortedObjectPaths({ process: "env" });
assert(Array.isArray(objectPaths));
});
it("should return a complete list of paths", () => {
const obj = { process: { env: { NODE_ENV: "development" } } };
const objectPaths = babelPluginTransformDefine.getSortedObjectPaths(obj);
assert.deepEqual(objectPaths, [ "process.env.NODE_ENV", "process.env", "process" ]);
});
it("should return a list sorted by length", () => {
const obj = { process: { env: { NODE_ENV: "development" } } };
const objectPaths = babelPluginTransformDefine.getSortedObjectPaths(obj);
assert.deepEqual(objectPaths, objectPaths.sort((elem) => elem.length));
});
});
});
});
babel-plugin-transform-define-1.3.0/test/load-config-file/ 0000775 0000000 0000000 00000000000 13106537162 0023377 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/load-config-file/actual.js 0000664 0000000 0000000 00000000076 13106537162 0025211 0 ustar 00root root 0000000 0000000 process.env.NODE_ENV;
process.env.NODE_ENV === "development";
babel-plugin-transform-define-1.3.0/test/load-config-file/config.js 0000664 0000000 0000000 00000000115 13106537162 0025177 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = {
"process.env.NODE_ENV": "development"
};
babel-plugin-transform-define-1.3.0/test/load-config-file/expected.js 0000664 0000000 0000000 00000000044 13106537162 0025534 0 ustar 00root root 0000000 0000000 "use strict";
"development";
true;
babel-plugin-transform-define-1.3.0/test/member-expression/ 0000775 0000000 0000000 00000000000 13106537162 0023744 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/member-expression/actual.js 0000664 0000000 0000000 00000000076 13106537162 0025556 0 ustar 00root root 0000000 0000000 process.env.NODE_ENV;
process.env.NODE_ENV === "development";
babel-plugin-transform-define-1.3.0/test/member-expression/expected.js 0000664 0000000 0000000 00000000044 13106537162 0026101 0 ustar 00root root 0000000 0000000 "use strict";
"development";
true;
babel-plugin-transform-define-1.3.0/test/null/ 0000775 0000000 0000000 00000000000 13106537162 0021252 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/null/actual.js 0000664 0000000 0000000 00000000174 13106537162 0023063 0 ustar 00root root 0000000 0000000 var x = PRODUCTION;
if (!PRODUCTION) {
console.log('Debug info');
}
if (PRODUCTION) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/null/expected.js 0000664 0000000 0000000 00000000171 13106537162 0023410 0 ustar 00root root 0000000 0000000 'use strict';
var x = null;
if (!null) {
console.log('Debug info');
}
if (null) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/unary-expression/ 0000775 0000000 0000000 00000000000 13106537162 0023633 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/unary-expression/actual.js 0000664 0000000 0000000 00000000053 13106537162 0025440 0 ustar 00root root 0000000 0000000 typeof window;
typeof window === "object";
babel-plugin-transform-define-1.3.0/test/unary-expression/expected.js 0000664 0000000 0000000 00000000037 13106537162 0025772 0 ustar 00root root 0000000 0000000 "use strict";
"object";
true;
babel-plugin-transform-define-1.3.0/test/undefined/ 0000775 0000000 0000000 00000000000 13106537162 0022241 5 ustar 00root root 0000000 0000000 babel-plugin-transform-define-1.3.0/test/undefined/actual.js 0000664 0000000 0000000 00000000174 13106537162 0024052 0 ustar 00root root 0000000 0000000 var x = PRODUCTION;
if (!PRODUCTION) {
console.log('Debug info');
}
if (PRODUCTION) {
console.log('Production log');
}
babel-plugin-transform-define-1.3.0/test/undefined/expected.js 0000664 0000000 0000000 00000000210 13106537162 0024371 0 ustar 00root root 0000000 0000000 'use strict';
var x = undefined;
if (!undefined) {
console.log('Debug info');
}
if (undefined) {
console.log('Production log');
}