{"id":21930065,"url":"https://github.com/aheissenberger/esbuild-plugin-text-replace","last_synced_at":"2025-04-19T18:53:23.361Z","repository":{"id":49263377,"uuid":"366487335","full_name":"aheissenberger/esbuild-plugin-text-replace","owner":"aheissenberger","description":"Replace content before bundling with support for Filefilter, Namespace, Regex and Functions.","archived":false,"fork":false,"pushed_at":"2023-03-26T11:12:47.000Z","size":620,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-16T09:01:29.581Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aheissenberger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-11T19:07:29.000Z","updated_at":"2024-11-11T15:49:05.000Z","dependencies_parsed_at":"2024-06-18T21:16:50.727Z","dependency_job_id":"5f51d403-0dba-49e4-af89-296d3b7874d7","html_url":"https://github.com/aheissenberger/esbuild-plugin-text-replace","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"3a8bf9a47eed6064ba955d41afb5089c229621a7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fesbuild-plugin-text-replace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fesbuild-plugin-text-replace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fesbuild-plugin-text-replace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fesbuild-plugin-text-replace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aheissenberger","download_url":"https://codeload.github.com/aheissenberger/esbuild-plugin-text-replace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249769973,"owners_count":21323067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T23:07:34.278Z","updated_at":"2025-04-19T18:53:23.344Z","avatar_url":"https://github.com/aheissenberger.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esbuild-plugin-text-replace\n\nReplace content before bundling with support for Filefilter, Namespace and Regex.\n\n## Install\n\n    $ npm install --save-dev esbuild-plugin-text-replace\n\n**Hint:** Node \u003e=10.1.0 for fs.promise\n\n## Usage\n\n**as a plugin**\n```js\nimport esbuild from 'esbuild'\nimport textReplace from 'esbuild-plugin-text-replace'\n\nawait esbuild.build(\n    {\n        entryPoints: ['./test-build-input'],\n        outfile: 'test-build-out.js',\n        plugins: [ \n            textReplace(\n                {\n                    include: /mypackage\\/dist\\/loader\\.js$/,\n                    pattern:[\n                        ['const installRetry','let installRetry'],\n                        [/const\\s+{\\s*textReplace\\s*}\\s*=\\s*require\\s*\\(\\s*'esbuild-plugin-text-replace'\\s*\\)\\s*;/g , \"'import textReplace from 'esbuild-plugin-text-replace'\"]\n                    ]\n                }\n            )\n        ],\n    }\n)\n```\n\n**as part of a pipe**\n```js\nimport esbuild from 'esbuild';\nimport pipe from 'esbuild-plugin-pipe';\nimport textReplace from 'esbuild-plugin-text-replace';\n\nawait esbuild.build(\n    {\n        entryPoints: ['./test-build-input'],\n        outfile: 'test-build-out.js',\n        bundle: true,\n        plugins: [\n            pipe({\n                filter: /.*/,\n                namespace: '',\n                plugins: [\n                    textReplace(\n                        {\n                            include: /mypackage\\/dist\\/loader\\.js$/,\n                            pattern:[\n                                ['const installRetry','let installRetry'],\n                                [/const\\s+{\\s*textReplace\\s*}\\s*=\\s*require\\s*\\(\\s*'esbuild-plugin-text-replace'\\s*\\)\\s*;/g , \"'import textReplace from 'esbuild-plugin-text-replace'\"]\n                            ]\n                        }\n                    )\n                ]\n            })\n        ]\n    }\n)\n```\n\n## Options\n\n### `include`\n\nFilter filepath by regex.\n\nType: `RegExp`\nDefault: `/.*/`\n\n\u003e **Note:** Try to never use the default value as this is has a huge impact on speed if all files are matched!\n\n### `namespace`\n\nType: `String`\nDefault: all\n\nMore info about [esbuild namespaces](https://esbuild.github.io/plugins/#namespaces)\n\n### `pattern`\n\nSearch with Text or Regex and replace the found content with a string.\n\nType: `Array`\nDefault: `[]`\n\nAll  information about the [replaceAll regex Options and replacer functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll).\n\n\n**Examples:**\n```js\n[\n    // transform 2020-10-02 to 02.10.2020\n    [/(\\d{4})-(\\d{2})-(\\d{2})/g , (match,p1,p2,p3,offset,wholeString)=\u003e`${p3}.${p2}.${p1}`], \n    ['__buildVersion' , '\"1.1.1\"'],\n    [/(\\s*)const(\\s+a\\s*=\\s*1[\\s;\\n])/g, '$1let$2']\n]\n```\n\u003e **Note:** `/g` for globale replacement is a must requirement\n\n## History\n\n* 1.3.0 **pipe mode only:** Use the regex from parameter include to transform only files which match\n* 1.2.0 Add [esbuild pipe](https://github.com/nativew/esbuild-plugin-pipe) support\n* 1.1.3 Initial relase\n## Roadmap\n\n - [X] tests\n - [ ] speed tests\n\n## Contribution\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.\n\n1. Fork the Project\n1. Create your Feature Branch (git checkout -b feature/AmazingFeature)\n1. Commit your Changes (git commit -m 'Add some AmazingFeature')\n1. Push to the Branch (git push origin feature/AmazingFeature)\n1. Open a Pull Request\n\n## Built With\n\n- [microbundle](https://github.com/developit/microbundle)\n\n## License\n\nDistributed under the \"bsd-2-clause\" License. See [LICENSE.txt](LICENSE.txt) for more information.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheissenberger%2Fesbuild-plugin-text-replace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faheissenberger%2Fesbuild-plugin-text-replace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheissenberger%2Fesbuild-plugin-text-replace/lists"}