react-code-locator 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/esbuild.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/swc.cjs +1 -1
- package/dist/swc.cjs.map +1 -1
- package/dist/swc.js +1 -1
- package/dist/swc.js.map +1 -1
- package/dist/unplugin.cjs +1 -1
- package/dist/unplugin.cjs.map +1 -1
- package/dist/unplugin.js +1 -1
- package/dist/unplugin.js.map +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.js +1 -1
- package/dist/webpack.js.map +1 -1
- package/package.json +1 -1
package/dist/esbuild.cjs
CHANGED
|
@@ -36,5 +36,5 @@ function _markReactElementSource(element, source) {
|
|
|
36
36
|
}
|
|
37
37
|
return element;
|
|
38
38
|
}
|
|
39
|
-
`;return Lr.parse(e,{ecmaVersion:"latest",sourceType:"module"}).body[0]}function Tn(e,i){return{type:"CallExpression",callee:{type:"Identifier",name:"_markReactElementSource"},arguments:[e,{type:"Literal",value:i}],optional:!1}}function Rr(e,i){let{filename:a,projectRoot:o=process.cwd(),injectJsxSource:h=!0,injectComponentSource:x=!0}=i,v;try{v=wn(a).parse(e,{ecmaVersion:"latest",sourceType:"module",locations:!0})}catch{return null}let k=!1,_=!1,l=new Set,M=[];if(Ar(v,{enter(z,Q){if(h&&z.type==="CallExpression"&&En(z)){let T=z.loc;T&&(this.replace(Tn(z,ji(a,T.start,o))),_=!0,k=!0)}if(x&&z.type==="FunctionDeclaration"){let T=z.id?.name;T&&Pr(T)&&!l.has(T)&&z.loc&&(M.push({node:z,parent:Q,assignment:Ir(T,ji(a,z.loc.start,o))}),l.add(T),k=!0)}if(x&&z.type==="VariableDeclarator"){let T=z.id;if(T.type==="Identifier"&&Pr(T.name)&&!l.has(T.name)){let I=z.init;if(I&&An(I)){let D=z.loc||I.loc;D&&(M.push({node:z,parent:Q,assignment:Ir(T.name,ji(a,D.start,o))}),l.add(T.name),k=!0)}}}}}),!k)return null;if(_){let z=_n();v.body.some(T=>T.type==="FunctionDeclaration"&&T.id?.name==="_markReactElementSource")||v.body.unshift(z)}for(let{node:z,parent:Q,assignment:T}of M.reverse())if(Q?.type==="Program"){let I=v.body.indexOf(z);I!==-1&&v.body.splice(I+1,0,T)}else if(Q?.type==="ExportNamedDeclaration"){let I=v.body.find(D=>D.type==="ExportNamedDeclaration"&&D.declaration===Q);I&&v.body.splice(v.body.indexOf(I)+1,0,T)}else Q?.type==="ExportDefaultDeclaration"&&v.body.splice(v.body.indexOf(Q)+1,0,T);return{code:kr(v,{generator:kn})}}function Pn(e){return e.endsWith(".tsx")?"tsx":e.endsWith(".ts")?"ts":e.endsWith(".jsx")?"jsx":"js"}function Or(e={}){let{projectRoot:i=process.cwd(),injectComponentSource:a=!0,injectJsxSource:o=!0}=e;return{name:"react-code-locator-source-transform",setup(h){h.onLoad({filter:/\.[mc]?[jt]sx?$/},async({path:x})=>{if(x.includes("/node_modules/"))return null;let v=await(0,Vr.readFile)(x,"utf8"),k=Rr(v,{filename:x,projectRoot:i,injectComponentSource:a,injectJsxSource:o});return{contents:k?k.code:v,loader:Pn(x)}})}}}function Dr(e={}){let i={projectRoot:process.cwd(),injectComponentSource:!0,injectJsxSource:!0,...e};return{kind:"esbuild",name:"react-code-locator/esbuild",options:i,config:{plugins:[Or(i)]}}}var In=Dr();0&&(module.exports={createEsbuildSourceAdapter,esbuildSourceAdapter,esbuildSourceTransformPlugin});
|
|
39
|
+
`;return Lr.parse(e,{ecmaVersion:"latest",sourceType:"module"}).body[0]}function Tn(e,i){return{type:"CallExpression",callee:{type:"Identifier",name:"_markReactElementSource"},arguments:[e,{type:"Literal",value:i}],optional:!1}}function Rr(e,i){let{filename:a,projectRoot:o=process.cwd(),injectJsxSource:h=!0,injectComponentSource:x=!0}=i,v;try{v=wn(a).parse(e,{ecmaVersion:"latest",sourceType:"module",locations:!0})}catch{return null}let k=!1,_=!1,l=new Set,M=[];if(Ar(v,{enter(z,Q){if(h&&z.type==="CallExpression"&&En(z)){let T=z.loc;T&&(this.replace(Tn(z,ji(a,T.start,o))),this.skip(),_=!0,k=!0)}if(x&&z.type==="FunctionDeclaration"){let T=z.id?.name;T&&Pr(T)&&!l.has(T)&&z.loc&&(M.push({node:z,parent:Q,assignment:Ir(T,ji(a,z.loc.start,o))}),l.add(T),k=!0)}if(x&&z.type==="VariableDeclarator"){let T=z.id;if(T.type==="Identifier"&&Pr(T.name)&&!l.has(T.name)){let I=z.init;if(I&&An(I)){let D=z.loc||I.loc;D&&(M.push({node:z,parent:Q,assignment:Ir(T.name,ji(a,D.start,o))}),l.add(T.name),k=!0)}}}}}),!k)return null;if(_){let z=_n();v.body.some(T=>T.type==="FunctionDeclaration"&&T.id?.name==="_markReactElementSource")||v.body.unshift(z)}for(let{node:z,parent:Q,assignment:T}of M.reverse())if(Q?.type==="Program"){let I=v.body.indexOf(z);I!==-1&&v.body.splice(I+1,0,T)}else if(Q?.type==="ExportNamedDeclaration"){let I=v.body.find(D=>D.type==="ExportNamedDeclaration"&&D.declaration===Q);I&&v.body.splice(v.body.indexOf(I)+1,0,T)}else Q?.type==="ExportDefaultDeclaration"&&v.body.splice(v.body.indexOf(Q)+1,0,T);return{code:kr(v,{generator:kn})}}function Pn(e){return e.endsWith(".tsx")?"tsx":e.endsWith(".ts")?"ts":e.endsWith(".jsx")?"jsx":"js"}function Or(e={}){let{projectRoot:i=process.cwd(),injectComponentSource:a=!0,injectJsxSource:o=!0}=e;return{name:"react-code-locator-source-transform",setup(h){h.onLoad({filter:/\.[mc]?[jt]sx?$/},async({path:x})=>{if(x.includes("/node_modules/"))return null;let v=await(0,Vr.readFile)(x,"utf8"),k=Rr(v,{filename:x,projectRoot:i,injectComponentSource:a,injectJsxSource:o});return{contents:k?k.code:v,loader:Pn(x)}})}}}function Dr(e={}){let i={projectRoot:process.cwd(),injectComponentSource:!0,injectJsxSource:!0,...e};return{kind:"esbuild",name:"react-code-locator/esbuild",options:i,config:{plugins:[Or(i)]}}}var In=Dr();0&&(module.exports={createEsbuildSourceAdapter,esbuildSourceAdapter,esbuildSourceTransformPlugin});
|
|
40
40
|
//# sourceMappingURL=esbuild.cjs.map
|