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

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

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

@@ -40,10 +40,10 @@ "get-tsconfig": "^3.0.1"

"devDependencies": {
"@pvtnbr/eslint-config": "^0.21.0",
"@types/node": "^17.0.31",
"@pvtnbr/eslint-config": "^0.22.0",
"@types/node": "^17.0.33",
"@types/semver": "^7.3.9",
"eslint": "^8.15.0",
"execa": "^6.1.0",
"get-node": "^12.1.0",
"manten": "^0.0.3",
"pkgroll": "^1.2.2",
"get-node": "^13.0.1",
"manten": "^0.1.0",
"pkgroll": "^1.3.0",
"semver": "^7.3.7",

@@ -50,0 +50,0 @@ "typescript": "^4.6.4"

@@ -27,5 +27,5 @@ # esm-loader

Pass `@esbuild/esm-loader` into the [`--loader`](https://nodejs.org/api/cli.html#--experimental-loadermodule) flag.
Pass `@esbuild-kit/esm-loader` into the [`--loader`](https://nodejs.org/api/cli.html#--experimental-loadermodule) flag.
```sh
node --loader @esbuild/esm-loader ./file.ts
node --loader @esbuild-kit/esm-loader ./file.ts
```

@@ -44,3 +44,3 @@

```sh
ESBK_DISABLE_CACHE=1 node --loader @esbuild/esm-loader ./file.ts
ESBK_DISABLE_CACHE=1 node --loader @esbuild-kit/esm-loader ./file.ts
```

@@ -51,3 +51,3 @@

### Can it import JSON modules?
Yes. This loader enables importing native [JSON modules](https://nodejs.org/api/esm.html#json-modules).
Yes. This loader transpiles JSON modules so it's also compatible with named imports.

@@ -61,3 +61,3 @@ ### Can it import ESM modules over network?

```sh
node --loader @esbuild/esm-loader --experimental-network-imports ./file.ts
node --loader @esbuild-kit/esm-loader --experimental-network-imports ./file.ts
```

@@ -78,4 +78,4 @@

- [tsx](https://github.com/esbuild-kit/tsx) - Node.js runtime powered by esbuild using `@esbuild-kit/cjs-loader` and `@esbuild-kit/esb-loader`.
- [tsx](https://github.com/esbuild-kit/tsx) - Node.js runtime powered by esbuild using [`@esbuild-kit/cjs-loader`](https://github.com/esbuild-kit/cjs-loader) and [`@esbuild-kit/esm-loader`](https://github.com/esbuild-kit/esm-loader).
- [@esbuild-kit/cjs-loader](https://github.com/esbuild-kit/cjs-loader) - TypeScript & ESM to CJS transpiler using the Node.js loader API.
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