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.5.4 to 2.5.5

2

dist/index.js

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

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

@@ -29,4 +29,4 @@ "access": "public"

"@esbuild-kit/core-utils": "^3.0.0",
"get-tsconfig": "^4.2.0"
"get-tsconfig": "^4.4.0"
}
}

@@ -34,4 +34,10 @@ # esm-loader

The following properties are used from `tsconfig.json` in the working directory:
- `jsxFactory`
- `jsxFragmentFactory`
- [`strict`](https://www.typescriptlang.org/tsconfig#strict): Whether to transform to strict mode
- [`jsx`](https://esbuild.github.io/api/#jsx): Whether to transform JSX
> **Warning:** When set to `preserve`, the JSX syntax will remain untransformed. To prevent Node.js from throwing a syntax error, chain another Node.js loader that can transform JSX to JS.
- [`jsxFactory`](https://esbuild.github.io/api/#jsx-factory): How to transform JSX
- [`jsxFragmentFactory`](https://esbuild.github.io/api/#jsx-fragment): How to transform JSX Fragments
- [`jsxImportSource`](https://www.typescriptlang.org/tsconfig#jsxImportSource): Where to import JSX functions from
- [`allowJs`](https://www.typescriptlang.org/tsconfig#allowJs): Whether to apply the tsconfig to JS files
- [`paths`](https://www.typescriptlang.org/tsconfig#paths): For resolving aliases

@@ -44,3 +50,3 @@ #### Custom `tsconfig.json` path

```sh
ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node --loader @esbuild/esm-loader ./file.ts
ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node --loader @esbuild-kit/esm-loader ./file.ts
```

@@ -47,0 +53,0 @@

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