/node_modules/tsm/loader.mjs:1
import{existsSync as S,promises as j}from"fs";import{fileURLToPath as p,URL as g}from"url";import*as d from"./utils.js";let u,m,l=d.$defaults("esm"),x=l.file&&import("file:///"+l.file);async function y(){let t=await x;return t=t&&t.default||t,d.$finalize(l,t)}const w=/\.\w+(?=\?|$)/,h=/\.[mc]?tsx?(?=\?|$)/,T=/\.([mc])?js$/;async function f(t){u=u||await y();let[r]=w.exec(t)||[];return u[r]}function c(t){let r=p(t);if(S(r))return t}const b=new g("file:///"+process.cwd()+"/");export const resolve=async function(t,r,e){if(/^\w+\:?/.test(t))return e(t,r,e);let o,a,n,s,i=new g(t,r.parentURL||b);if(o=w.exec(i.href)){if(n=o[0],!r.parentURL||h.test(n))return{url:i.href};if(s=c(i.href),s)return{url:s};if(T.test(n)&&h.test(r.parentURL))return s=i.href.substring(0,a=o.index),(s=c(s+n.replace("js","ts")))?(a+=n.length,a>i.href.length&&(s+=i.href.substring(a)),{url:s}):e(t,r,e)}u=u||await y();for(n in u)if(s=c(i.href+n),s)return{url:s};return e(t,r,e)},load=async function(t,r,e){let o=await f(t);if(o==null)return e(t,r,e);let a=o.format==="cjs"?"commonjs":"module",n=p(t),s=await j.readFile(n);m=m||await import("esbuild");let i=await m.transform(s.toString(),{...o,sourcefile:n,format:a==="module"?"esm":"cjs"});return{format:a,source:i.code}},getFormat=async function(t,r,e){let o=await f(t);return o==null?e(t,r,e):{format:o.format==="cjs"?"commonjs":"module"}},transformSource=async function(t,r,e){let o=await f(r.url);return o==null?e(t,r,e):(m=m||await import("esbuild"),{source:(await m.transform(t.toString(),{...o,sourcefile:r.url,format:r.format==="module"?"esm":"cjs"})).code})};
^
TypeError: d.$defaults is not a function...
and I'm wondering if I am missing some setup or something wrong with my local env.
What would help me troubleshoot is if either there was an example repo or if there was a command like tsm --init for creating any boilerplate. I appreciate there might not be any boilerplate but even then would be good to have that validated by the example. So that I'm not second guessing things like "do I need tsconfig.json?"
Node 14.15.0 was the first LTS release of the 14.x cycle. Whatever is going on in 14.6 wasn't kept and is not the way forward. Strongly recommend upgrading, especially since all of 13.x and early 14.x was all about finalizing the ESM imports/exports resolution.
Getting this error
and I'm wondering if I am missing some setup or something wrong with my local env.
What would help me troubleshoot is if either there was an example repo or if there was a command like
tsm --init
for creating any boilerplate. I appreciate there might not be any boilerplate but even then would be good to have that validated by the example. So that I'm not second guessing things like "do I need tsconfig.json?"