lxsmnsyc / solid-labels

Simple, reactive labels for SolidJS
MIT License
243 stars 8 forks source link

SyntaxError: Cannot use import statement outside a module #11

Closed idolf closed 1 year ago

idolf commented 1 year ago

Operating system: MacOS 13.0.1 arm64 Bundler: vite Bundler Version: 3.2.4 Node version: v18.11.0

Error Messages:

> labeldemo@0.0.0 dev /Users/xiaodeng/WebstormProjects/labeldemo
> vite

(node:8725) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
failed to load config from /Users/xiaodeng/WebstormProjects/labeldemo/vite.config.mjs
error when starting dev server:
/Users/xiaodeng/WebstormProjects/labeldemo/node_modules/.pnpm/registry.npmmirror.com+babel-plugin-solid-labels@0.12.1_sumpexkp2w6cfekvtfjnaia54m/node_modules/babel-plugin-solid-labels/dist/esm/production/index.js:1
var Ee=Object.defineProperty,be=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var te=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var re=(o,e,t)=>e in o?Ee(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,U=(o,e)=>{for(var t in e||(e={}))ye.call(e,t)&&re(o,t,e[t]);if(te)for(var t of te(e))Pe.call(e,t)&&re(o,t,e[t]);return o},oe=(o,e)=>be(o,ge(e));import*as d from"@babel/types";import{addNamed as Te}from"@babel/helper-module-imports";function x(o,e,t,r="solid-js"){let n=o.get(t);if(n)return n;let s=Te(e,t,r);return o.set(t,s),s}import*as P from"@babel/types";import*as ie from"@babel/types";import*as S from"@babel/types";function f(o,e,t){return o.buildCodeFrameError(`Unexpected '${e}' (Expected: ${t})`)}function $(o){return o.buildCodeFrameError("Unexpected missing parent.")}function N(o,e,t){return o.buildCodeFrameError(`Unexpected argument length of ${e} (Expected: ${t})`)}function ne(o,e,t){return o.buildCodeFrameError(`Unexpected assignment operator '${e}' (Expected: ${t})`)}import*as X from"@babel/types";function I(o,e,t){return{ObjectProperty(r){!(r.scope!==o.scope&&r.scope.hasOwnBinding(t.name))&&r.node.shorthand&&X.isIdentifier(r.node.key)&&r.node.key.name===t.name&&X.isIdentifier(r.node.value)&&r.node.value.name===t.name&&r.replaceWith(X.objectProperty(t,e))},Expression(r){X.isIdentifier(r.node)&&r.node.name===t.name&&!(r.scope!==o.scope&&r.scope.hasOwnBinding(t.name))&&r.replaceWith(e)}}}function z(o,e,t,r){let n=e.scope.path;n&&n.traverse(U({CallExpression(s){var i,m;if(!(s.scope!==e.scope&&s.scope.hasOwnBinding(t.name)||!S.isIdentifier(s.node.callee)||((m=(i=o.opts.disabled)==null?void 0:i.ctf)==null?void 0:m[s.node.callee.name])))switch(s.node.callee.name){case"$refMemo":if(!S.isIdentifier(s.node.arguments[0]))throw f(s,s.node.arguments[0].type,"Identifier");s.node.arguments[0].name===t.name&&s.replaceWith(r);break;case"$get":if(!S.isIdentifier(s.node.arguments[0]))throw f(s,s.node.arguments[0].type,"Identifier");s.node.arguments[0].name===t.name&&s.replaceWith(r);break;case"$getter":case"$property":if(!s.parentPath)throw $(s);if(!S.isObjectProperty(s.parent))throw f(s,s.parent.type,"ObjectProperty");if(!S.isIdentifier(s.node.arguments[0]))throw f(s,s.node.arguments[0].type,"Identifier");if(S.isPrivateName(s.parent.key))throw f(s,"PrivateName","Expression");s.node.arguments[0].name===t.name&&s.parentPath.replaceWith(S.objectMethod("get",s.parent.key,[],S.blockStatement([S.returnStatement(S.callExpression(r,[]))])));break;default:break}}},I(e,S.callExpression(r,[]),t)))}function v(o,e,t,r,n){let s=e.scope.generateUidIdentifier(t.name);e.node.id=s,e.node.init=ie.callExpression(x(o.hooks,e,r),n),z(o,e,t,s)}import*as se from"@babel/types";function R(o){return se.arrowFunctionExpression([],o)}function L(o,e,t,r,n){let s=R(r);o.opts.dev?n?v(o,e,t,"createMemo",[s,P.identifier("undefined"),P.callExpression(P.memberExpression(P.identifier("Object"),P.identifier("assign")),[P.objectExpression([P.objectProperty(P.identifier("name"),P.stringLiteral(t.name))]),n])]):v(o,e,t,"createMemo",[s,P.identifier("undefined"),P.objectExpression([P.objectProperty(P.identifier("name"),P.stringLiteral(t.name))])]):n?v(o,e,t,"createMemo",[s,P.identifier("undefined"),n]):v(o,e,t,"createMemo",[s])}import*as b from"@babel/types";import*as l from"@babel/types";function J(o,e,t,r,n){let s=e.scope.path;s&&s.traverse(oe(U({CallExpression(i){var m,y;if(!(i.scope!==e.scope&&i.scope.hasOwnBinding(t.name)||!l.isIdentifier(i.node.callee)||((y=(m=o.opts.disabled)==null?void 0:m.ctf)==null?void 0:y[i.node.callee.name])))switch(i.node.callee.name){case"$refSignal":if(!l.isIdentifier(i.node.arguments[0]))throw f(i,i.node.arguments[0].type,"Identifier");i.node.arguments[0].name===t.name&&i.replaceWith(l.arrayExpression([r,n]));break;case"$get":if(!l.isIdentifier(i.node.arguments[0]))throw f(i,i.node.arguments[0].type,"Identifier");i.node.arguments[0].name===t.name&&i.replaceWith(r);break;case"$set":if(!l.isIdentifier(i.node.arguments[0]))throw f(i,i.node.arguments[0].type,"Identifier");i.node.arguments[0].name===t.name&&i.replaceWith(n);break;case"$getter":if(!i.parentPath)throw $(i);if(!l.isObjectProperty(i.parent))throw f(i,i.parent.type,"ObjectProperty");if(!l.isIdentifier(i.node.arguments[0]))throw f(i,i.node.arguments[0].type,"Identifier");if(l.isPrivateName(i.parent.key))throw f(i,"PrivateName","Expression");i.node.arguments[0].name===t.name&&i.parentPath.replaceWith(l.objectMethod("get",i.parent.key,[],l.blockStatement([l.returnStatement(l.callExpression(r,[]))])));break;case"$setter":{if(!i.parentPath)throw $(i);if(!l.isObjectProperty(i.parent))throw f(i,i.parent.type,"ObjectProperty");if(!l.isIdentifier(i.node.arguments[0]))throw f(i,i.node.arguments[0].type,"Identifier");if(l.isPrivateName(i.parent.key))throw f(i,"PrivateName","Expression");let g=i.scope.generateUidIdentifier("value");i.node.arguments[0].name===t.name&&i.parentPath.replaceWith(l.objectMethod("set",i.parent.key,[g],l.blockStatement([l.returnStatement(l.callExpression(n,[l.arrowFunctionExpression([],g)]))])))}break;case"$property":{if(!i.parentPath)throw $(i);if(!l.isObjectProperty(i.parent))throw f(i,i.parent.type,"ObjectProperty");if(!l.isIdentifier(i.node.arguments[0]))throw f(i,i.node.arguments[0].type,"Identifier");if(l.isPrivateName(i.parent.key))throw f(i,"PrivateName","Expression");let g=i.scope.generateUidIdentifier("value");i.node.arguments[0].name===t.name&&(i.parentPath.replaceWith(l.objectMethod("get",i.parent.key,[],l.blockStatement([l.returnStatement(l.callExpression(r,[]))]))),i.parentPath.insertAfter(l.objectMethod("set",i.parent.key,[g],l.blockStatement([l.returnStatement(l.callExpression(n,[l.arrowFunctionExpression([],g)]))]))))}break;default:break}}},I(e,l.callExpression(r,[]),t)),{UpdateExpression(i){if(!(i.scope!==e.scope&&i.scope.hasOwnBinding(t.name))&&l.isIdentifier(i.node.argument)&&i.node.argument.name===t.name){let m=i.scope.generateUidIdentifier("current");i.node.prefix?i.replaceWith(l.callExpression(n,[l.arrowFunctionExpression([m],l.binaryExpression(i.node.operator==="++"?"+":"-",m,l.numericLiteral(1)))])):i.replaceWith(l.callExpression(l.arrowFunctionExpression([],l.blockStatement([l.variableDeclaration("const",[l.variableDeclarator(m,l.callExpression(r,[]))]),l.expressionStatement(l.callExpression(n,[l.arrowFunctionExpression([],l.binaryExpression(i.node.operator==="++"?"+":"-",m,l.numericLiteral(1)))])),l.returnStatement(m)])),[]))}},AssignmentExpression(i){if(i.scope!==e.scope&&i.scope.hasOwnBinding(t.name))return;let m=i.node.left,y=i.node.right;if(l.isIdentifier(m)&&m.name===t.name)if(i.node.operator==="=")i.replaceWith(l.callExpression(n,[l.arrowFunctionExpression([],y)]));else{let g=i.scope.generateUidIdentifier("current");i.replaceWith(l.callExpression(n,[l.arrowFunctionExpression([g],l.assignmentExpression(i.node.operator,g,y))]))}}}))}function B(o,e,t,r,n){let s=e.scope.generateUidIdentifier(t.name),i=e.scope.generateUidIdentifier(`set${t.name}`);e.node.id=b.arrayPattern([s,i]),o.opts.dev?n?e.node.init=b.callExpression(x(o.hooks,e,"createSignal"),[r,b.callExpression(b.memberExpression(b.identifier("Object"),b.identifier("assign")),[b.objectExpression([b.objectProperty(b.identifier("name"),b.stringLiteral(t.name))]),n])]):e.node.init=b.callExpression(x(o.hooks,e,"createSignal"),[r,b.objectExpression([b.objectProperty(b.identifier("name"),b.stringLiteral(t.name))])]):n?e.node.init=b.callExpression(x(o.hooks,e,"createSignal"),[r,n]):e.node.init=b.callExpression(x(o.hooks,e,"createSignal"),[r]),J(o,e,t,s,i)}import*as T from"@babel/types";function H(o,e,t,r=T.identifier("undefined"),n){let s=R(r);o.opts.dev?n?v(o,e,t,"createDeferred",[s,T.callExpression(T.memberExpression(T.identifier("Object"),T.identifier("assign")),[T.objectExpression([T.objectProperty(T.identifier("name"),T.stringLiteral(t.name))]),n])]):v(o,e,t,"createDeferred",[s,T.objectExpression([T.objectProperty(T.identifier("name"),T.stringLiteral(t.name))])]):n?v(o,e,t,"createDeferred",[s,n]):v(o,e,t,"createDeferred",[s])}import*as a from"@babel/types";function D(o,e,t,r,n=!0,s){let i=e.scope.generateUidIdentifier("other"),m=[],y;if(a.isObjectPattern(r))for(let V=0,C=r.properties.length;V<C;V+=1){let u=r.properties[V];if(a.isObjectProperty(u)){let{value:w,key:k}=u;if(!u.computed)a.isIdentifier(k)&&m.push(a.stringLiteral(k.name));else{if(a.isPrivateName(k))throw f(e,"PrivateName","Expression");m.push(k)}let O=e.scope.generateUidIdentifier("prop"),W=a.memberExpression(t,k,u.computed),F;if(a.isAssignmentPattern(w)){F=e.scope.generateUidIdentifier("def"),e.insertBefore(a.variableDeclarator(F,a.callExpression(x(o.hooks,e,"createMemo"),[a.arrowFunctionExpression([],w.right)])));let Q=e.scope.generateUidIdentifier("value");W=a.blockStatement([a.variableDeclaration("const",[a.variableDeclarator(Q,W)]),a.returnStatement(a.conditionalExpression(a.binaryExpression("==",Q,a.nullLiteral()),a.callExpression(F,[]),Q))])}if(e.insertBefore(a.variableDeclarator(O,a.arrowFunctionExpression([],W))),a.isObjectPattern(w)||a.isArrayPattern(w))D(o,e,a.callExpression(O,[]),w,!1);else if(a.isIdentifier(w))e.scope.path.traverse(I(e.scope.path,a.callExpression(O,[]),w));else if(a.isAssignmentPattern(w))a.isIdentifier(w.left)?e.scope.path.traverse(I(e.scope.path,a.callExpression(O,[]),w.left)):(a.isArrayPattern(w.left)||a.isObjectPattern(w.left))&&D(o,e,a.callExpression(O,[]),w.left,!1,F);else throw f(e,w.type,"Identifier | ObjectPattern | ArrayPattern")}else a.isIdentifier(u.argument)&&(y=u.argument)}else for(let V=0,C=r.elements.length;V<C;V+=1){let u=r.elements[V];if(u){let w=a.numericLiteral(V),k=e.scope.generateUidIdentifier("prop"),O=a.memberExpression(t,w,!0),W;if(a.isAssignmentPattern(u)){W=e.scope.generateUidIdentifier("def"),e.insertBefore(a.variableDeclarator(W,a.callExpression(x(o.hooks,e,"createMemo"),[a.arrowFunctionExpression([],u.right)])));let F=e.scope.generateUidIdentifier("value");O=a.blockStatement([a.variableDeclaration("const",[a.variableDeclarator(F,O)]),a.returnStatement(a.conditionalExpression(a.binaryExpression("==",F,a.nullLiteral()),a.callExpression(W,[]),F))])}e.insertBefore(a.variableDeclarator(k,a.arrowFunctionExpression([],O))),m.push(w),a.isIdentifier(u)?e.scope.path.traverse(I(e.scope.path,a.callExpression(k,[]),u)):a.isAssignmentPattern(u)?a.isIdentifier(u.left)?e.scope.path.traverse(I(e.scope.path,a.callExpression(k,[]),u.left)):(a.isArrayPattern(u.left)||a.isObjectPattern(u.left))&&D(o,e,a.callExpression(k,[]),u.left,!1,W):a.isArrayPattern(u)||a.isObjectPattern(u)?D(o,e,a.callExpression(k,[]),u,!1):a.isRestElement(u)&&a.isIdentifier(u.argument)&&(y=u.argument)}}let g=a.variableDeclarator(i,m.length?a.memberExpression(a.callExpression(x(o.hooks,e,"splitProps"),[s!=null?a.callExpression(x(o.hooks,e,"mergeProps"),[t,s]):t,a.arrayExpression(m)]),a.numericLiteral(1),!0):t);n?e.replaceWith(g):e.insertAfter(g),y&&e.scope.path.traverse(I(e.scope.path,i,y))}function q(o){return(e,t)=>{let{body:r}=t.node;if(d.isExpressionStatement(r)){if(d.isAssignmentExpression(r.expression)){if(r.expression.operator!=="=")throw ne(t,r.expression.operator,"=");let n=r.expression.left,s=r.expression.right;if(!d.isIdentifier(n))throw f(t,n.type,"Identifier");t.replaceWith(d.variableDeclaration("const",[d.variableDeclarator(n,s)]))}else if(d.isIdentifier(r.expression))t.replaceWith(d.variableDeclaration("const",[d.variableDeclarator(r.expression)]));else if(d.isSequenceExpression(r.expression)){let n=[];for(let s=0,i=r.expression.expressions.length;s<i;s+=1){let m=r.expression.expressions[s];if(d.isIdentifier(m))n.push(d.variableDeclarator(m));else if(d.isAssignmentExpression(m)){if(m.operator!=="=")throw new Error("Invalid assignment expression operator");let y=m.left,g=m.right;if(!d.isIdentifier(y))throw f(t,y.type,"Identifier");t.replaceWith(d.variableDeclarator(y,g))}else throw f(t,m.type,"Identifier | AssignmentExpression")}t.replaceWith(d.variableDeclaration("const",n))}}if(d.isVariableDeclaration(r)&&(r.kind="const",t.replaceWith(r)),d.isVariableDeclaration(t.node))t.traverse({VariableDeclarator(n){if(n.parentPath===t){let s=n.node.id,i=n.node.init;o(e,n,s,i)}}});else throw f(t,t.node.type,"VariableDeclaration")}}function Se(o,e){let{body:t}=e.node;d.isExpressionStatement(t)?e.replaceWith(d.callExpression(x(o.hooks,e,"createEffect"),[d.arrowFunctionExpression([],t.expression)])):d.isBlockStatement(t)?e.replaceWith(d.callExpression(x(o.hooks,e,"createEffect"),[d.arrowFunctionExpression([],t)])):d.isVariableDeclaration(t)&&(t.kind="const",e.replaceWith(t),e.traverse({VariableDeclarator(r){let n=r.node.id,s=r.node.init;d.isIdentifier(n)&&L(o,r,n,s!=null?s:d.identifier("undefined"))}}))}function A(o,e=!1){return function(r,n){let{body:s}=n.node,i,m;if(e&&d.isLabeledStatement(s)&&(i=s.label.name,s=s.body),d.isBlockStatement(s))m=d.arrowFunctionExpression([],s);else if(d.isExpressionStatement(s))m=s.expression;else throw f(n,s.type,"BlockStatement | ExpressionStatement");i?n.replaceWith(d.callExpression(x(r.hooks,n,o),[m,d.identifier("undefined"),d.objectExpression([d.objectProperty(d.identifier("name"),d.stringLiteral(i))])])):n.replaceWith(d.callExpression(x(r.hooks,n,o),[m]))}}var ae={$:Se,signal:q((o,e,t,r)=>{d.isIdentifier(t)&&B(o,e,t,r!=null?r:d.identifier("undefined"))}),memo:q((o,e,t,r)=>{d.isIdentifier(t)&&L(o,e,t,r!=null?r:d.identifier("undefined"))}),deferred:q((o,e,t,r)=>{d.isIdentifier(t)&&H(o,e,t,r!=null?r:d.identifier("undefined"))}),destructure:q((o,e,t,r)=>{(d.isObjectPattern(t)||d.isArrayPattern(t))&&r&&D(o,e,r,t)}),children:q((o,e,t,r)=>{d.isIdentifier(t)&&v(o,e,t,"children",[d.arrowFunctionExpression([],r!=null?r:d.identifier("undefined"))])}),effect:A("createEffect",!0),computed:A("createComputed",!0),renderEffect:A("createRenderEffect",!0),mount:A("onMount"),cleanup:A("onCleanup"),error:A("onError"),root:A("createRoot"),untrack:A("untrack"),batch:A("batch"),transition:A("startTransition")},ve={LabeledStatement(o,e){var t,r;o.node.label.name in ae&&!((r=(t=e.opts.disabled)==null?void 0:t.labels)!=null&&r[o.node.label.name])&&ae[o.node.label.name](e,o)}},le=ve;import*as p from"@babel/types";function we(o,e){e.traverse({VariableDeclarator(t){if(t.parentPath===e){let r=t.node.id,n=t.node.init;p.isIdentifier(r)&&B(o,t,r,n!=null?n:p.identifier("undefined"))}}})}function $e(o,e){e.traverse({VariableDeclarator(t){if(t.parentPath===e){let r=t.node.id,n=t.node.init;p.isIdentifier(r)&&L(o,t,r,n!=null?n:p.identifier("undefined"))}}})}function he(o,e){e.traverse({VariableDeclarator(t){if(t.parentPath===e){let r=t.node.id,n=t.node.init;(p.isObjectPattern(r)||p.isArrayPattern(r))&&n&&D(o,t,n,r)}}})}function Ve(o,e){e.traverse({VariableDeclarator(t){if(t.parentPath===e){let r=t.node.id,n=t.node.init;p.isIdentifier(r)&&H(o,t,r,n!=null?n:p.identifier("undefined"))}}})}function Ne(o,e){e.traverse({VariableDeclarator(t){if(t.parentPath===e){let r=t.node.id,n=t.node.init;p.isIdentifier(r)&&v(o,t,r,"children",[p.arrowFunctionExpression([],n!=null?n:p.identifier("undefined"))])}}})}function j(o,e=!1){return function(r,n,s){let i=n.node,m;p.isBlockStatement(i)?m=p.arrowFunctionExpression([],i):m=i.expression,e&&s?n.replaceWith(p.callExpression(x(r.hooks,n,o),[m,p.identifier("undefined"),p.objectExpression([p.objectProperty(p.identifier("name"),p.stringLiteral(s))])])):n.replaceWith(p.callExpression(x(r.hooks,n,o),[m]))}}var ce={"@signal":we,"@memo":$e,"@children":Ne,"@deferred":Ve,"@destructure":he},K={"@effect":j("createEffect",!0),"@computed":j("createComputed",!0),"@renderEffect":j("createRenderEffect",!0),"@mount":j("onMount"),"@cleanup":j("onCleanup"),"@error":j("onError"),"@root":j("createRoot"),"@untrack":j("untrack"),"@batch":j("batch"),"@transition":j("startTransition")},ke={VariableDeclaration(o,e){var r,n;let t=o.node.leadingComments;if(t){let s;for(let i=0,m=t.length;i<m;i+=1){let y=t[i],g=y.value.trim();g in ce&&!((n=(r=e.opts.disabled)==null?void 0:r.pragma)!=null&&n[g])&&(s=g,y.value="")}s&&ce[s](e,o)}},BlockStatement(o,e){var r,n;if(p.isFunctionDeclaration(o.parent))return;let t=o.node.leadingComments;if(t){let s,i;for(let m=0,y=t.length;m<y;m+=1){let g=t[m],V=g.value.trim();if(/^@\w+( .*)?$/.test(V)){let[C,...u]=V.split(" ");C in K&&!((n=(r=e.opts.disabled)==null?void 0:r.pragma)!=null&&n[V])&&(s=C,i=u.join(" "),g.value="")}}s&&K[s](e,o,i)}},ExpressionStatement(o,e){var r,n;let t=o.node.leadingComments;if(t){let s,i;for(let m=0,y=t.length;m<y;m+=1){let g=t[m],V=g.value.trim();if(/^@\w+( .*)?$/.test(V)){let[C,...u]=V.split(" ");C in K&&!((n=(r=e.opts.disabled)==null?void 0:r.pragma)!=null&&n[V])&&(s=C,i=u.join(" "),g.value="")}}s&&K[s](e,o,i)}}},de=ke;import*as c from"@babel/types";import*as fe from"@babel/types";function Y(o,e,t,r){let n=e.scope.generateUidIdentifier(t.name),s=e.scope.generateUidIdentifier(`set${t.name}`);e.node.id=fe.arrayPattern([n,s]),e.node.init=r,J(o,e,t,n,s)}function Z(o,e,t,r){let n=e.scope.generateUidIdentifier(t.name);e.node.id=n,e.node.init=r,z(o,e,t,n)}function Ie(o,e){if(e.node.arguments.length>1)throw N(e,e.node.arguments.length,1);let t=e.node.arguments[0];if(!c.isExpression(t))throw f(e,t.type,"Expression");if(!e.parentPath)throw $(e);if(!c.isVariableDeclarator(e.parent))throw f(e.parentPath,e.parent.type,"VariableDeclarator");let r=e.parent.id;if(!c.isIdentifier(r))throw f(e.parentPath,r.type,"Identifier");Y(o,e.parentPath,r,t)}function De(o,e){if(e.node.arguments.length>2)throw N(e,e.node.arguments.length,2);let t,r;if(e.node.arguments.length>0){let s=e.node.arguments[0];if(!c.isExpression(s))throw f(e,s.type,"Expression");if(t=s,e.node.arguments.length>1){let i=e.node.arguments[1];if(!c.isExpression(i))throw f(e,i.type,"Expression");r=i}}if(!e.parentPath)throw $(e);if(!c.isVariableDeclarator(e.parent))throw f(e.parentPath,e.parent.type,"VariableDeclarator");let n=e.parent.id;if(!c.isIdentifier(n))throw f(e.parentPath,n.type,"Identifier");B(o,e.parentPath,n,t!=null?t:c.identifier("undefined"),r)}function Ae(o,e){if(e.node.arguments.length>1)throw N(e,e.node.arguments.length,1);let t=e.node.arguments[0];if(!c.isExpression(t))throw f(e,t.type,"Expression");if(!e.parentPath)throw $(e);if(!c.isVariableDeclarator(e.parent))throw f(e.parentPath,e.parent.type,"VariableDeclarator");let r=e.parent.id;if(!c.isIdentifier(r))throw f(e.parentPath,r.type,"Expression");Z(o,e.parentPath,r,t)}function je(o,e){if(e.node.arguments.length>2)throw N(e,e.node.arguments.length,2);let t=e.node.arguments[0];if(!c.isExpression(t))throw f(e,t.type,"Expression");let r;if(e.node.arguments.length>1){let s=e.node.arguments[1];if(!c.isExpression(s))throw f(e,s.type,"Expression");r=s}if(!e.parentPath)throw $(e);if(!c.isVariableDeclarator(e.parent))throw f(e.parentPath,e.parent.type,"VariableDeclarator");let n=e.parent.id;if(!c.isIdentifier(n))throw f(e.parentPath,n.type,"Expression");L(o,e.parentPath,n,t,r)}function Ce(o,e){if(e.node.arguments.length>2)throw N(e,e.node.arguments.length,2);let t,r;if(e.node.arguments.length>0){let s=e.node.arguments[0];if(!c.isExpression(s))throw f(e,s.type,"Expression");if(t=s,e.node.arguments.length>1){let i=e.node.arguments[1];if(!c.isExpression(i))throw f(e,i.type,"Expression");r=i}}if(!e.parentPath)throw $(e);if(!c.isVariableDeclarator(e.parent))throw f(e.parentPath,e.parent.type,"VariableDeclarator");let n=e.parent.id;if(!c.isIdentifier(n))throw f(e,n.type,"Identifier");H(o,e.parentPath,n,t,r)}function Oe(o,e){if(e.node.arguments.length>1)throw N(e,e.node.arguments.length,1);let t=e.node.arguments[0];if(!c.isExpression(t))throw f(e,t.type,"Expression");if(!e.parentPath)throw $(e);if(c.isVariableDeclarator(e.parent)){let r=e.parent.id;if(!c.isIdentifier(r))throw f(e,r.type,"Identifier");L(o,e.parentPath,r,t)}else if(c.isExpressionStatement(e.parent))e.replaceWith(c.callExpression(x(o.hooks,e,"createEffect"),[c.arrowFunctionExpression([],t)]));else throw f(e.parentPath,e.parent.type,"VariableDeclarator | ExpressionStatement")}function Ue(o,e){if(e.node.arguments.length>1)throw N(e,e.node.arguments.length,1);let t=e.node.arguments[0];if(!c.isExpression(t))throw f(e,t.type,"Expression");if(!e.parentPath)throw $(e);let r=c.isArrowFunctionExpression(t)||c.isFunctionExpression(t)?t:c.arrowFunctionExpression([],t);e.replaceWith(c.callExpression(x(o.hooks,e,"createRoot"),[r]))}function Le(o,e){if(e.node.arguments.length>1)throw N(e,e.node.arguments.length,1);let t=e.node.arguments[0];if(!c.isExpression(t))throw f(e,t.type,"Expression");if(!e.parentPath)throw $(e);if(!c.isVariableDeclarator(e.parent))throw f(e.parentPath,e.parent.type,"VariableDeclarator");let r=e.parent.id;if(!c.isIdentifier(r))throw f(e,r.type,"Identifier");v(o,e.parentPath,r,"from",[t])}function ee(o,e){return(t,r)=>{if(r.node.arguments.length>e)throw N(r,r.node.arguments.length,e);let[n,...s]=r.node.arguments;if(!c.isExpression(n))throw f(r,n.type,"Expression");if(!r.parentPath)throw $(r);if(!c.isVariableDeclarator(r.parent))throw f(r.parentPath,r.parent.type,"VariableDeclarator");let i=r.parent.id;if(!c.isIdentifier(i))throw f(r,i.type,"Identifier");v(t,r.parentPath,i,o,[R(n),...s])}}function h(o,e){return(t,r)=>{r.node.callee=x(t.hooks,r,o,e)}}function _(o,e){return(t,r)=>{if(r.node.arguments.length>e)throw N(r,r.node.arguments.length,e);let[n,...s]=r.node.arguments;if(!c.isExpression(n))throw f(r,n.type,"Expression");r.replaceWith(c.callExpression(x(t.hooks,r,o),[R(n),...s]))}}function Me(o,e){if(e.node.arguments.length>1)throw N(e,e.node.arguments.length,1);let t=e.node.arguments[0];if(!c.isExpression(t))throw f(e,t.type,"Expression");if(!e.parentPath)throw $(e);if(!c.isVariableDeclarator(e.parent))throw f(e.parentPath,e.parent.type,"VariableDeclarator");let r=e.parent.id;if(!(c.isObjectPattern(r)||c.isArrayPattern(r)))throw f(e,r.type,"ArrayPattern | ObjectPattern");D(o,e.parentPath,t,r)}function We(o,e){if(e.node.arguments.length>1)throw N(e,e.node.arguments.length,1);let t=e.node.arguments[0];if(!c.isFunctionExpression(t)&&!c.isArrowFunctionExpression(t))throw f(e,t.type,"FunctionExpression | ArrowFunctionExpression");if(t.params.length>0){let r=t.params[0];if(c.isObjectPattern(r)){let n=e.scope.generateUidIdentifier("props");t.params[0]=n;let s=c.variableDeclaration("const",[c.variableDeclarator(r,c.callExpression(c.identifier("$destructure"),[n]))]);c.isExpression(t.body)?t.body=c.blockStatement([s,c.returnStatement(t.body)]):t.body.body.unshift(s)}}e.replaceWith(t)}var me={$:Oe,$derefSignal:Ie,$derefMemo:Ae,$signal:De,$memo:je,$root:Ue,$from:Le,$deferred:Ce,$children:ee("children",1),$mapArray:ee("mapArray",3),$indexArray:ee("indexArray",3),$lazy:_("lazy",1),$untrack:_("untrack",1),$batch:_("batch",1),$observable:_("observable",1),$selector:_("createSelector",1),$on:_("on",3),$useContext:h("useContext"),$createContext:h("createContext"),$uid:h("createUniqueId"),$effect:h("createEffect"),$computed:h("createComputed"),$renderEffect:h("createRenderEffect"),$merge:h("mergeProps"),$resource:h("createResource"),$cleanup:h("onCleanup"),$mount:h("onMount"),$error:h("onError"),$reaction:h("createReaction"),$store:h("createStore","solid-js/store"),$mutable:h("createMutable","solid-js/store"),$produce:h("produce","solid-js/store"),$reconcile:h("reconcile","solid-js/store"),$unwrap:h("unwrap","solid-js/store"),$destructure:Me,$component:We},Fe={CallExpression(o,e){var t,r;c.isIdentifier(o.node.callee)&&o.node.callee.name in me&&!o.scope.hasBinding(o.node.callee.name)&&!((r=(t=e.opts.disabled)==null?void 0:t.ctf)!=null&&r[o.node.callee.name])&&me[o.node.callee.name](e,o)}},pe=Fe;import*as M from"@babel/types";function E(o,e){return(t,r)=>x(t.hooks,r,o,e)}var G={$for:E("For"),$show:E("Show"),$switch:E("Switch"),$match:E("Match"),$index:E("Index"),$errorBoundary:E("ErrorBoundary"),$suspense:E("Suspense"),$suspenseList:E("SuspenseList"),$dynamic:E("Dynamic","solid-js/web"),$portal:E("Portal","solid-js/web"),$assets:E("Assets","solid-js/web"),$hydrationScript:E("HydrationScript","solid-js/web"),$noHydration:E("NoHydration","solid-js/web")},Re="solid",ue={for:E("For"),switch:E("Switch"),match:E("Match"),show:E("Show"),index:E("Index"),"error-boundary":E("ErrorBoundary"),suspense:E("Suspense"),"suspense-list":E("SuspenseList"),dynamic:E("Dynamic","solid-js/web"),portal:E("Portal","solid-js/web"),assets:E("Assets","solid-js/web"),"hydration-script":E("HydrationScript","solid-js/web"),"no-hydration":E("NoHydration","solid-js/web")},Be={Expression(o,e){M.isIdentifier(o.node)&&!o.scope.hasBinding(o.node.name)&&o.node.name in G&&o.replaceWith(G[o.node.name](e,o))},JSXElement(o,e){let{openingElement:t,closingElement:r}=o.node,n=t.name,s;M.isJSXNamespacedName(n)&&n.namespace.name===Re&&n.name.name in ue&&(s=M.jsxIdentifier(ue[n.name.name](e,o).name)),M.isJSXIdentifier(n)&&!o.scope.hasBinding(n.name)&&n.name in G&&(s=M.jsxIdentifier(G[n.name](e,o).name)),s&&(t.name=s,r&&(r.name=s))}},xe=Be;var He=U(U(U(U({},le),de),pe),xe);function Xe(){return{pre(){this.hooks=new Map},visitor:{Program(o,e){o.traverse(He,e),o.scope.crawl()}}}}export{Xe as default};
                                                                                                                                                                                                                                                                                                                                                                                                                                                              ^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1088:15)
    at Module._compile (node:internal/modules/cjs/loader:1123:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
 ELIFECYCLE  Command failed with exit code 1.

vite.config.js

// vite.config.js
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import solidLabels from 'babel-plugin-solid-labels';

export default defineConfig({
    plugins: [
        solidPlugin({
            babel: {
                plugins: [
                    [solidLabels, { dev: process.env.NODE_ENV !== 'production' }]
                ],
            },
        }),
    ],
});
lxsmnsyc commented 1 year ago

Seems like I haven't added the "type": "module" yet. I'll be making a minor release.

lxsmnsyc commented 1 year ago

Should be fixed in 0.13