react-lazy-data
Advanced tools
Comparing version 0.2.3 to 0.2.4
# Changelog | ||
## 0.2.4 | ||
Build: | ||
* Remove `__DEV__` from builds [fix] | ||
## 0.2.3 | ||
@@ -4,0 +10,0 @@ |
@@ -20,3 +20,3 @@ 'use strict'; | ||
const invariant = __DEV__ ? (condition, message) => invariant$1(condition, `${PLUGIN_NAME}: ${message}`) : invariant$1; | ||
const invariant = (condition, message) => invariant$1(condition, `${PLUGIN_NAME}: ${message}`) ; | ||
/** | ||
@@ -58,3 +58,3 @@ * Babel plugin. | ||
} = options; | ||
invariant(cacheVar === undefined || isItType.isFullString(cacheVar), `options.cacheVar must be a non-empty string if provided - got ${cacheVar}`); // Disregard the default as it's unnecessary | ||
!(cacheVar === undefined || isItType.isFullString(cacheVar)) ? invariant(false, `options.cacheVar must be a non-empty string if provided - got ${cacheVar}`) : void 0; // Disregard the default as it's unnecessary | ||
@@ -64,3 +64,3 @@ if (cacheVar === constants.DEFAULT_CACHE_VAR) cacheVar = undefined; // ID options | ||
const idOptions = lodash.pick(options, ['rootPath', 'isPackage', 'packageName', 'packageVersion', 'idLength']); | ||
if (__DEV__) idOptions.pluginName = PLUGIN_NAME; // Return plugin | ||
idOptions.pluginName = PLUGIN_NAME; // Return plugin | ||
@@ -108,6 +108,6 @@ return { | ||
noSsr = false; | ||
invariant(!idProp || idProp.valuePath.isStringLiteral(), '`createResourceFactory()` `id` option must be a string literal if defined'); | ||
!(!idProp || idProp.valuePath.isStringLiteral()) ? invariant(false, '`createResourceFactory()` `id` option must be a string literal if defined') : void 0; | ||
if (noSsrProp) { | ||
invariant(noSsrProp.valuePath.isBooleanLiteral(), '`createResourceFactory()` `noSsr` option must be a boolean literal if defined'); | ||
!noSsrProp.valuePath.isBooleanLiteral() ? invariant(false, '`createResourceFactory()` `noSsr` option must be a boolean literal if defined') : void 0; | ||
noSsr = noSsrProp.value; // Remove `noSsr: false` as it's the default | ||
@@ -128,3 +128,3 @@ | ||
} else { | ||
invariant(valuePath.isFunctionExpression() || valuePath.isArrowFunctionExpression(), '`createResourceFactory()` `serialize` option must be a boolean or function literal'); | ||
!(valuePath.isFunctionExpression() || valuePath.isArrowFunctionExpression()) ? invariant(false, '`createResourceFactory()` `serialize` option must be a boolean or function literal') : void 0; | ||
} | ||
@@ -134,5 +134,5 @@ } | ||
if (cacheVarProp) { | ||
invariant(cacheVarProp.valuePath.isStringLiteral(), '`createResourceFactory()` `cacheVar` option must be a string literal if defined'); | ||
!cacheVarProp.valuePath.isStringLiteral() ? invariant(false, '`createResourceFactory()` `cacheVar` option must be a string literal if defined') : void 0; | ||
cacheVar = cacheVarProp.value; | ||
invariant(cacheVar !== '', '`createResourceFactory()` `cacheVar` option must not be empty string'); // Remove `cacheVar: <default>` as it's the default | ||
!(cacheVar !== '') ? invariant(false, '`createResourceFactory()` `cacheVar` option must not be empty string') : void 0; // Remove `cacheVar: <default>` as it's the default | ||
@@ -182,3 +182,3 @@ if (cacheVar === constants.DEFAULT_CACHE_VAR) { | ||
function getObjectProps(objectPath) { | ||
invariant(objectPath.isObjectExpression(), '`createResourceFactory()` options must be an object literal'); | ||
!objectPath.isObjectExpression() ? invariant(false, '`createResourceFactory()` options must be an object literal') : void 0; | ||
const propsPaths = {}; | ||
@@ -189,3 +189,3 @@ | ||
const keyPath = propPath.get('key'); | ||
invariant(keyPath.isIdentifier(), '`createResourceFactory()` options must contain only identifiers as keys'); | ||
!keyPath.isIdentifier() ? invariant(false, '`createResourceFactory()` options must contain only identifiers as keys') : void 0; | ||
const valuePath = propPath.get('value'), | ||
@@ -192,0 +192,0 @@ { |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("is-it-type"),r=e(require("tiny-invariant")),o=require("./constants.min.js"),i=e(require("babel-unique-id")),a=require("lodash");const n=__DEV__?(e,t)=>r(e,`react-lazy-data/babel: ${t}`):r;function s(e,t,r,o){!function(e,t,r,o){const i=o.objectProperty(o.identifier(t),r);e.pushContainer("properties",i)}(e,t,o.stringLiteral(r),o)}module.exports=function(e,r){let{cacheVar:c}=r;n(void 0===c||t.isFullString(c),`options.cacheVar must be a non-empty string if provided - got ${c}`),c===o.DEFAULT_CACHE_VAR&&(c=void 0);const u=a.pick(r,["rootPath","isPackage","packageName","packageVersion","idLength"]);return __DEV__&&(u.pluginName="react-lazy-data/babel"),{visitor:{CallExpression(t,r){!function(e,t,r,a,c){if(!e.get("callee").isIdentifier({name:"createResourceFactory"}))return;let u,l;if(e.node.arguments.length>1){u=e.get("arguments.1");const t=function(e){n(e.isObjectExpression(),"`createResourceFactory()` options must be an object literal");const t={};for(let r=0;r<e.node.properties.length;r++){const o=e.get(`properties.${r}`),i=o.get("key");n(i.isIdentifier(),"`createResourceFactory()` options must contain only identifiers as keys");const a=o.get("value"),{value:s}=a.node;t[i.node.name]={propPath:o,valuePath:a,value:s}}return t}(u),{id:r,serialize:i,noSsr:a}=t;let s=t.cacheVar,c=!0,p=!1;if(n(!r||r.valuePath.isStringLiteral(),"`createResourceFactory()` `id` option must be a string literal if defined"),a&&(n(a.valuePath.isBooleanLiteral(),"`createResourceFactory()` `noSsr` option must be a boolean literal if defined"),p=a.value,p||a.propPath.remove()),i){const{valuePath:e}=i;e.isBooleanLiteral()?(c=i.value,c&&!p&&i.propPath.remove()):n(e.isFunctionExpression()||e.isArrowFunctionExpression(),"`createResourceFactory()` `serialize` option must be a boolean or function literal")}if(s&&(n(s.valuePath.isStringLiteral(),"`createResourceFactory()` `cacheVar` option must be a string literal if defined"),l=s.value,n(""!==l,"`createResourceFactory()` `cacheVar` option must not be empty string"),l===o.DEFAULT_CACHE_VAR&&(s.propPath.remove(),s=void 0)),!c||p)return r&&r.propPath.remove(),void(s&&s.propPath.remove());if(r)return}else{const t=c.objectExpression([]);e.pushContainer("arguments",t),u=e.get("arguments.1")}const p=i(t,r);s(u,"id",p,c),l||(l=a,l&&s(u,"cacheVar",l,c))}(t,r,u,c,e.types)}}}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("is-it-type"),r=e(require("tiny-invariant")),i=require("./constants.min.js"),n=e(require("babel-unique-id")),o=require("lodash");const a=r;function s(e,t,r,i){!function(e,t,r,i){const n=i.objectProperty(i.identifier(t),r);e.pushContainer("properties",n)}(e,t,i.stringLiteral(r),i)}module.exports=function(e,r){let{cacheVar:u}=r;void 0===u||t.isFullString(u)||a(!1),u===i.DEFAULT_CACHE_VAR&&(u=void 0);const c=o.pick(r,["rootPath","isPackage","packageName","packageVersion","idLength"]);return{visitor:{CallExpression(t,r){!function(e,t,r,o,u){if(!e.get("callee").isIdentifier({name:"createResourceFactory"}))return;let c,l;if(e.node.arguments.length>1){c=e.get("arguments.1");const t=function(e){e.isObjectExpression()||a(!1);const t={};for(let r=0;r<e.node.properties.length;r++){const i=e.get(`properties.${r}`),n=i.get("key");n.isIdentifier()||a(!1);const o=i.get("value"),{value:s}=o.node;t[n.node.name]={propPath:i,valuePath:o,value:s}}return t}(c),{id:r,serialize:n,noSsr:o}=t;let s=t.cacheVar,u=!0,p=!1;if(r&&!r.valuePath.isStringLiteral()&&a(!1),o&&(o.valuePath.isBooleanLiteral()||a(!1),p=o.value,p||o.propPath.remove()),n){const{valuePath:e}=n;e.isBooleanLiteral()?(u=n.value,u&&!p&&n.propPath.remove()):e.isFunctionExpression()||e.isArrowFunctionExpression()||a(!1)}if(s&&(s.valuePath.isStringLiteral()||a(!1),l=s.value,""===l&&a(!1),l===i.DEFAULT_CACHE_VAR&&(s.propPath.remove(),s=void 0)),!u||p)return r&&r.propPath.remove(),void(s&&s.propPath.remove());if(r)return}else{const t=u.objectExpression([]);e.pushContainer("arguments",t),c=e.get("arguments.1")}const p=n(t,r);s(c,"id",p,u),l||(l=o,l&&s(c,"cacheVar",l,u))}(t,r,c,u,e.types)}}}}; | ||
//# sourceMappingURL=babel.min.js.map |
@@ -16,3 +16,3 @@ import { isFullString } from 'is-it-type'; | ||
const invariant = __DEV__ ? (condition, message) => invariant$1(condition, `${PLUGIN_NAME}: ${message}`) : invariant$1; | ||
const invariant = (condition, message) => invariant$1(condition, `${PLUGIN_NAME}: ${message}`) ; | ||
/** | ||
@@ -54,3 +54,3 @@ * Babel plugin. | ||
} = options; | ||
invariant(cacheVar === undefined || isFullString(cacheVar), `options.cacheVar must be a non-empty string if provided - got ${cacheVar}`); // Disregard the default as it's unnecessary | ||
!(cacheVar === undefined || isFullString(cacheVar)) ? invariant(false, `options.cacheVar must be a non-empty string if provided - got ${cacheVar}`) : void 0; // Disregard the default as it's unnecessary | ||
@@ -60,3 +60,3 @@ if (cacheVar === DEFAULT_CACHE_VAR) cacheVar = undefined; // ID options | ||
const idOptions = pick(options, ['rootPath', 'isPackage', 'packageName', 'packageVersion', 'idLength']); | ||
if (__DEV__) idOptions.pluginName = PLUGIN_NAME; // Return plugin | ||
idOptions.pluginName = PLUGIN_NAME; // Return plugin | ||
@@ -104,6 +104,6 @@ return { | ||
noSsr = false; | ||
invariant(!idProp || idProp.valuePath.isStringLiteral(), '`createResourceFactory()` `id` option must be a string literal if defined'); | ||
!(!idProp || idProp.valuePath.isStringLiteral()) ? invariant(false, '`createResourceFactory()` `id` option must be a string literal if defined') : void 0; | ||
if (noSsrProp) { | ||
invariant(noSsrProp.valuePath.isBooleanLiteral(), '`createResourceFactory()` `noSsr` option must be a boolean literal if defined'); | ||
!noSsrProp.valuePath.isBooleanLiteral() ? invariant(false, '`createResourceFactory()` `noSsr` option must be a boolean literal if defined') : void 0; | ||
noSsr = noSsrProp.value; // Remove `noSsr: false` as it's the default | ||
@@ -124,3 +124,3 @@ | ||
} else { | ||
invariant(valuePath.isFunctionExpression() || valuePath.isArrowFunctionExpression(), '`createResourceFactory()` `serialize` option must be a boolean or function literal'); | ||
!(valuePath.isFunctionExpression() || valuePath.isArrowFunctionExpression()) ? invariant(false, '`createResourceFactory()` `serialize` option must be a boolean or function literal') : void 0; | ||
} | ||
@@ -130,5 +130,5 @@ } | ||
if (cacheVarProp) { | ||
invariant(cacheVarProp.valuePath.isStringLiteral(), '`createResourceFactory()` `cacheVar` option must be a string literal if defined'); | ||
!cacheVarProp.valuePath.isStringLiteral() ? invariant(false, '`createResourceFactory()` `cacheVar` option must be a string literal if defined') : void 0; | ||
cacheVar = cacheVarProp.value; | ||
invariant(cacheVar !== '', '`createResourceFactory()` `cacheVar` option must not be empty string'); // Remove `cacheVar: <default>` as it's the default | ||
!(cacheVar !== '') ? invariant(false, '`createResourceFactory()` `cacheVar` option must not be empty string') : void 0; // Remove `cacheVar: <default>` as it's the default | ||
@@ -178,3 +178,3 @@ if (cacheVar === DEFAULT_CACHE_VAR) { | ||
function getObjectProps(objectPath) { | ||
invariant(objectPath.isObjectExpression(), '`createResourceFactory()` options must be an object literal'); | ||
!objectPath.isObjectExpression() ? invariant(false, '`createResourceFactory()` options must be an object literal') : void 0; | ||
const propsPaths = {}; | ||
@@ -185,3 +185,3 @@ | ||
const keyPath = propPath.get('key'); | ||
invariant(keyPath.isIdentifier(), '`createResourceFactory()` options must contain only identifiers as keys'); | ||
!keyPath.isIdentifier() ? invariant(false, '`createResourceFactory()` options must contain only identifiers as keys') : void 0; | ||
const valuePath = propPath.get('value'), | ||
@@ -188,0 +188,0 @@ { |
@@ -1,2 +0,2 @@ | ||
import{isFullString as e}from"is-it-type";import t from"tiny-invariant";import{D as o}from"./constants.min.js";import r from"babel-unique-id";import{pick as a}from"lodash";const i=__DEV__?(e,o)=>t(e,`react-lazy-data/babel: ${o}`):t;function n(e,t,o,r){!function(e,t,o,r){const a=r.objectProperty(r.identifier(t),o);e.pushContainer("properties",a)}(e,t,r.stringLiteral(o),r)}export default function(t,s){let{cacheVar:c}=s;i(void 0===c||e(c),`options.cacheVar must be a non-empty string if provided - got ${c}`),c===o&&(c=void 0);const l=a(s,["rootPath","isPackage","packageName","packageVersion","idLength"]);return __DEV__&&(l.pluginName="react-lazy-data/babel"),{visitor:{CallExpression(e,a){!function(e,t,a,s,c){if(!e.get("callee").isIdentifier({name:"createResourceFactory"}))return;let l,u;if(e.node.arguments.length>1){l=e.get("arguments.1");const t=function(e){i(e.isObjectExpression(),"`createResourceFactory()` options must be an object literal");const t={};for(let o=0;o<e.node.properties.length;o++){const r=e.get(`properties.${o}`),a=r.get("key");i(a.isIdentifier(),"`createResourceFactory()` options must contain only identifiers as keys");const n=r.get("value"),{value:s}=n.node;t[a.node.name]={propPath:r,valuePath:n,value:s}}return t}(l),{id:r,serialize:a,noSsr:n}=t;let s=t.cacheVar,c=!0,p=!1;if(i(!r||r.valuePath.isStringLiteral(),"`createResourceFactory()` `id` option must be a string literal if defined"),n&&(i(n.valuePath.isBooleanLiteral(),"`createResourceFactory()` `noSsr` option must be a boolean literal if defined"),p=n.value,p||n.propPath.remove()),a){const{valuePath:e}=a;e.isBooleanLiteral()?(c=a.value,c&&!p&&a.propPath.remove()):i(e.isFunctionExpression()||e.isArrowFunctionExpression(),"`createResourceFactory()` `serialize` option must be a boolean or function literal")}if(s&&(i(s.valuePath.isStringLiteral(),"`createResourceFactory()` `cacheVar` option must be a string literal if defined"),u=s.value,i(""!==u,"`createResourceFactory()` `cacheVar` option must not be empty string"),u===o&&(s.propPath.remove(),s=void 0)),!c||p)return r&&r.propPath.remove(),void(s&&s.propPath.remove());if(r)return}else{const t=c.objectExpression([]);e.pushContainer("arguments",t),l=e.get("arguments.1")}const p=r(t,a);n(l,"id",p,c),u||(u=s,u&&n(l,"cacheVar",u,c))}(e,a,l,c,t.types)}}}} | ||
import{isFullString as e}from"is-it-type";import t from"tiny-invariant";import{D as r}from"./constants.min.js";import o from"babel-unique-id";import{pick as i}from"lodash";const n=t;function a(e,t,r,o){!function(e,t,r,o){const i=o.objectProperty(o.identifier(t),r);e.pushContainer("properties",i)}(e,t,o.stringLiteral(r),o)}export default function(t,s){let{cacheVar:p}=s;void 0===p||e(p)||n(!1),p===r&&(p=void 0);const c=i(s,["rootPath","isPackage","packageName","packageVersion","idLength"]);return{visitor:{CallExpression(e,i){!function(e,t,i,s,p){if(!e.get("callee").isIdentifier({name:"createResourceFactory"}))return;let c,l;if(e.node.arguments.length>1){c=e.get("arguments.1");const t=function(e){e.isObjectExpression()||n(!1);const t={};for(let r=0;r<e.node.properties.length;r++){const o=e.get(`properties.${r}`),i=o.get("key");i.isIdentifier()||n(!1);const a=o.get("value"),{value:s}=a.node;t[i.node.name]={propPath:o,valuePath:a,value:s}}return t}(c),{id:o,serialize:i,noSsr:a}=t;let s=t.cacheVar,p=!0,u=!1;if(o&&!o.valuePath.isStringLiteral()&&n(!1),a&&(a.valuePath.isBooleanLiteral()||n(!1),u=a.value,u||a.propPath.remove()),i){const{valuePath:e}=i;e.isBooleanLiteral()?(p=i.value,p&&!u&&i.propPath.remove()):e.isFunctionExpression()||e.isArrowFunctionExpression()||n(!1)}if(s&&(s.valuePath.isStringLiteral()||n(!1),l=s.value,""===l&&n(!1),l===r&&(s.propPath.remove(),s=void 0)),!p||u)return o&&o.propPath.remove(),void(s&&s.propPath.remove());if(o)return}else{const t=p.objectExpression([]);e.pushContainer("arguments",t),c=e.get("arguments.1")}const u=o(t,i);a(c,"id",u,p),l||(l=s,l&&a(c,"cacheVar",l,p))}(e,i,c,p,t.types)}}}} | ||
//# sourceMappingURL=babel.min.js.map |
{ | ||
"name": "react-lazy-data", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Lazy-load data with React Suspense", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
383897
2267