Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

raw.macro

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raw.macro - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

dist/raw.macro.esm.js

@@ -1,2 +0,2 @@

var e=require("path"),r=require("fs"),t=require("babel-plugin-macros");function a(t,i,n,o){void 0===o&&(o="");var l=i.map(function(i){if(Array.isArray(i))return t.objectProperty(t.stringLiteral(i[0]),a(t,i[1],e.join(n,i[0]),o));try{var l=o.startsWith(".")&&i.endsWith(o)?i:i+o,s=require.resolve(l,{paths:[n]});return t.objectProperty(t.stringLiteral(i.replace(o,"")),t.stringLiteral(r.readFileSync(s,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===l.length)throw new Error("Cannot resolve file "+o+" in these directories: "+i.join(", "));return t.objectExpression(l)}module.exports=(0,t.createMacro)(function(t){var i=t.state,n=t.babel,o={value:0};t.references.default.forEach(function(t){if("CallExpression"!==t.parentPath.type)throw new Error("This is not supported: `"+t.findParent(n.types.isExpression).getSource()+"`. Please see the raw.macro documentation");!function(t){var i,n=t.referencePath,o=t.usageCounter,l=t.babel.types,s=n.parentPath,u=e.dirname(t.state.file.opts.filename),c=s.get("arguments")[0];switch(c.node.type){case"TemplateLiteral":var f=c.node,h=f.expressions,v=f.quasis;if(0===h.length){i=v[0].value.raw;break}if(""===v[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(h.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");var d="__raw_dynamic__"+o.value;o.value++;var p=h.map(function(e,r){var t=r!==v.length-1&&c.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),m=e.join(u,v[0].value.raw),y=r.readdirSync(m).filter(function(t){try{return r.lstatSync(e.join(m,t)).isDirectory()===p[0].isDirectory}catch(e){return!1}}).flatMap(function(e){return p[0].isDirectory?e:e.endsWith(v[1].value.raw)?e.replace(v[1].value.raw,""):[]});return v.slice(1).forEach(function(t,a){p[a].isDirectory&&y.forEach(function(i,n){if(!t.tail){var o=e.join(m,i),l=r.readdirSync(o).filter(function(e){return e.endsWith(v[a+2].value.raw)});y[n]=[i,l]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(n).unshiftContainer("body",l.variableDeclaration("var",[l.variableDeclarator(l.identifier(d),a(l,y,m,v[v.length-1].value.raw))])),void s.replaceWith(l.expressionStatement(p.reduce(function(e,r){return l.memberExpression(e,l.identifier(r.name),!0)},l.identifier(d))));case"StringLiteral":i=c.node.value}if(void 0===i)throw new Error("There was a problem evaluating the value of the argument for the code: "+s.getSource()+". If the value is dynamic, please make sure that its value is statically deterministic.");var w=require.resolve(i,{paths:[u]}),g=r.readFileSync(w,{encoding:"utf-8"});s.replaceWith(l.expressionStatement(l.stringLiteral(g)))}({referencePath:t,state:i,babel:n,usageCounter:o})})});
var e=require("path"),r=require("fs"),t=require("babel-plugin-macros");function a(t,i,n,o){void 0===o&&(o="");var l=i.map(function(i){if(Array.isArray(i))return t.objectProperty(t.stringLiteral(i[0]),a(t,i[1],e.join(n,i[0]),o));try{var l=o.startsWith(".")&&i.endsWith(o)?i:i+o,s=require.resolve("./"+l,{paths:[n]});return t.objectProperty(t.stringLiteral(i.replace(o,"")),t.stringLiteral(r.readFileSync(s,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===l.length)throw new Error("Cannot resolve file "+o+" in these directories: "+i.join(", "));return t.objectExpression(l)}module.exports=(0,t.createMacro)(function(t){var i=t.state,n=t.babel,o={value:0};t.references.default.forEach(function(t){if("CallExpression"!==t.parentPath.type)throw new Error("This is not supported: `"+t.findParent(n.types.isExpression).getSource()+"`. Please see the raw.macro documentation");!function(t){var i,n=t.referencePath,o=t.usageCounter,l=t.babel.types,s=n.parentPath,u=e.dirname(t.state.file.opts.filename),c=s.get("arguments")[0];switch(c.node.type){case"TemplateLiteral":var f=c.node,v=f.expressions,h=f.quasis;if(0===v.length){i=h[0].value.raw;break}try{if(void 0!==(i=s.get("arguments")[0].evaluate().value))break}catch(e){}if(""===h[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(v.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");var d="__raw_dynamic__"+o.value;o.value++;var p=v.map(function(e,r){var t=r!==h.length-1&&c.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),m=e.join(u,h[0].value.raw),y=r.readdirSync(m).filter(function(t){try{return r.lstatSync(e.join(m,t)).isDirectory()===p[0].isDirectory}catch(e){return!1}}).flatMap(function(e){return p[0].isDirectory?e:e.endsWith(h[1].value.raw)?e.replace(h[1].value.raw,""):[]});return h.slice(1).forEach(function(t,a){p[a].isDirectory&&y.forEach(function(i,n){if(!t.tail){var o=e.join(m,i),l=r.readdirSync(o).filter(function(e){return e.endsWith(h[a+2].value.raw)});y[n]=[i,l]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(n).unshiftContainer("body",l.variableDeclaration("var",[l.variableDeclarator(l.identifier(d),a(l,y,m,h[h.length-1].value.raw))])),void s.replaceWith(l.expressionStatement(p.reduce(function(e,r){return l.memberExpression(e,l.identifier(r.name),!0)},l.identifier(d))));case"StringLiteral":i=c.node.value}if(void 0===i)throw new Error("There was a problem evaluating the value of the argument for the code: "+s.getSource()+". If the value is dynamic, please make sure that its value is statically deterministic.");var g=require.resolve(i,{paths:[u]}),w=r.readFileSync(g,{encoding:"utf-8"});s.replaceWith(l.expressionStatement(l.stringLiteral(w)))}({referencePath:t,state:i,babel:n,usageCounter:o})})});
//# sourceMappingURL=raw.macro.esm.js.map

@@ -1,2 +0,2 @@

var e=require("path"),r=require("fs"),t=require("babel-plugin-macros");function a(t,i,n,o){void 0===o&&(o="");var l=i.map(function(i){if(Array.isArray(i))return t.objectProperty(t.stringLiteral(i[0]),a(t,i[1],e.join(n,i[0]),o));try{var l=o.startsWith(".")&&i.endsWith(o)?i:i+o,s=require.resolve(l,{paths:[n]});return t.objectProperty(t.stringLiteral(i.replace(o,"")),t.stringLiteral(r.readFileSync(s,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===l.length)throw new Error("Cannot resolve file "+o+" in these directories: "+i.join(", "));return t.objectExpression(l)}module.exports=(0,t.createMacro)(function(t){var i=t.state,n=t.babel,o={value:0};t.references.default.forEach(function(t){if("CallExpression"!==t.parentPath.type)throw new Error("This is not supported: `"+t.findParent(n.types.isExpression).getSource()+"`. Please see the raw.macro documentation");!function(t){var i,n=t.referencePath,o=t.usageCounter,l=t.babel.types,s=n.parentPath,u=e.dirname(t.state.file.opts.filename),c=s.get("arguments")[0];switch(c.node.type){case"TemplateLiteral":var f=c.node,h=f.expressions,v=f.quasis;if(0===h.length){i=v[0].value.raw;break}if(""===v[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(h.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");var d="__raw_dynamic__"+o.value;o.value++;var p=h.map(function(e,r){var t=r!==v.length-1&&c.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),m=e.join(u,v[0].value.raw),y=r.readdirSync(m).filter(function(t){try{return r.lstatSync(e.join(m,t)).isDirectory()===p[0].isDirectory}catch(e){return!1}}).flatMap(function(e){return p[0].isDirectory?e:e.endsWith(v[1].value.raw)?e.replace(v[1].value.raw,""):[]});return v.slice(1).forEach(function(t,a){p[a].isDirectory&&y.forEach(function(i,n){if(!t.tail){var o=e.join(m,i),l=r.readdirSync(o).filter(function(e){return e.endsWith(v[a+2].value.raw)});y[n]=[i,l]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(n).unshiftContainer("body",l.variableDeclaration("var",[l.variableDeclarator(l.identifier(d),a(l,y,m,v[v.length-1].value.raw))])),void s.replaceWith(l.expressionStatement(p.reduce(function(e,r){return l.memberExpression(e,l.identifier(r.name),!0)},l.identifier(d))));case"StringLiteral":i=c.node.value}if(void 0===i)throw new Error("There was a problem evaluating the value of the argument for the code: "+s.getSource()+". If the value is dynamic, please make sure that its value is statically deterministic.");var w=require.resolve(i,{paths:[u]}),g=r.readFileSync(w,{encoding:"utf-8"});s.replaceWith(l.expressionStatement(l.stringLiteral(g)))}({referencePath:t,state:i,babel:n,usageCounter:o})})});
var e=require("path"),r=require("fs"),t=require("babel-plugin-macros");function a(t,i,n,o){void 0===o&&(o="");var l=i.map(function(i){if(Array.isArray(i))return t.objectProperty(t.stringLiteral(i[0]),a(t,i[1],e.join(n,i[0]),o));try{var l=o.startsWith(".")&&i.endsWith(o)?i:i+o,s=require.resolve("./"+l,{paths:[n]});return t.objectProperty(t.stringLiteral(i.replace(o,"")),t.stringLiteral(r.readFileSync(s,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===l.length)throw new Error("Cannot resolve file "+o+" in these directories: "+i.join(", "));return t.objectExpression(l)}module.exports=(0,t.createMacro)(function(t){var i=t.state,n=t.babel,o={value:0};t.references.default.forEach(function(t){if("CallExpression"!==t.parentPath.type)throw new Error("This is not supported: `"+t.findParent(n.types.isExpression).getSource()+"`. Please see the raw.macro documentation");!function(t){var i,n=t.referencePath,o=t.usageCounter,l=t.babel.types,s=n.parentPath,u=e.dirname(t.state.file.opts.filename),c=s.get("arguments")[0];switch(c.node.type){case"TemplateLiteral":var f=c.node,v=f.expressions,h=f.quasis;if(0===v.length){i=h[0].value.raw;break}try{if(void 0!==(i=s.get("arguments")[0].evaluate().value))break}catch(e){}if(""===h[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(v.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");var d="__raw_dynamic__"+o.value;o.value++;var p=v.map(function(e,r){var t=r!==h.length-1&&c.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),m=e.join(u,h[0].value.raw),y=r.readdirSync(m).filter(function(t){try{return r.lstatSync(e.join(m,t)).isDirectory()===p[0].isDirectory}catch(e){return!1}}).flatMap(function(e){return p[0].isDirectory?e:e.endsWith(h[1].value.raw)?e.replace(h[1].value.raw,""):[]});return h.slice(1).forEach(function(t,a){p[a].isDirectory&&y.forEach(function(i,n){if(!t.tail){var o=e.join(m,i),l=r.readdirSync(o).filter(function(e){return e.endsWith(h[a+2].value.raw)});y[n]=[i,l]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(n).unshiftContainer("body",l.variableDeclaration("var",[l.variableDeclarator(l.identifier(d),a(l,y,m,h[h.length-1].value.raw))])),void s.replaceWith(l.expressionStatement(p.reduce(function(e,r){return l.memberExpression(e,l.identifier(r.name),!0)},l.identifier(d))));case"StringLiteral":i=c.node.value}if(void 0===i)throw new Error("There was a problem evaluating the value of the argument for the code: "+s.getSource()+". If the value is dynamic, please make sure that its value is statically deterministic.");var g=require.resolve(i,{paths:[u]}),w=r.readFileSync(g,{encoding:"utf-8"});s.replaceWith(l.expressionStatement(l.stringLiteral(w)))}({referencePath:t,state:i,babel:n,usageCounter:o})})});
//# sourceMappingURL=raw.macro.js.map

@@ -1,2 +0,2 @@

const e=require("path"),r=require("fs"),{createMacro:t}=require("babel-plugin-macros");function a(t,i,n,o=""){const s=i.map(i=>{if(Array.isArray(i))return t.objectProperty(t.stringLiteral(i[0]),a(t,i[1],e.join(n,i[0]),o));try{const e=o.startsWith(".")&&i.endsWith(o)?i:i+o,a=require.resolve(e,{paths:[n]});return t.objectProperty(t.stringLiteral(i.replace(o,"")),t.stringLiteral(r.readFileSync(a,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===s.length)throw new Error(`Cannot resolve file ${o} in these directories: ${i.join(", ")}`);return t.objectExpression(s)}module.exports=t(function({references:t,state:i,babel:n}){let o={value:0};t.default.forEach(t=>{if("CallExpression"!==t.parentPath.type)throw new Error(`This is not supported: \`${t.findParent(n.types.isExpression).getSource()}\`. Please see the raw.macro documentation`);!function({referencePath:t,state:i,babel:n,usageCounter:o}){const s=n.types,l=t.parentPath,c=e.dirname(i.file.opts.filename);let u;const h=l.get("arguments")[0];switch(h.node.type){case"TemplateLiteral":{const{expressions:i,quasis:n}=h.node;if(0===i.length){u=n[0].value.raw;break}if(""===n[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(i.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");const f="__raw_dynamic__"+o.value;o.value++;const p=i.map((e,r)=>{const t=r!==n.length-1&&h.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),d=e.join(c,n[0].value.raw),v=r.readdirSync(d).filter(t=>{try{return r.lstatSync(e.join(d,t)).isDirectory()===p[0].isDirectory}catch(e){return!1}}).flatMap(e=>p[0].isDirectory?e:e.endsWith(n[1].value.raw)?e.replace(n[1].value.raw,""):[]);return n.slice(1).forEach((t,a)=>{p[a].isDirectory&&v.forEach((i,o)=>{if(!t.tail){const t=e.join(d,i),s=r.readdirSync(t).filter(e=>e.endsWith(n[a+2].value.raw));v[o]=[i,s]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(t).unshiftContainer("body",s.variableDeclaration("var",[s.variableDeclarator(s.identifier(f),a(s,v,d,n[n.length-1].value.raw))])),void l.replaceWith(s.expressionStatement(p.reduce((e,r)=>s.memberExpression(e,s.identifier(r.name),!0),s.identifier(f))))}case"StringLiteral":u=h.node.value}if(void 0===u)throw new Error(`There was a problem evaluating the value of the argument for the code: ${l.getSource()}. If the value is dynamic, please make sure that its value is statically deterministic.`);const f=require.resolve(u,{paths:[c]}),p=r.readFileSync(f,{encoding:"utf-8"});l.replaceWith(s.expressionStatement(s.stringLiteral(p)))}({referencePath:t,state:i,babel:n,usageCounter:o})})});
const e=require("path"),r=require("fs"),{createMacro:t}=require("babel-plugin-macros");function a(t,i,n,o=""){const s=i.map(i=>{if(Array.isArray(i))return t.objectProperty(t.stringLiteral(i[0]),a(t,i[1],e.join(n,i[0]),o));try{const e=o.startsWith(".")&&i.endsWith(o)?i:i+o,a=require.resolve("./"+e,{paths:[n]});return t.objectProperty(t.stringLiteral(i.replace(o,"")),t.stringLiteral(r.readFileSync(a,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===s.length)throw new Error(`Cannot resolve file ${o} in these directories: ${i.join(", ")}`);return t.objectExpression(s)}module.exports=t(function({references:t,state:i,babel:n}){let o={value:0};t.default.forEach(t=>{if("CallExpression"!==t.parentPath.type)throw new Error(`This is not supported: \`${t.findParent(n.types.isExpression).getSource()}\`. Please see the raw.macro documentation`);!function({referencePath:t,state:i,babel:n,usageCounter:o}){const s=n.types,l=t.parentPath,c=e.dirname(i.file.opts.filename);let u;const h=l.get("arguments")[0];switch(h.node.type){case"TemplateLiteral":{const{expressions:i,quasis:n}=h.node;if(0===i.length){u=n[0].value.raw;break}try{if(u=l.get("arguments")[0].evaluate().value,void 0!==u)break}catch(e){}if(""===n[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(i.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");const f="__raw_dynamic__"+o.value;o.value++;const d=i.map((e,r)=>{const t=r!==n.length-1&&h.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),p=e.join(c,n[0].value.raw),v=r.readdirSync(p).filter(t=>{try{return r.lstatSync(e.join(p,t)).isDirectory()===d[0].isDirectory}catch(e){return!1}}).flatMap(e=>d[0].isDirectory?e:e.endsWith(n[1].value.raw)?e.replace(n[1].value.raw,""):[]);return n.slice(1).forEach((t,a)=>{d[a].isDirectory&&v.forEach((i,o)=>{if(!t.tail){const t=e.join(p,i),s=r.readdirSync(t).filter(e=>e.endsWith(n[a+2].value.raw));v[o]=[i,s]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(t).unshiftContainer("body",s.variableDeclaration("var",[s.variableDeclarator(s.identifier(f),a(s,v,p,n[n.length-1].value.raw))])),void l.replaceWith(s.expressionStatement(d.reduce((e,r)=>s.memberExpression(e,s.identifier(r.name),!0),s.identifier(f))))}case"StringLiteral":u=h.node.value}if(void 0===u)throw new Error(`There was a problem evaluating the value of the argument for the code: ${l.getSource()}. If the value is dynamic, please make sure that its value is statically deterministic.`);const f=require.resolve(u,{paths:[c]}),d=r.readFileSync(f,{encoding:"utf-8"});l.replaceWith(s.expressionStatement(s.stringLiteral(d)))}({referencePath:t,state:i,babel:n,usageCounter:o})})});
//# sourceMappingURL=raw.macro.modern.js.map

@@ -1,2 +0,2 @@

!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){var e=require("path"),r=require("fs"),t=require("babel-plugin-macros");function a(t,n,i,o){void 0===o&&(o="");var l=n.map(function(n){if(Array.isArray(n))return t.objectProperty(t.stringLiteral(n[0]),a(t,n[1],e.join(i,n[0]),o));try{var l=o.startsWith(".")&&n.endsWith(o)?n:n+o,s=require.resolve(l,{paths:[i]});return t.objectProperty(t.stringLiteral(n.replace(o,"")),t.stringLiteral(r.readFileSync(s,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===l.length)throw new Error("Cannot resolve file "+o+" in these directories: "+n.join(", "));return t.objectExpression(l)}module.exports=(0,t.createMacro)(function(t){var n=t.state,i=t.babel,o={value:0};t.references.default.forEach(function(t){if("CallExpression"!==t.parentPath.type)throw new Error("This is not supported: `"+t.findParent(i.types.isExpression).getSource()+"`. Please see the raw.macro documentation");!function(t){var n,i=t.referencePath,o=t.usageCounter,l=t.babel.types,s=i.parentPath,u=e.dirname(t.state.file.opts.filename),c=s.get("arguments")[0];switch(c.node.type){case"TemplateLiteral":var f=c.node,h=f.expressions,v=f.quasis;if(0===h.length){n=v[0].value.raw;break}if(""===v[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(h.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");var d="__raw_dynamic__"+o.value;o.value++;var p=h.map(function(e,r){var t=r!==v.length-1&&c.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),m=e.join(u,v[0].value.raw),y=r.readdirSync(m).filter(function(t){try{return r.lstatSync(e.join(m,t)).isDirectory()===p[0].isDirectory}catch(e){return!1}}).flatMap(function(e){return p[0].isDirectory?e:e.endsWith(v[1].value.raw)?e.replace(v[1].value.raw,""):[]});return v.slice(1).forEach(function(t,a){p[a].isDirectory&&y.forEach(function(n,i){if(!t.tail){var o=e.join(m,n),l=r.readdirSync(o).filter(function(e){return e.endsWith(v[a+2].value.raw)});y[i]=[n,l]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(i).unshiftContainer("body",l.variableDeclaration("var",[l.variableDeclarator(l.identifier(d),a(l,y,m,v[v.length-1].value.raw))])),void s.replaceWith(l.expressionStatement(p.reduce(function(e,r){return l.memberExpression(e,l.identifier(r.name),!0)},l.identifier(d))));case"StringLiteral":n=c.node.value}if(void 0===n)throw new Error("There was a problem evaluating the value of the argument for the code: "+s.getSource()+". If the value is dynamic, please make sure that its value is statically deterministic.");var w=require.resolve(n,{paths:[u]}),g=r.readFileSync(w,{encoding:"utf-8"});s.replaceWith(l.expressionStatement(l.stringLiteral(g)))}({referencePath:t,state:n,babel:i,usageCounter:o})})})});
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){var e=require("path"),r=require("fs"),t=require("babel-plugin-macros");function a(t,n,i,o){void 0===o&&(o="");var l=n.map(function(n){if(Array.isArray(n))return t.objectProperty(t.stringLiteral(n[0]),a(t,n[1],e.join(i,n[0]),o));try{var l=o.startsWith(".")&&n.endsWith(o)?n:n+o,s=require.resolve("./"+l,{paths:[i]});return t.objectProperty(t.stringLiteral(n.replace(o,"")),t.stringLiteral(r.readFileSync(s,"utf-8")))}catch(e){return null}}).filter(Boolean);if(0===l.length)throw new Error("Cannot resolve file "+o+" in these directories: "+n.join(", "));return t.objectExpression(l)}module.exports=(0,t.createMacro)(function(t){var n=t.state,i=t.babel,o={value:0};t.references.default.forEach(function(t){if("CallExpression"!==t.parentPath.type)throw new Error("This is not supported: `"+t.findParent(i.types.isExpression).getSource()+"`. Please see the raw.macro documentation");!function(t){var n,i=t.referencePath,o=t.usageCounter,l=t.babel.types,s=i.parentPath,u=e.dirname(t.state.file.opts.filename),c=s.get("arguments")[0];switch(c.node.type){case"TemplateLiteral":var f=c.node,v=f.expressions,h=f.quasis;if(0===v.length){n=h[0].value.raw;break}try{if(void 0!==(n=s.get("arguments")[0].evaluate().value))break}catch(e){}if(""===h[0].value.raw)throw new Error("Invalid value, variable interpolation can't be at the start of template literal");if(v.length>2)throw new Error("Invalid value. You can only have 2 dynamic values max. 1 for directory name, 1 for file name.");var d="__raw_dynamic__"+o.value;o.value++;var p=v.map(function(e,r){var t=r!==h.length-1&&c.node.quasis[r+1].value.raw.startsWith("/");return{name:e.name,isDirectory:t}}),m=e.join(u,h[0].value.raw),y=r.readdirSync(m).filter(function(t){try{return r.lstatSync(e.join(m,t)).isDirectory()===p[0].isDirectory}catch(e){return!1}}).flatMap(function(e){return p[0].isDirectory?e:e.endsWith(h[1].value.raw)?e.replace(h[1].value.raw,""):[]});return h.slice(1).forEach(function(t,a){p[a].isDirectory&&y.forEach(function(n,i){if(!t.tail){var o=e.join(m,n),l=r.readdirSync(o).filter(function(e){return e.endsWith(h[a+2].value.raw)});y[i]=[n,l]}})}),function e(r){return r.parentPath?e(r.parentPath):r}(i).unshiftContainer("body",l.variableDeclaration("var",[l.variableDeclarator(l.identifier(d),a(l,y,m,h[h.length-1].value.raw))])),void s.replaceWith(l.expressionStatement(p.reduce(function(e,r){return l.memberExpression(e,l.identifier(r.name),!0)},l.identifier(d))));case"StringLiteral":n=c.node.value}if(void 0===n)throw new Error("There was a problem evaluating the value of the argument for the code: "+s.getSource()+". If the value is dynamic, please make sure that its value is statically deterministic.");var g=require.resolve(n,{paths:[u]}),w=r.readFileSync(g,{encoding:"utf-8"});s.replaceWith(l.expressionStatement(l.stringLiteral(w)))}({referencePath:t,state:n,babel:i,usageCounter:o})})})});
//# sourceMappingURL=raw.macro.umd.js.map
{
"name": "raw.macro",
"description": "Read file contents at build time, similar to webpack raw-loader",
"version": "0.4.1",
"version": "0.4.2",
"engines": {

@@ -6,0 +6,0 @@ "node": ">=8.9.0"

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc