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 2.6.0 to 2.6.1

6

dist/index.js

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

import g from"path";import{fileURLToPath as l,pathToFileURL as F}from"url";import{installSourceMapSupport as U,compareNodeVersion as w,resolveTsPath as v,transform as P,transformDynamicImport as T}from"@esbuild-kit/core-utils";import{parseTsconfig as D,getTsconfig as I,createFilesMatcher as W,createPathsMatcher as A}from"get-tsconfig";import S from"fs";const p=new Map;async function M(t){if(p.has(t))return p.get(t);if(!await S.promises.access(t).then(()=>!0,()=>!1)){p.set(t,void 0);return}const s=await S.promises.readFile(t,"utf8");try{const n=JSON.parse(s);return p.set(t,n),n}catch{throw new Error(`Error parsing: ${t}`)}}async function J(t){let r=new URL("package.json",t);for(;!r.pathname.endsWith("/node_modules/package.json");){const s=l(r),n=await M(s);if(n)return n;const o=r;if(r=new URL("../package.json",r),r.pathname===o.pathname)break}}async function L(t){var r;const s=await J(t);return(r=s==null?void 0:s.type)!=null?r:"commonjs"}const f=U(),u=process.env.ESBK_TSCONFIG_PATH?{path:g.resolve(process.env.ESBK_TSCONFIG_PATH),config:D(process.env.ESBK_TSCONFIG_PATH)}:I(),k=u&&W(u),N=u&&A(u),_="file://",d=/\.([cm]?ts|[tj]sx)$/,b=t=>{const r=g.extname(t);if(r===".json")return"json";if(r===".mjs"||r===".mts")return"module";if(r===".cjs"||r===".cts")return"commonjs"},R=t=>{const r=b(t);if(r)return r;if(d.test(t))return L(t)};let y;const x=({port:t})=>(y=t,`
const require = getBuiltin('module').createRequire(getBuiltin('process').cwd() + '/<preload>');
import g from"path";import{fileURLToPath as l,pathToFileURL as F}from"url";import{installSourceMapSupport as U,compareNodeVersion as w,resolveTsPath as v,transform as P,transformDynamicImport as T}from"@esbuild-kit/core-utils";import{parseTsconfig as D,getTsconfig as I,createFilesMatcher as W,createPathsMatcher as A}from"get-tsconfig";import S from"fs";const p=new Map;async function J(t){if(p.has(t))return p.get(t);if(!await S.promises.access(t).then(()=>!0,()=>!1)){p.set(t,void 0);return}const s=await S.promises.readFile(t,"utf8");try{const n=JSON.parse(s);return p.set(t,n),n}catch{throw new Error(`Error parsing: ${t}`)}}async function M(t){let r=new URL("package.json",t);for(;!r.pathname.endsWith("/node_modules/package.json");){const s=l(r),n=await J(s);if(n)return n;const o=r;if(r=new URL("../package.json",r),r.pathname===o.pathname)break}}async function L(t){var r;const s=await M(t);return(r=s==null?void 0:s.type)!=null?r:"commonjs"}const f=U(),u=process.env.ESBK_TSCONFIG_PATH?{path:g.resolve(process.env.ESBK_TSCONFIG_PATH),config:D(process.env.ESBK_TSCONFIG_PATH)}:I(),k=u&&W(u),N=u&&A(u),_="file://",d=/\.([cm]?ts|[tj]sx)$/,b=t=>{const r=g.extname(t);if(r===".json")return"json";if(r===".mjs"||r===".mts")return"module";if(r===".cjs"||r===".cts")return"commonjs"},O=t=>{const r=b(t);if(r)return r;if(d.test(t))return L(t)};let y;const x=({port:t})=>(y=t,`
const require = getBuiltin('module').createRequire(${JSON.stringify(import.meta.url)});
require('@esbuild-kit/core-utils').installSourceMapSupport(port);
port.unref(); // Allows process to exit without waiting for port to close
`),C=[".js",".json",".ts",".tsx",".jsx"];async function E(t,r,s){let n;for(const o of C)try{return await h(t+o,r,s,!0)}catch(a){if(n===void 0&&a instanceof Error){const{message:e}=a;a.message=a.message.replace(`${o}'`,"'"),a.stack=a.stack.replace(e,a.message),n=a}}throw n}async function O(t,r,s){const n=t.endsWith("/"),o=n?"index":"/index";try{return await E(t+o,r,s)}catch(a){if(!n)try{return await E(t,r,s)}catch{}const e=a,{message:c}=e;throw e.message=e.message.replace(`${o.replace("/",g.sep)}'`,"'"),e.stack=e.stack.replace(c,e.message),e}}const K=/^\.{0,2}\//,B=w([14,13,1])>=0||w([12,20,0])>=0,h=async function(t,r,s,n){var o;if(!B&&t.startsWith("node:")&&(t=t.slice(5)),t.endsWith("/"))return await O(t,r,s);const a=t.startsWith(_)||K.test(t);if(N&&!a&&!((o=r.parentURL)!=null&&o.includes("/node_modules/"))){const c=N(t);for(const i of c)try{return await h(F(i).toString(),r,s)}catch{}}if(d.test(r.parentURL)){const c=v(t);if(c)try{return await h(c,r,s,!0)}catch(i){const{code:m}=i;if(m!=="ERR_MODULE_NOT_FOUND"&&m!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw i}}let e;try{e=await s(t,r)}catch(c){if(c instanceof Error&&!n){const{code:i}=c;if(i==="ERR_UNSUPPORTED_DIR_IMPORT")try{return await O(t,r,s)}catch(m){if(m.code!=="ERR_PACKAGE_IMPORT_NOT_DEFINED")throw m}if(i==="ERR_MODULE_NOT_FOUND")try{return await E(t,r,s)}catch{}}throw c}return!e.format&&e.url.startsWith(_)&&(e.format=await R(e.url)),e},G=async function(t,r,s){var n;process.send&&process.send({type:"dependency",path:t}),t.endsWith(".json")&&(r.importAssertions||(r.importAssertions={}),r.importAssertions.type="json");const o=await s(t,r);if(!o.source)return o;const a=t.startsWith("file://")?l(t):t,e=o.source.toString();if(o.format==="json"||d.test(t)){const c=await P(e,a,{tsconfigRaw:(n=k)==null?void 0:n(a)});return{format:"module",source:f(c,t,y)}}if(o.format==="module"){const c=T(a,e);c&&(o.source=f(c,t,y))}return o},H=async function(t,r,s){if(t.endsWith(".json"))return{format:"module"};try{return await s(t,r,s)}catch(n){if(n.code==="ERR_UNKNOWN_FILE_EXTENSION"&&t.startsWith(_)){const o=await R(t);if(o)return{format:o}}throw n}},$=async function(t,r,s){var n;const{url:o}=r,a=o.startsWith("file://")?l(o):o;if(process.send&&process.send({type:"dependency",path:o}),o.endsWith(".json")||d.test(o)){const c=await P(t.toString(),a,{tsconfigRaw:(n=k)==null?void 0:n(a)});return{source:f(c,o)}}const e=await s(t,r,s);if(r.format==="module"){const c=T(a,e.source.toString());c&&(e.source=f(c,o))}return e},j=w([16,12,0])<0,q=j?H:void 0,X=j?$:void 0;export{q as getFormat,x as globalPreload,G as load,h as resolve,X as transformSource};
`),C=[".js",".json",".ts",".tsx",".jsx"];async function E(t,r,s){let n;for(const o of C)try{return await h(t+o,r,s,!0)}catch(a){if(n===void 0&&a instanceof Error){const{message:e}=a;a.message=a.message.replace(`${o}'`,"'"),a.stack=a.stack.replace(e,a.message),n=a}}throw n}async function R(t,r,s){const n=t.endsWith("/"),o=n?"index":"/index";try{return await E(t+o,r,s)}catch(a){if(!n)try{return await E(t,r,s)}catch{}const e=a,{message:c}=e;throw e.message=e.message.replace(`${o.replace("/",g.sep)}'`,"'"),e.stack=e.stack.replace(c,e.message),e}}const K=/^\.{0,2}\//,$=w([14,13,1])>=0||w([12,20,0])>=0,h=async function(t,r,s,n){var o;if(!$&&t.startsWith("node:")&&(t=t.slice(5)),t.endsWith("/"))return await R(t,r,s);const a=t.startsWith(_)||K.test(t);if(N&&!a&&!((o=r.parentURL)!=null&&o.includes("/node_modules/"))){const c=N(t);for(const i of c)try{return await h(F(i).toString(),r,s)}catch{}}if(d.test(r.parentURL)){const c=v(t);if(c)try{return await h(c,r,s,!0)}catch(i){const{code:m}=i;if(m!=="ERR_MODULE_NOT_FOUND"&&m!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw i}}let e;try{e=await s(t,r)}catch(c){if(c instanceof Error&&!n){const{code:i}=c;if(i==="ERR_UNSUPPORTED_DIR_IMPORT")try{return await R(t,r,s)}catch(m){if(m.code!=="ERR_PACKAGE_IMPORT_NOT_DEFINED")throw m}if(i==="ERR_MODULE_NOT_FOUND")try{return await E(t,r,s)}catch{}}throw c}return!e.format&&e.url.startsWith(_)&&(e.format=await O(e.url)),e},B=async function(t,r,s){var n;process.send&&process.send({type:"dependency",path:t}),t.endsWith(".json")&&(r.importAssertions||(r.importAssertions={}),r.importAssertions.type="json");const o=await s(t,r);if(!o.source)return o;const a=t.startsWith("file://")?l(t):t,e=o.source.toString();if(o.format==="json"||d.test(t)){const c=await P(e,a,{tsconfigRaw:(n=k)==null?void 0:n(a)});return{format:"module",source:f(c,t,y)}}if(o.format==="module"){const c=T(a,e);c&&(o.source=f(c,t,y))}return o},G=async function(t,r,s){if(t.endsWith(".json"))return{format:"module"};try{return await s(t,r,s)}catch(n){if(n.code==="ERR_UNKNOWN_FILE_EXTENSION"&&t.startsWith(_)){const o=await O(t);if(o)return{format:o}}throw n}},H=async function(t,r,s){var n;const{url:o}=r,a=o.startsWith("file://")?l(o):o;if(process.send&&process.send({type:"dependency",path:o}),o.endsWith(".json")||d.test(o)){const c=await P(t.toString(),a,{tsconfigRaw:(n=k)==null?void 0:n(a)});return{source:f(c,o)}}const e=await s(t,r,s);if(r.format==="module"){const c=T(a,e.source.toString());c&&(e.source=f(c,o))}return e},j=w([16,12,0])<0,q=j?G:void 0,X=j?H:void 0;export{q as getFormat,x as globalPreload,B as load,h as resolve,X as transformSource};
{
"name": "@esbuild-kit/esm-loader",
"version": "2.6.0",
"version": "2.6.1",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

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