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

@esbuild-kit/esm-loader

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esbuild-kit/esm-loader - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

2

dist/index.js

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

import{installSourceMapSupport as p,transform as u}from"@esbuild-kit/core-utils";import _ from"get-tsconfig";import{init as h,parse as D}from"es-module-lexer";import{fileURLToPath as W}from"url";import $ from"fs";const a=/\.([cm]?ts|[tj]sx)$/;let w=!1;h.then(()=>{w=!0});const j=t=>{const[o,r]=D(t);return o.length>0||r.length>0};function y(t){return w?j(t):h.then(()=>j(t))}var U=Object.defineProperty,v=Object.defineProperties,N=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,O=(t,o,r)=>o in t?U(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r,c=(t,o)=>{for(var r in o||(o={}))b.call(o,r)&&O(t,r,o[r]);if(g)for(var r of g(o))F.call(o,r)&&O(t,r,o[r]);return t},m=(t,o)=>v(t,N(o));const L=p(),P=_(),R=P==null?void 0:P.config,T=/\.\w+$/,l=[".js",".json",".ts",".tsx",".jsx"],I=[...l,...l.map(t=>`/index${t}`)],i=async function(t,o,r){if(t.startsWith("node:")&&(t=t.slice(5)),t.endsWith("/"))return i(`${t}index`,o,r);if(/\.[cm]js$/.test(t)&&a.test(o.parentURL))try{return await i(`${t.slice(0,-2)}ts`,o,r)}catch(s){if(s.code!=="ERR_MODULE_NOT_FOUND")throw s}if(a.test(t))return m(c({},await r(t,o,r)),{format:"module"});if(t.endsWith(".json"))return m(c({},await r(t,o,r)),{format:"json"});try{const s=await r(t,o,r);return t.endsWith(".js")&&s.format==="commonjs"&&(s.format="module"),s}catch(s){if(s instanceof Error){if(s.code==="ERR_UNSUPPORTED_DIR_IMPORT")return i(`${t}/index`,o,r);if(s.code==="ERR_MODULE_NOT_FOUND"&&!T.test(t))for(const n of I)try{const e=t+(t.endsWith("/")&&n.startsWith("/")?n.slice(1):n);return m(c({},await r(e,o,r)),{format:n===".json"?"json":"module"})}catch{}}throw s}},M=async function(t,o,r){process.send&&process.send({type:"dependency",path:t}),t.endsWith(".json")&&(o.importAssertions||(o.importAssertions={}),o.importAssertions.type="json");const s=await r(t,o,r);if(!s.source||t.includes("/node_modules/"))return s;const n=s.source.toString();if(s.format==="json"||a.test(t)){const e=await u(n,t,{format:"esm",tsconfigRaw:R});return e.map&&L.set(t,e.map),{format:"module",source:e.code}}return await y(n)||(s.format="commonjs"),s},E=_(),x=E==null?void 0:E.config,A=p(),V=async function(t,o,r){if(t.endsWith(".json"))return{format:"module"};if(a.test(t))return{format:"module"};const s=await r(t,o,r);if(t.endsWith(".js")&&(s.format==="commonjs"||s.format==="module")){const n=W(t),e=await $.promises.readFile(n,"utf8");s.format=await y(e)?"module":"commonjs"}return s},q=async function(t,o,r){const{url:s}=o;if(process.send&&process.send({type:"dependency",path:s}),s.endsWith(".json")||a.test(s)){const n=await u(t.toString(),s,{format:"esm",tsconfigRaw:x});return n.map&&A.set(s,n.map),{source:n.code}}return r(t,o,r)},f=[16,12,0],d=process.version.slice(1).split(".").map(Number),S=(d[0]-f[0]||d[1]-f[1]||d[2]-f[2])<0,z=S?V:void 0,B=S?q:void 0;export{z as getFormat,M as load,i as resolve,B as transformSource};
import{installSourceMapSupport as d,transform as u,transformDynamicImport as g}from"@esbuild-kit/core-utils";import w from"get-tsconfig";import J from"path";import{init as $}from"es-module-lexer";import _ from"fs";import{fileURLToPath as N}from"url";const c=/\.([cm]?ts|[tj]sx)$/,y=t=>{const n=J.extname(t);if(n===".mts")return"module";if(n===".cts")return"commonjs"};$.then(()=>{});const m=new Map;async function W(t){if(m.has(t))return m.get(t);if(!await _.promises.access(t).then(()=>!0,()=>!1)){m.set(t,void 0);return}const o=await _.promises.readFile(t,"utf8");try{const r=JSON.parse(o);return m.set(t,r),r}catch{throw new Error(`Error parsing: ${t}`)}}async function b(t){let n=new URL("package.json",t);for(;!n.pathname.endsWith("/node_modules/package.json");){const o=N(n),r=await W(o);if(r)return r;const s=n;if(n=new URL("../package.json",n),n.pathname===s.pathname)break}}async function h(t){var n;const o=await b(t);return(n=o==null?void 0:o.type)!=null?n:"commonjs"}var T=Object.defineProperty,I=Object.defineProperties,R=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,j=(t,n,o)=>n in t?T(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,P=(t,n)=>{for(var o in n||(n={}))x.call(n,o)&&j(t,o,n[o]);if(O)for(var o of O(n))F.call(n,o)&&j(t,o,n[o]);return t},l=(t,n)=>I(t,R(n));const k=d(),E=w(),L=E==null?void 0:E.config,M=/\.\w+$/,S=[".js",".json",".ts",".tsx",".jsx"],A=[...S,...S.map(t=>`/index${t}`)],i=async function(t,n,o){var r;if(t.startsWith("node:")&&(t=t.slice(5)),t.endsWith("/"))return i(`${t}index`,n,o);if(/\.[cm]js$/.test(t)&&c.test(n.parentURL))try{return await i(`${t.slice(0,-2)}ts`,n,o)}catch(s){if(s.code!=="ERR_MODULE_NOT_FOUND")throw s}if(c.test(t)){const s=await o(t,n,o),e=(r=y(s.url))!=null?r:await h(s.url);return l(P({},s),{format:e})}if(t.endsWith(".json"))return l(P({},await o(t,n,o)),{format:"json"});try{return await o(t,n,o)}catch(s){if(s instanceof Error){if(s.code==="ERR_UNSUPPORTED_DIR_IMPORT")return i(`${t}/index`,n,o);if(s.code==="ERR_MODULE_NOT_FOUND"&&!M.test(t))for(const e of A)try{const a=t+(t.endsWith("/")&&e.startsWith("/")?e.slice(1):e);return await i(a,n,o)}catch{}}throw s}},V=async function(t,n,o){process.send&&process.send({type:"dependency",path:t}),t.endsWith(".json")&&(n.importAssertions||(n.importAssertions={}),n.importAssertions.type="json");const r=await o(t,n,o);if(!r.source||t.includes("/node_modules/"))return r;const s=r.source.toString();if(r.format==="json"||c.test(t)){const a=await u(s,t,{format:"esm",tsconfigRaw:L});return a.map&&k.set(t,a.map),{format:"module",source:a.code}}const e=g({code:s});return e&&(r.source=e.code,e.map&&k.set(t,e.map)),r},v=w(),C=v==null?void 0:v.config,U=d(),q=async function(t,n,o){var r;return t.endsWith(".json")?{format:"module"}:c.test(t)?{format:(r=y(t))!=null?r:await h(t)}:await o(t,n,o)},z=async function(t,n,o){const{url:r}=n;if(process.send&&process.send({type:"dependency",path:r}),r.endsWith(".json")||c.test(r)){const a=await u(t.toString(),r,{format:"esm",tsconfigRaw:C});return a.map&&U.set(r,a.map),{source:a.code}}const s=await o(t,n,o),e=g({code:s.source});return e&&(s.source=e.code,e.map&&U.set(r,e.map)),s},p=[16,12,0],f=process.version.slice(1).split(".").map(Number),D=(f[0]-p[0]||f[1]-p[1]||f[2]-p[2])<0,B=D?q:void 0,H=D?z:void 0;export{B as getFormat,V as load,i as resolve,H as transformSource};
{
"name": "@esbuild-kit/esm-loader",
"version": "1.1.2",
"version": "2.0.0",
"publishConfig": {

@@ -28,3 +28,3 @@ "access": "public"

"scripts": {
"build": "pkgroll --minify --target=node12.19",
"build": "pkgroll --target=node12.19 --minify",
"lint": "eslint .",

@@ -35,3 +35,3 @@ "pretest": "npm run build",

"dependencies": {
"@esbuild-kit/core-utils": "^1.0.1",
"@esbuild-kit/core-utils": "^1.1.0",
"es-module-lexer": "^0.10.5",

@@ -50,2 +50,3 @@ "get-tsconfig": "^3.0.1"

"semver": "^7.3.7",
"type-fest": "^2.12.2",
"typescript": "^4.6.4"

@@ -64,3 +65,4 @@ },

"allow": [
"describe"
"describe",
"runTestSuite"
]

@@ -67,0 +69,0 @@ }

@@ -7,3 +7,2 @@ # esm-loader

- Transforms TypeScript to ESM on demand
- Supports TS extensions `.cjs` & `.mjs` (`.cts` & `.mts`)
- Classic Node.js resolution (extensionless & directory imports)

@@ -10,0 +9,0 @@ - Cached for performance boost

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