Socket
Socket
Sign inDemoInstall

@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.5.5 to 2.6.0

6

dist/index.js

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

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

6

package.json
{
"name": "@esbuild-kit/esm-loader",
"version": "2.5.5",
"version": "2.6.0",
"publishConfig": {

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

"dependencies": {
"@esbuild-kit/core-utils": "^3.0.0",
"get-tsconfig": "^4.4.0"
"@esbuild-kit/core-utils": "^3.3.0",
"get-tsconfig": "^4.7.0"
}
}
# esm-loader
Node.js `import` hook to instantaneously transform TypeScript to ESM on demand using [esbuild](https://esbuild.github.io/).
[Node.js loader](https://nodejs.org/api/esm.html#loaders) for loading TypeScript using [esbuild](https://esbuild.github.io/).

@@ -19,2 +19,14 @@ ### Features

<br>
<p align="center">
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum">
<picture>
<source width="830" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image=dark">
<source width="830" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image">
<img width="830" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image" alt="Premium sponsor banner">
</picture>
</a>
</p>
## Install

@@ -62,2 +74,14 @@

<br>
<p align="center">
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold">
<picture>
<source width="830" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image=dark">
<source width="830" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image">
<img width="830" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image" alt="Premium sponsor banner">
</picture>
</a>
</p>
## FAQ

@@ -106,1 +130,26 @@

- [@esbuild-kit/cjs-loader](https://github.com/esbuild-kit/cjs-loader) - TypeScript & ESM to CJS transpiler using the Node.js loader API.
## Sponsors
<p align="center">
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1">
<picture>
<source width="410" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image=dark">
<source width="410" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image">
<img width="410" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image" alt="Premium sponsor banner">
</picture>
</a>
<a href="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2">
<picture>
<source width="410" media="(prefers-color-scheme: dark)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image=dark">
<source width="410" media="(prefers-color-scheme: light)" srcset="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image">
<img width="410" src="https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image" alt="Premium sponsor banner">
</picture>
</a>
</p>
<p align="center">
<a href="https://github.com/sponsors/privatenumber">
<img src="https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg">
</a>
</p>
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