{"id":15594239,"url":"https://github.com/orta/typescript-web-extension","last_synced_at":"2025-04-30T07:05:09.226Z","repository":{"id":66647403,"uuid":"281179569","full_name":"orta/typescript-web-extension","owner":"orta","description":"A cross-browser extension for working with TypeScript code","archived":false,"fork":false,"pushed_at":"2024-09-03T21:05:13.000Z","size":18,"stargazers_count":21,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T07:04:33.378Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orta.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":null,"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},"funding":{"custom":"https://paypal.me/bytemode"}},"created_at":"2020-07-20T17:12:31.000Z","updated_at":"2024-08-12T18:44:36.000Z","dependencies_parsed_at":"2024-10-23T05:47:54.095Z","dependency_job_id":"4c7274e1-540e-4b16-972c-36a6536d1e2d","html_url":"https://github.com/orta/typescript-web-extension","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":"fregante/browser-extension-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orta%2Ftypescript-web-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orta%2Ftypescript-web-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orta%2Ftypescript-web-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orta%2Ftypescript-web-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orta","download_url":"https://codeload.github.com/orta/typescript-web-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251658201,"owners_count":21622819,"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-10-03T00:35:51.142Z","updated_at":"2025-04-30T07:05:09.176Z","avatar_url":"https://github.com/orta.png","language":"JavaScript","funding_links":["https://paypal.me/bytemode"],"categories":[],"sub_categories":[],"readme":"# browser-extension-template\n\n[link-webext-polyfill]: https://github.com/mozilla/webextension-polyfill\n[link-rgh]: https://github.com/sindresorhus/refined-github\n[link-ngh]: https://github.com/sindresorhus/notifier-for-github\n[link-hfog]: https://github.com/sindresorhus/hide-files-on-github\n[link-tsconfig]: https://github.com/sindresorhus/tsconfig\n[link-xo-ts]: https://github.com/xojs/eslint-config-xo-typescript\n[link-options-sync]: https://github.com/fregante/webext-options-sync\n[link-cws-keys]: https://github.com/DrewML/chrome-webstore-upload/blob/master/How%20to%20generate%20Google%20API%20keys.md\n[link-amo-keys]: https://addons.mozilla.org/en-US/developers/addon/api/key\n\n\u003e Barebones boilerplate with webpack, options handler and auto-publishing.\n\n![Sample extension output](media/previewer.png)\n\n## Features\n\n- Use modern Promise-based `browser.*` APIs [webextension-polyfill][link-webext-polyfill].\n- [Auto-syncing options](#auto-syncing-options).\n- [Auto-publishing](#publishing) with auto-versioning and support for manual releases.\n- [Extensive configuration documentation](#configuration).\n\nThis extension template is heavily inspired by [refined-github][link-rgh], [notifier-for-github][link-ngh], and [hide-files-on-github][link-hfog] browser extensions. You can always refer to these browser extensions' source code if you find anything confusing on how to create a new extension.\n\n## How to use this template\n\nClick [\u003ckbd\u003eUse this template\u003c/kbd\u003e](https://github.com/notlmn/browser-extension-template/generate) and make a copy of your own. 😉\n\n## Configuration\n\nThe extension doesn't target any specific ECMAScript environment or provide any transpiling by default. The extensions output will be the same ECMAScript you write. This allows us to always target the latest browser version, which is a good practice you should be following.\n\n### Webpack\n\n#### Transpiling using Babel\n\nThe template bakes in a pretty basic webpack config, with no transpiling. To setup transpiling using Babel follow the following configuration steps.\n\n1. Install Babel packages and respective loader for webpack.\n\n\t``` sh\n\tnpm i --save-dev @babel/core @babel/preset-env babel-loader\n\t```\n1. In `webpack.config.js`, add the following rule to process JS files.\n\n\t``` js\n\tmodule: {\n\t\trules: [\n\t\t\t{\n\t\t\t\ttest: /\\.js$/,\n\t\t\t\texclude: /node_modules/,\n\t\t\t\tloader: 'babel-loader'\n\t\t\t}\n\t\t]\n\t}\n\t```\n1. Target respective browsers using `.babelrc`.\n\n\t``` json\n\t{\n\t\t\"presets\": [\n\t\t\t[\"@babel/preset-env\", {\n\t\t\t\t\"targets\": {\n\t\t\t\t\t\"chrome\": \"74\",\n\t\t\t\t\t\"firefox\": \"67\"\n\t\t\t\t}\n\t\t\t}]\n\t\t]\n\t}\n\t```\n\n#### Extracting CSS\n\nIf you will be writing any code that will be importing CSS files from JS files, then you will be needing `mini-css-extract-plugin` to extract this imported CSS into its own file.\n\n1. Install the webpack plugin.\n\n\t``` sh\n\tnpm i --save-dev mini-css-extract-plugin\n\t```\n1. Modify the webpack config as mentioned to let this plugin handle CSS imports.\n\n\t``` js\n\t// Import plugin\n\tconst MiniCssExtractPlugin = require('mini-css-extract-plugin');\n\n\t// Under `module.rules`\n\t{\n\t\ttest: /\\.css$/,\n\t\tuse: [\n\t\t\tMiniCssExtractPlugin.loader,\n\t\t\t'css-loader'\n\t\t]\n\t}\n\n\t// Under `plugins`\n\tnew MiniCssExtractPlugin({\n\t\tfilename: 'content.css'\n\t})\n\t```\n\n#### TypeScript\n\nTypeScript and Babel configs conflict each other, so you can only use one of these configuration types at any point.\n\n1. Install TypeScript and respective loader for webpack\n\n\t``` sh\n\tnpm i --save-dev typescript ts-loader @types/firefox-webext-browser\n\t```\n1. Use the following webpack rule in the config file.\n\n\t``` js\n\t{\n\t\ttest: /\\.(js|ts|tsx)$/,\n\t\tloader: 'ts-loader',\n\t\texclude: /node_modules/\n\t},\n\t```\n\n1. Use the following as `tsconfig.json`, uses [sindresorhus/tsconfig][link-tsconfig] (install it as dependecy before using).\n\n\t``` json\n\t{\n\t\t\"extends\": \"@sindresorhus/tsconfig\",\n\t\t\"compilerOptions\": {\n\t\t\t\"target\": \"esnext\",\n\t\t\t\"declaration\": false\n\t\t},\n\t\t\"include\": [\n\t\t\t\"source\"\n\t\t]\n\t}\n\t```\n\nTypeScript requires additional configuration depending on how you set it up, like [linting][link-xo-ts].\n\n### Auto-syncing options\n\nOptions are managed by [fregante/webext-options-sync][link-options-sync], which auto-saves and auto-restores the options form, applies defaults and runs migrations.\n\n### Publishing\n\nIt's possible to publish to both the Chrome Web Store and Mozilla Addons at once by creating these ENV variables:\n\n1. `CLIENT_ID`, `CLIENT_SECRET`, and `REFRESH_TOKEN` from [Google APIs][link-cws-keys].\n1. `WEB_EXT_API_KEY`, and `WEB_EXT_API_SECRET` from [AMO][link-amo-keys].\n\nAnd then running:\n\n``` sh\nnpm run release\n```\n\nThis will:\n\n1. Build the extension\n1. Create a version number based on the current UTC time, like [`19.6.16.428`](https://github.com/fregante/daily-version) and sets it in the manifest.json\n1. Deploy it to both stores\n\n#### Auto-publishing\n\nThanks to the included [GitHub Action Workflows](.github/workflows), if you set up those ENVs in the repo's Settings, the deployment will automatically happen:\n\n- when creating a `deploy` tag (it will use the current date/time as version, like [`19.6.16.428`](hhttps://github.com/fregante/daily-version))\n- when creating a specific version tag based on the same date format (like `20.1.2` or `20.1.2.3`)\n- on a schedule, by default [every week](.github/workflows/deploy-automatic.yml) (but only if there are any new commits in the last tag)\n\n### License\n\nThis browser extension template is released under [CC0](#license) and mentioned below. There is no `license` file included in here, but when you clone this template, you should include your own license file for the specific license you choose to use.\n\n## Credits\n\nExtension icon made by [Freepik](https://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0).\n\n## Extensions created using this template\n\n- [notlmn/copy-as-markdown](https://github.com/notlmn/copy-as-markdown) - Browser extension to copy hyperlinks, images, and selected text as Markdown.\n\n## License\n\n[![CC0](https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg)](https://creativecommons.org/publicdomain/zero/1.0/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forta%2Ftypescript-web-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forta%2Ftypescript-web-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forta%2Ftypescript-web-extension/lists"}