UNPKG

jotai

Version:

👻 Primitive and flexible state management for React

5 lines (4 loc) • 1.84 kB
System.register(["@babel/core","@babel/template"],(function(m){"use strict";var r;return{setters:[null,function(o){r=o.default}],execute:(function(){m("default",u);function o(t,i,e=[]){const n=[...c,...e];if(t.isIdentifier(i)&&n.includes(i.name))return!0;if(t.isMemberExpression(i)){const{property:a}=i;if(t.isIdentifier(a)&&n.includes(a.name))return!0}return!1}const c=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],d=r.default||r;function u({types:t},i){return console.warn("[DEPRECATED] jotai/babel/plugin-debug-label is deprecated and will be removed in v3.\nPlease use the `jotai-babel` package instead: https://github.com/jotaijs/jotai-babel"),{visitor:{ExportDefaultDeclaration(e,n){const{node:a}=e;if(t.isCallExpression(a.declaration)&&o(t,a.declaration.callee,i==null?void 0:i.customAtomNames)){const s=(n.filename||"unknown").replace(/\.\w+$/,"");let l=s.split("/").pop();l==="index"&&(l=s.slice(0,-6).split("/").pop()||"unknown");const f=d(` const %%atomIdentifier%% = %%atom%%; export default %%atomIdentifier%% `)({atomIdentifier:t.identifier(l),atom:a.declaration});e.replaceWithMultiple(f)}},VariableDeclarator(e){t.isIdentifier(e.node.id)&&t.isCallExpression(e.node.init)&&o(t,e.node.init.callee,i==null?void 0:i.customAtomNames)&&e.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(e.node.id.name),t.identifier("debugLabel")),t.stringLiteral(e.node.id.name))))}}}}})}}));