Initial commit
This commit is contained in:
21
node_modules/@esbuild-kit/esm-loader/LICENSE
generated
vendored
Normal file
21
node_modules/@esbuild-kit/esm-loader/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
155
node_modules/@esbuild-kit/esm-loader/README.md
generated
vendored
Normal file
155
node_modules/@esbuild-kit/esm-loader/README.md
generated
vendored
Normal file
@ -0,0 +1,155 @@
|
||||
# esm-loader
|
||||
|
||||
[Node.js loader](https://nodejs.org/api/esm.html#loaders) for loading TypeScript files.
|
||||
|
||||
### Features
|
||||
- Transforms TypeScript to ESM on demand
|
||||
- Classic Node.js resolution (extensionless & directory imports)
|
||||
- Cached for performance boost
|
||||
- Supports Node.js v12.20.0+
|
||||
- Handles `node:` import prefixes
|
||||
- Resolves `tsconfig.json` [`paths`](https://www.typescriptlang.org/tsconfig#paths)
|
||||
- Named imports from JSON modules
|
||||
|
||||
> **Protip: use with _cjs-loader_ or _tsx_**
|
||||
>
|
||||
> _esm-loader_ only transforms ES modules (`.mjs`/`.mts` extensions or `.js` files in `module` type packages).
|
||||
>
|
||||
> To transform CommonJS files (`.cjs`/`.cts` extensions or `.js` files in `commonjs` type packages), use this with [_cjs-loader_](https://github.com/esbuild-kit/cjs-loader).
|
||||
>
|
||||
> Alternatively, use [tsx](https://github.com/esbuild-kit/tsx) to handle them both automatically.
|
||||
|
||||
<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
|
||||
|
||||
```sh
|
||||
npm install --save-dev @esbuild-kit/esm-loader
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Pass `@esbuild-kit/esm-loader` into the [`--loader`](https://nodejs.org/api/cli.html#--experimental-loadermodule) flag.
|
||||
```sh
|
||||
node --loader @esbuild-kit/esm-loader ./file.ts
|
||||
```
|
||||
|
||||
### TypeScript configuration
|
||||
The following properties are used from `tsconfig.json` in the working directory:
|
||||
- [`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
|
||||
|
||||
#### Custom `tsconfig.json` path
|
||||
By default, `tsconfig.json` will be detected from the current working directory.
|
||||
|
||||
To set a custom path, use the `ESBK_TSCONFIG_PATH` environment variable:
|
||||
|
||||
```sh
|
||||
ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node --loader @esbuild-kit/esm-loader ./file.ts
|
||||
```
|
||||
|
||||
### Cache
|
||||
Modules transformations are cached in the system cache directory ([`TMPDIR`](https://en.wikipedia.org/wiki/TMPDIR)). Transforms are cached by content hash so duplicate dependencies are not re-transformed.
|
||||
|
||||
Set environment variable `ESBK_DISABLE_CACHE` to a truthy value to disable the cache:
|
||||
|
||||
```sh
|
||||
ESBK_DISABLE_CACHE=1 node --loader @esbuild-kit/esm-loader ./file.ts
|
||||
```
|
||||
|
||||
<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
|
||||
|
||||
### Can it import JSON modules?
|
||||
Yes. This loader transpiles JSON modules so it's also compatible with named imports.
|
||||
|
||||
### Can it import ESM modules over network?
|
||||
|
||||
Node.js has built-in support for network imports [behind the `--experimental-network-imports` flag](https://nodejs.org/api/esm.html#network-based-loading-is-not-enabled-by-default).
|
||||
|
||||
You can pass it in with `esm-loader`:
|
||||
|
||||
```sh
|
||||
node --loader @esbuild-kit/esm-loader --experimental-network-imports ./file.ts
|
||||
```
|
||||
|
||||
### Can it resolve files without an extension?
|
||||
|
||||
In ESM, import paths must be explicit (must include file name and extension).
|
||||
|
||||
For backwards compatibility, this loader adds support for classic Node resolution for extensions: `.js`, `.json`, `.ts`, `.tsx`, `.jsx`. Resolving a `index` file by the directory name works too.
|
||||
|
||||
```js
|
||||
import file from './file' // -> ./file.js
|
||||
import directory from './directory' // -> ./directory/index.js
|
||||
```
|
||||
|
||||
### Can it use Node.js's CommonJS resolution algorithm?
|
||||
|
||||
ESM import resolution expects explicit import paths, whereas CommonJS resolution expects implicit imports (eg. extensionless & directory imports).
|
||||
|
||||
As a result of this change, Node.js changes how it imports a path that matches both a file and directory. In ESM, the directory would be imported, but in CJS, the file would be imported.
|
||||
|
||||
To use to the CommonJS resolution algorithm, use the [`--experimental-specifier-resolution=node`](https://nodejs.org/api/cli.html#--experimental-specifier-resolutionmode) flag.
|
||||
|
||||
```sh
|
||||
node --loader @esbuild-kit/esm-loader --experimental-specifier-resolution=node ./file.ts
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [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.
|
||||
|
||||
## 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>
|
||||
12
node_modules/@esbuild-kit/esm-loader/dist/index.js
generated
vendored
Executable file
12
node_modules/@esbuild-kit/esm-loader/dist/index.js
generated
vendored
Executable file
@ -0,0 +1,12 @@
|
||||
import l from"path";import{fileURLToPath as y,pathToFileURL as U}from"url";import{installSourceMapSupport as I,compareNodeVersion as m,resolveTsPath as M,transform as S,transformDynamicImport as k}from"@esbuild-kit/core-utils";import{parseTsconfig as A,getTsconfig as J,createFilesMatcher as L,createPathsMatcher as W}from"get-tsconfig";import R from"fs";const f=new Map;async function b(t){if(f.has(t))return f.get(t);if(!await R.promises.access(t).then(()=>!0,()=>!1)){f.set(t,void 0);return}const e=await R.promises.readFile(t,"utf8");try{const n=JSON.parse(e);return f.set(t,n),n}catch{throw new Error(`Error parsing: ${t}`)}}async function $(t){let s=new URL("package.json",t);for(;!s.pathname.endsWith("/node_modules/package.json");){const e=y(s),n=await b(e);if(n)return n;const r=s;if(s=new URL("../package.json",s),s.pathname===r.pathname)break}}async function x(t){var s;const e=await $(t);return(s=e==null?void 0:e.type)!=null?s:"commonjs"}const u=I(),d=process.env.ESBK_TSCONFIG_PATH?{path:l.resolve(process.env.ESBK_TSCONFIG_PATH),config:A(process.env.ESBK_TSCONFIG_PATH)}:J(),N=d&&L(d),O=d&&W(d),w="file://",g=/\.([cm]?ts|[tj]sx)($|\?)/,_=/\.json(?:$|\?)/,C=t=>{const s=l.extname(t);if(s===".json")return"json";if(s===".mjs"||s===".mts")return"module";if(s===".cjs"||s===".cts")return"commonjs"},j=t=>{const s=C(t);if(s)return s;if(g.test(t))return x(t)},v=/\/(?:$|\?)/,K=m([20,0,0])>=0;let P=process.send?process.send.bind(process):void 0,E;const q=({port:t})=>(E=t,P=t.postMessage.bind(t),`
|
||||
const require = getBuiltin('module').createRequire("${import.meta.url}");
|
||||
require('@esbuild-kit/core-utils').installSourceMapSupport(port);
|
||||
if (process.send) {
|
||||
port.addListener('message', (message) => {
|
||||
if (message.type === 'dependency') {
|
||||
process.send(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
port.unref(); // Allows process to exit without waiting for port to close
|
||||
`),B=K?q:void 0,G=[".js",".json",".ts",".tsx",".jsx"];async function T(t,s,e){const[n,r]=t.split("?");let i;for(const a of G)try{return await h(n+a+(r?`?${r}`:""),s,e,!0)}catch(o){if(i===void 0&&o instanceof Error){const{message:c}=o;o.message=o.message.replace(`${a}'`,"'"),o.stack=o.stack.replace(c,o.message),i=o}}throw i}async function F(t,s,e){const n=v.test(t),r=n?"index":"/index",[i,a]=t.split("?");try{return await T(i+r+(a?`?${a}`:""),s,e)}catch(o){if(!n)try{return await T(t,s,e)}catch{}const c=o,{message:p}=c;throw c.message=c.message.replace(`${r.replace("/",l.sep)}'`,"'"),c.stack=c.stack.replace(p,c.message),c}}const H=/^\.{1,2}\//,Q=m([14,13,1])>=0||m([12,20,0])>=0,h=async function(t,s,e,n){var r;if(!Q&&t.startsWith("node:")&&(t=t.slice(5)),v.test(t))return await F(t,s,e);const i=t.startsWith(w)||H.test(t);if(O&&!i&&!((r=s.parentURL)!=null&&r.includes("/node_modules/"))){const o=O(t);for(const c of o)try{return await h(U(c).toString(),s,e)}catch{}}if(g.test(s.parentURL)){const o=M(t);if(o)try{return await h(o,s,e,!0)}catch(c){const{code:p}=c;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw c}}let a;try{a=await e(t,s)}catch(o){if(o instanceof Error&&!n){const{code:c}=o;if(c==="ERR_UNSUPPORTED_DIR_IMPORT")try{return await F(t,s,e)}catch(p){if(p.code!=="ERR_PACKAGE_IMPORT_NOT_DEFINED")throw p}if(c==="ERR_MODULE_NOT_FOUND")try{return await T(t,s,e)}catch{}}throw o}return!a.format&&a.url.startsWith(w)&&(a.format=await j(a.url)),a},X=async function(t,s,e){var n;P&&P({type:"dependency",path:t}),_.test(t)&&(s.importAssertions||(s.importAssertions={}),s.importAssertions.type="json");const r=await e(t,s);if(!r.source)return r;const i=t.startsWith("file://")?y(t):t,a=r.source.toString();if(r.format==="json"||g.test(t)){const o=await S(a,i,{tsconfigRaw:(n=N)==null?void 0:n(i)});return{format:"module",source:u(o,t,E)}}if(r.format==="module"){const o=k(i,a);o&&(r.source=u(o,t,E))}return r},V=async function(t,s,e){if(_.test(t))return{format:"module"};try{return await e(t,s,e)}catch(n){if(n.code==="ERR_UNKNOWN_FILE_EXTENSION"&&t.startsWith(w)){const r=await j(t);if(r)return{format:r}}throw n}},z=async function(t,s,e){var n;const{url:r}=s,i=r.startsWith("file://")?y(r):r;if(process.send&&process.send({type:"dependency",path:r}),_.test(r)||g.test(r)){const o=await S(t.toString(),i,{tsconfigRaw:(n=N)==null?void 0:n(i)});return{source:u(o,r)}}const a=await e(t,s,e);if(s.format==="module"){const o=k(i,a.source.toString());o&&(a.source=u(o,r))}return a},D=m([16,12,0])<0,Y=D?V:void 0,Z=D?z:void 0;export{Y as getFormat,B as globalPreload,X as load,h as resolve,Z as transformSource};
|
||||
31
node_modules/@esbuild-kit/esm-loader/package.json
generated
vendored
Normal file
31
node_modules/@esbuild-kit/esm-loader/package.json
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@esbuild-kit/esm-loader",
|
||||
"version": "2.6.5",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "Node.js loader for compiling TypeScript modules to ESM",
|
||||
"keywords": [
|
||||
"esbuild",
|
||||
"loader",
|
||||
"node",
|
||||
"esm",
|
||||
"typescript"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "esbuild-kit/esm-loader",
|
||||
"author": {
|
||||
"name": "Hiroki Osame",
|
||||
"email": "hiroki.osame@gmail.com"
|
||||
},
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"exports": "./dist/index.js",
|
||||
"dependencies": {
|
||||
"@esbuild-kit/core-utils": "^3.3.2",
|
||||
"get-tsconfig": "^4.7.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user