{"name":"@esbuild-kit/esm-loader","version":"2.1.0","publishConfig":{"access":"public"},"description":"Node.js loader for compiling TypeScript modules to ESM","keywords":["esbuild","loader","node","esm","typescript"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/esbuild-kit/esm-loader.git"},"author":{"name":"Hiroki Osame","email":"hiroki.osame@gmail.com"},"type":"module","main":"./dist/index.js","exports":"./dist/index.js","scripts":{"build":"pkgroll --target=node12.19 --minify","lint":"eslint .","pretest":"npm run build","test":"node --loader @esbuild-kit/esm-loader tests"},"dependencies":{"@esbuild-kit/core-utils":"^1.1.0","es-module-lexer":"^0.10.5","get-tsconfig":"^3.0.1"},"devDependencies":{"@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":"^13.0.1","manten":"^0.1.0","pkgroll":"^1.3.0","semver":"^7.3.7","type-fest":"^2.12.2","typescript":"^4.6.4"},"eslintConfig":{"extends":"@pvtnbr","ignorePatterns":["tests/fixtures"],"rules":{"import/no-unresolved":"off","@typescript-eslint/no-shadow":["error",{"allow":["describe","runTestSuite"]}]}},"gitHead":"0d64195031bb599034be6c2d29427efd4d9d6334","bugs":{"url":"https://github.com/esbuild-kit/esm-loader/issues"},"homepage":"https://github.com/esbuild-kit/esm-loader#readme","_id":"@esbuild-kit/esm-loader@2.1.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-zE7BepoWvVhyoHDEnc2whD9x27UzdRIcUguOD6mUx8PzYjEw2pdNsY+2sP9PeGxW6YJvtLOqcDj3tqhxj61IPw==","shasum":"5c2939917e6a35e5ea2c76037dccad0b9614bdc3","tarball":"http://registry-npm.ywwl.com/@esbuild-kit/esm-loader/download/@esbuild-kit/esm-loader-2.1.0.tgz","fileCount":3,"unpackedSize":7558,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDK8t33cm/U1jN0h8vZbtrjh4bIpAIf8dqcQ0+PU/largIhAPvJR4AHFcTvL71krFMEfPdRDT7vOYgSdsqZwYsvZzny"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJihRE6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmprqQ//cWKrWWIt3dU6UjKp3cdleY6Fdn5N+Ddv2DIArD7PcCZjwtFL\r\n1EVDNdMfPSjuM8mtaGNKP9bqRNN+kqW4Ez1fbSOGgbF0mwnCRzI0gi6GhKiO\r\nJMTwmbTPlaTWiy62aLc7s0sR+O6AGcUvx2CQy7aCW53tHu9Xuu71aZEhU1LF\r\nH8I5ZieSK68i9VrJ8QI81qqKd1exm2go/pC/YM1mQfAqZsB0f3/wMb+hgRjO\r\n+vT8vK+oVvsRDR5KzWA0UMJ2i1h9DU2FgFF6gvsztlPUwXg0L7YF3E3ruQ3M\r\notTf7l39LB9bQuzJk9t2xm1lhThkI5tn2V0nVjQbd4n/Tzd2MWhkt1tTnueA\r\nPhxSJWaIV86Wsp7NRFWF+Ue8ZAbAUMdGV1HqgGs0qG8quMkl9LRwg2MGIygO\r\nlILKphH3jJFxX2f+8MljFDOZx0NWe8i6Ny4IJSQm50YO4kjNBqnlXppIPTtO\r\nkxZLHo5aY2Ju7zMlLIP4bZE1aplf7C6fSyDUb7Fo/+GI7f5M3ATIulXnZvZD\r\nMPvvgJmuZPKqyI9+05HaBeui9Nft7UM8SxCocJZE5Q7lKaTG5MG5jPSuXlTt\r\naXdczKvVSeeBlwcEaf7gn0r9vZyXU3qE7b2lDjnJY9Ojr6ozNOsZd1bXrURQ\r\n/wueQg2a4AcWBJI4UOxidiK9tMcf0xjKhnM=\r\n=p2l/\r\n-----END PGP SIGNATURE-----\r\n","size":3355,"noattachment":false,"key":"/@esbuild-kit/esm-loader/-/@esbuild-kit/esm-loader-2.1.0.tgz"},"_npmUser":{"name":"hirokiosame","email":"hiroki.osame@gmail.com"},"directories":{},"maintainers":[{"name":"hirokiosame","email":"hiroki.osame@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-loader_2.1.0_1652887866563_0.16585997795788576"},"_hasShrinkwrap":false,"readme":"# esm-loader\n\n[Node.js loader](https://nodejs.org/api/esm.html#loaders) for loading TypeScript files.\n\n### Features\n- Transforms TypeScript to ESM on demand\n- Classic Node.js resolution (extensionless & directory imports)\n- Cached for performance boost\n- Supports Node.js v12.20.0+\n- Handles `node:` import prefixes\n- Resolves `tsconfig.json` [`paths`](https://www.typescriptlang.org/tsconfig#paths)\n- Named imports from JSON modules\n\n> **Protip: use with _cjs-loader_ or _tsx_**\n>\n> _esm-loader_ only transforms ES modules (`.mjs`/`.mts` extensions or `.js` files in `module` type packages).\n>\n> 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).\n>\n> Alternatively, use [tsx](https://github.com/esbuild-kit/tsx) to handle them both automatically.\n\n<br>\n\n<p align=\"center\">\n\t<a href=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum\">\n\t\t<picture>\n\t\t\t<source width=\"830\" media=\"(prefers-color-scheme: dark)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image=dark\">\n\t\t\t<source width=\"830\" media=\"(prefers-color-scheme: light)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image\">\n\t\t\t<img width=\"830\" src=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=platinum&image\" alt=\"Premium sponsor banner\">\n\t\t</picture>\n\t</a>\n</p>\n\n## Install\n\n```sh\nnpm install --save-dev @esbuild-kit/esm-loader\n```\n\n## Usage\n\nPass `@esbuild-kit/esm-loader` into the [`--loader`](https://nodejs.org/api/cli.html#--experimental-loadermodule) flag.\n```sh\nnode --loader @esbuild-kit/esm-loader ./file.ts\n```\n\n### TypeScript configuration\nThe following properties are used from `tsconfig.json` in the working directory:\n- [`strict`](https://www.typescriptlang.org/tsconfig#strict): Whether to transform to strict mode\n- [`jsx`](https://esbuild.github.io/api/#jsx): Whether to transform JSX\n\t> **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.\n- [`jsxFactory`](https://esbuild.github.io/api/#jsx-factory): How to transform JSX\n- [`jsxFragmentFactory`](https://esbuild.github.io/api/#jsx-fragment): How to transform JSX Fragments\n- [`jsxImportSource`](https://www.typescriptlang.org/tsconfig#jsxImportSource): Where to import JSX functions from\n- [`allowJs`](https://www.typescriptlang.org/tsconfig#allowJs): Whether to apply the tsconfig to JS files\n- [`paths`](https://www.typescriptlang.org/tsconfig#paths): For resolving aliases\n\n#### Custom `tsconfig.json` path\nBy default, `tsconfig.json` will be detected from the current working directory.\n\nTo set a custom path, use the `ESBK_TSCONFIG_PATH` environment variable:\n\n```sh\nESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node --loader @esbuild-kit/esm-loader ./file.ts\n```\n\n### Cache\nModules 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.\n\nSet environment variable `ESBK_DISABLE_CACHE` to a truthy value to disable the cache:\n\n```sh\nESBK_DISABLE_CACHE=1 node --loader @esbuild-kit/esm-loader ./file.ts\n```\n\n<br>\n\n<p align=\"center\">\n\t<a href=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold\">\n\t\t<picture>\n\t\t\t<source width=\"830\" media=\"(prefers-color-scheme: dark)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image=dark\">\n\t\t\t<source width=\"830\" media=\"(prefers-color-scheme: light)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image\">\n\t\t\t<img width=\"830\" src=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=gold&image\" alt=\"Premium sponsor banner\">\n\t\t</picture>\n\t</a>\n</p>\n\n## FAQ\n\n### Can it import JSON modules?\nYes. This loader transpiles JSON modules so it's also compatible with named imports.\n\n### Can it import ESM modules over network?\n\nNode.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).\n\nYou can pass it in with `esm-loader`:\n\n```sh\nnode --loader @esbuild-kit/esm-loader --experimental-network-imports ./file.ts\n```\n\n### Can it resolve files without an extension?\n\nIn ESM, import paths must be explicit (must include file name and extension).\n\nFor 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.\n\n```js\nimport file from './file' // -> ./file.js\nimport directory from './directory' // -> ./directory/index.js\n```\n\n### Can it use Node.js's CommonJS resolution algorithm?\n\nESM import resolution expects explicit import paths, whereas CommonJS resolution expects implicit imports (eg. extensionless & directory imports).\n\nAs 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.\n\nTo use to the CommonJS resolution algorithm, use the [`--experimental-specifier-resolution=node`](https://nodejs.org/api/cli.html#--experimental-specifier-resolutionmode) flag.\n\n```sh\nnode --loader @esbuild-kit/esm-loader --experimental-specifier-resolution=node ./file.ts\n```\n\n## Related\n\n- [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).\n\n- [@esbuild-kit/cjs-loader](https://github.com/esbuild-kit/cjs-loader) - TypeScript & ESM to CJS transpiler using the Node.js loader API.\n\n## Sponsors\n\n<p align=\"center\">\n\t<a href=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1\">\n\t\t<picture>\n\t\t\t<source width=\"410\" media=\"(prefers-color-scheme: dark)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image=dark\">\n\t\t\t<source width=\"410\" media=\"(prefers-color-scheme: light)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image\">\n\t\t\t<img width=\"410\" src=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver1&image\" alt=\"Premium sponsor banner\">\n\t\t</picture>\n\t</a>\n\t<a href=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2\">\n\t\t<picture>\n\t\t\t<source width=\"410\" media=\"(prefers-color-scheme: dark)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image=dark\">\n\t\t\t<source width=\"410\" media=\"(prefers-color-scheme: light)\" srcset=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image\">\n\t\t\t<img width=\"410\" src=\"https://privatenumber-sponsors.vercel.app/api/sponsor?tier=silver2&image\" alt=\"Premium sponsor banner\">\n\t\t</picture>\n\t</a>\n</p>\n\n<p align=\"center\">\n\t<a href=\"https://github.com/sponsors/privatenumber\">\n\t\t<img src=\"https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg\">\n\t</a>\n</p>\n","publish_time":1652887866740,"deprecated":"Merged into tsx: https://tsx.hirok.io","_cnpm_publish_time":1652887866740,"dist-tags":{"latest":"2.6.5"}}