{"id":15819559,"url":"https://github.com/florianrappl/ts-node-browser-hybrid-example","last_synced_at":"2026-05-02T17:32:46.999Z","repository":{"id":147576777,"uuid":"79749387","full_name":"FlorianRappl/ts-node-browser-hybrid-example","owner":"FlorianRappl","description":"Simple example to create an hybrid Node.js / web version of a library with TypeScript.","archived":false,"fork":false,"pushed_at":"2017-01-22T22:11:30.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-06T06:41:35.510Z","etag":null,"topics":["browserify","example","gulp","library","node","package","typescript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FlorianRappl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-01-22T22:10:43.000Z","updated_at":"2017-01-22T22:11:31.000Z","dependencies_parsed_at":"2023-05-31T16:30:32.893Z","dependency_job_id":null,"html_url":"https://github.com/FlorianRappl/ts-node-browser-hybrid-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fts-node-browser-hybrid-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fts-node-browser-hybrid-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fts-node-browser-hybrid-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianRappl%2Fts-node-browser-hybrid-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FlorianRappl","download_url":"https://codeload.github.com/FlorianRappl/ts-node-browser-hybrid-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246591782,"owners_count":20801986,"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":["browserify","example","gulp","library","node","package","typescript"],"created_at":"2024-10-05T06:41:44.348Z","updated_at":"2026-05-02T17:32:46.962Z","avatar_url":"https://github.com/FlorianRappl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Dev dependencies][dependencies-badge]][dependencies]\n[![Node.js version][nodejs-badge]][nodejs]\n[![NPM version][npm-badge]][npm]\n[![MIT License][license-badge]][license]\n[![PRs Welcome][prs-badge]][prs]\n\n# ts-node-browser-hybrid-example\n\nMinimalistic example to jump-start a library project written in [TypeScript][typescript] that runs on [Node.js][nodejs] and in [browsers][browserify]!\n\nProvides a basic template using the following set of utilities:\n\n+ [TypeScript][typescript] for transpilation,\n+ [Mocha][mocha] unit testing and coverage,\n+ [Nock][nock] to be used for HTTP mocking,\n+ [Gulp][gulp] for all development tasks,\n+ *.editorconfig* for consistent file format.\n\nThe unit tests are written in plain JavaScript, the source is fully written in TypeScript.\n\n## Quick Start\n\nThis example is intended to be used with Node.js v6 or later and a recent version of NPM. Make sure you have those installed. Then just type following commands:\n\n```bash\ngit clone https://github.com/FlorianRappl/ts-node-browser-hybrid-example\ncd ts-node-browser-hybrid-example\nnpm install\n```\n\nWhile tools such as Gulp and TypeScript are also obtained for the local repository it makes sense to have these dependencies also globally installed.\n\n## Gulp Tasks\n\nThe example comes with the following Gulp tasks, which should provide a quick useful basis:\n\n* `build` to build both versions\n* `build-browser` to build the browser version\n* `build-node` to build the Node.js version\n* `test` to run the unit tests\n\nThe unit tests are setup to run only in the Node.js environment (thus making efficient use of the hybrid scenario). All distributables are stored in the respective folder in the `dist` directory.\n\nBy default Gulp runs `build` with a subsequent `test` execution.\n\n## Examples\n\nThe constructed example library uses 3 files and the `http` module. The root file (*index.ts*) exports its (pseudo) API to showcase how to deal with such a hybrid approach.\n\nIn the browser space the minimum way to see how this example can be used is as follows.\n\n```html\n\u003c!DOCTYPE HTML\u003e\n\u003cscript src=\"dist/browser/app.js\"\u003e\u003c/script\u003e\n\u003cscript\u003eapp();\u003c/script\u003e\n```\n\nPlease note that the request may fail due to CORS restrictions (however, the important part is that a request is being performed). The name (`app`) can be changed in the *gulpfile.js*.\n\nFor Node.js we have the usual straight forward approach:\n\n```js\nconst app = require('./dist/node/index.js');\napp();\n```\n\nSimilarly, if the library would be a real dependency (not the same directory) a simple `require('ts-node-browser-hybrid-example')` resolution would do the job. Here the name needs to replaced with the name of the library, of course.\n\n## License\n\nMIT License. See the [LICENSE][license] file.\n\n[dependencies-badge]: https://david-dm.org/FlorianRappl/ts-node-browser-hybrid-example/dev-status.svg\n[dependencies]: https://david-dm.org/FlorianRappl/ts-node-browser-hybrid-example?type=dev\n[nodejs-badge]: https://img.shields.io/badge/node-\u003e=%206.0.0-blue.svg\n[nodejs]: https://nodejs.org/dist/latest-v6.x/docs/api/\n[browserify]: http://browserify.org\n[npm-badge]: https://img.shields.io/badge/npm-\u003e=%203.10.9-blue.svg\n[npm]: https://docs.npmjs.com/\n[typescript]: https://www.typescriptlang.org/\n[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[license]: https://github.com/FlorianRappl/ts-node-browser-hybrid-example/blob/master/LICENSE\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg\n[prs]: http://makeapullrequest.com\n[mocha]: https://mochajs.org\n[nock]: https://github.com/node-nock/nock\n[gulp]: http://gulpjs.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianrappl%2Fts-node-browser-hybrid-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorianrappl%2Fts-node-browser-hybrid-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianrappl%2Fts-node-browser-hybrid-example/lists"}