{"_rev":"3-6a7f209ddb3b2acb35038ad8cf192e2f","time":{"created":"2023-08-21T21:13:55.512Z","1.0.0":"2023-08-21T20:58:30.809Z","modified":"2023-08-21T21:13:56.169Z","1.0.1":"2023-08-21T21:13:55.890Z"},"_id":"@awalgawe/esbuild-typescript-paths-plugin","name":"@awalgawe/esbuild-typescript-paths-plugin","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@awalgawe/esbuild-typescript-paths-plugin","version":"1.0.1","description":"A plugin for esbuild that resolves TypeScript path aliases during the build process.","homepage":"https://github.com/Awalgawe/esbuild-typescript-paths-plugin","repository":{"type":"git","url":"git+https://github.com/Awalgawe/esbuild-typescript-paths-plugin.git"},"bugs":{"url":"https://github.com/Awalgawe/esbuild-typescript-paths-plugin/issues"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14.0.0"},"scripts":{"test":"jest dist","test:watch":"jest --watch dist","lint":"eslint src --ext .ts","build":"tsc","build:watch":"tsc -w","build:clean":"rm -rf dist"},"author":{"name":"Valéry Herlaud"},"keywords":["esbuild","typescript","tsconfig","paths","aliases","plugin"],"license":"ISC","devDependencies":{"@jest/globals":"^29.6.2","@types/git-diff":"^2.0.3","@types/node":"^20.5.0","@typescript-eslint/eslint-plugin":"^6.3.0","@typescript-eslint/parser":"^6.3.0","assert-plus":"^1.0.0","eslint":"^8.47.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","git-diff":"^2.0.6","jest":"^29.6.2","prettier":"^3.0.1"},"peerDependencies":{"esbuild":"^0.19.2","typescript":"^5.1.6"},"_id":"@awalgawe/esbuild-typescript-paths-plugin@1.0.1","gitHead":"f85709d689a078d39e5e6ffb2b5f62016585d684","_nodeVersion":"20.5.1","_npmVersion":"9.8.0","dist":{"integrity":"sha512-MPbXk9D1ZXCU2bZuUaZ5ueAFNPFIJE+B/x26jikMEImbfe8SMoUg1xN68F4N/e7oSkAA5jWR8tbsapMSOd9HIQ==","shasum":"f007a13c2e9f596b9f30a045b85d60c74f404448","tarball":"https://registry.npmjs.org/@awalgawe/esbuild-typescript-paths-plugin/-/esbuild-typescript-paths-plugin-1.0.1.tgz","fileCount":21,"unpackedSize":30030,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHyGKyVIxQgq0y9DSkujjgmzcGxcR5d0f5ayB+lKUDfcAiAmv2T38dFXS6h/Zxggfc3UCZf+97p/X6UeQJnOhBnLBQ=="}]},"_npmUser":{"name":"awalgawe","email":"valery.herlaud@webedia-group.com"},"directories":{},"maintainers":[{"name":"awalgawe","email":"valery.herlaud@webedia-group.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-typescript-paths-plugin_1.0.1_1692652435656_0.10478927939543614"},"_hasShrinkwrap":false}},"maintainers":[{"name":"awalgawe","email":"valery.herlaud@webedia-group.com"}],"description":"A plugin for esbuild that resolves TypeScript path aliases during the build process.","homepage":"https://github.com/Awalgawe/esbuild-typescript-paths-plugin","keywords":["esbuild","typescript","tsconfig","paths","aliases","plugin"],"repository":{"type":"git","url":"git+https://github.com/Awalgawe/esbuild-typescript-paths-plugin.git"},"author":{"name":"Valéry Herlaud"},"bugs":{"url":"https://github.com/Awalgawe/esbuild-typescript-paths-plugin/issues"},"license":"ISC","readme":"# @awalgawe/esbuild-typescript-paths-plugin\n\nA plugin for [esbuild](https://esbuild.github.io/) that resolves TypeScript path aliases during the build process.\n\n## Installation\n\nYou can install the plugin using npm or yarn:\n\n```bash\nnpm install --save-dev @awalgawe/esbuild-typescript-paths-plugin\n```\n\nor\n\n```bash\nyarn add --dev @awalgawe/esbuild-typescript-paths-plugin\n```\n\n## Usage\n\nTo use the TypeScript Paths Plugin, you need to import it and add it to your esbuild plugins list. Here's an example of how you can set it up:\n\n```javascript\nimport { build } from 'esbuild';\nimport { tsPathsPlugin } from '@awalgawe/esbuild-typescript-paths-plugin';\n\nbuild({\n  entryPoints: ['src/main.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [tsPathsPlugin()],\n  tsconfig: './path/to/your/tsconfig.json', // Optional: Path to your TypeScript configuration file.\n  absWorkingDir: __dirname, // Optional: Absolute working directory for resolving paths.\n}).catch(() => process.exit(1));\n```\n\nor without bundling:\n\n```javascript\nimport { build } from 'esbuild';\nimport { tsPathsPlugin } from '@awalgawe/esbuild-typescript-paths-plugin';\n\nbuild({\n  entryPoints: ['src/**/*.ts'],\n  outdir: 'dist',\n  plugins: [tsPathsPlugin()],\n  tsconfig: './path/to/your/tsconfig.json', // Optional: Path to your TypeScript configuration file.\n  absWorkingDir: __dirname, // Optional: Absolute working directory for resolving paths.\n}).catch(() => process.exit(1));\n```\n\nMake sure you have a valid `tsconfig.json` file with the required path mappings in your project root.\n\n```json\n{\n  \"compilerOptions\": {\n    // ...\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"#app/*\": [\"src/*\"]\n    }\n  }\n}\n```\n\n## How It Works\n\nThe plugin works by intercepting the import statements in your TypeScript files and resolving the path aliases defined in your `tsconfig.json` file. It uses the TypeScript compiler API to parse and resolve the import paths. If an alias is found, it replaces the import path with the actual resolved path during the build process.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\nThis plugin is inspired by the need to handle TypeScript path aliases in projects built with esbuild.\n\n## Contributing\n\nContributions are welcome! If you find a bug or want to add a new feature, feel free to open an issue or submit a pull request.\n\n## Alternatives\n\n- [@esbuild-plugins/tsconfig-path](https://www.npmjs.com/package/@esbuild-plugins/tsconfig-paths)\n- [esbuild-plugin-alias](https://www.npmjs.com/package/esbuild-plugin-alias)\n- [esbuild-plugin-alias-path](https://www.npmjs.com/package/esbuild-plugin-alias-path)\n- [esbuild-plugin-path-alias](https://www.npmjs.com/package/esbuild-plugin-path-alias)\n- [esbuild-plugin-tsconfig-paths](https://www.npmjs.com/package/esbuild-plugin-tsconfig-paths)\n","readmeFilename":"README.md"}