├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── appveyor.yml ├── mocha.opts ├── package.json ├── rollup.config.js ├── scripts └── move-type-declarations.js ├── src └── index.ts ├── test └── test.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | *.d.ts 4 | dist -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | 5 | env: 6 | global: 7 | - BUILD_TIMEOUT=10000 -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # TODO changelog 2 | 3 | ## 1.0.0 4 | 5 | * First release -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Rich Harris 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # typescript-lib 2 | 3 | Clone this project template with [degit](https://github.com/Rich-Harris/degit): 4 | 5 | ```bash 6 | npx degit rich-harris/typescript-lib my-new-lib 7 | cd my-new-lib 8 | yarn 9 | ``` 10 | 11 | Remember to update a) the package.json with the correct name, b) the Rollup config, and c) this README. 12 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # http://www.appveyor.com/docs/appveyor-yml 2 | 3 | version: "{build}" 4 | 5 | clone_depth: 10 6 | 7 | init: 8 | - git config --global core.autocrlf false 9 | 10 | environment: 11 | matrix: 12 | # node.js 13 | - nodejs_version: 8 14 | 15 | install: 16 | - ps: Install-Product node $env:nodejs_version 17 | - npm install 18 | 19 | build: off 20 | 21 | test_script: 22 | - node --version && npm --version 23 | - npm test 24 | 25 | matrix: 26 | fast_finish: false 27 | 28 | # cache: 29 | # - C:\Users\appveyor\AppData\Roaming\npm-cache -> package.json # npm cache 30 | # - node_modules -> package.json # local npm modules 31 | -------------------------------------------------------------------------------- /mocha.opts: -------------------------------------------------------------------------------- 1 | --require sucrase/register 2 | test/test.ts -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TODO", 3 | "description": "TODO", 4 | "version": "1.0.0", 5 | "repository": "Rich-Harris/TODO", 6 | "main": "dist/TODO.umd.js", 7 | "module": "dist/TODO.esm.js", 8 | "types": "types/index.d.ts", 9 | "files": [ 10 | "dist", 11 | "types" 12 | ], 13 | "devDependencies": { 14 | "@types/mocha": "^5.2.5", 15 | "@types/node": "^10.9.4", 16 | "mocha": "^5.2.0", 17 | "rollup": "^0.65.2", 18 | "rollup-plugin-sucrase": "^2.1.0", 19 | "sander": "^0.6.0", 20 | "sucrase": "^3.9.5", 21 | "tiny-glob": "^0.2.6" 22 | }, 23 | "scripts": { 24 | "build-declarations": "tsc -d && node scripts/move-type-declarations.js", 25 | "build": "npm run build-declarations && rollup -c", 26 | "dev": "rollup -cw", 27 | "test": "mocha --opts mocha.opts", 28 | "prepublishOnly": "npm test && npm run build" 29 | }, 30 | "license": "MIT" 31 | } 32 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import sucrase from 'rollup-plugin-sucrase'; 2 | import pkg from './package.json'; 3 | 4 | export default { 5 | input: 'src/index.ts', 6 | output: [ 7 | { file: pkg.main, format: 'umd', name: 'TODO' }, 8 | { file: pkg.module, format: 'esm' } 9 | ], 10 | plugins: [ 11 | sucrase({ 12 | transforms: ['typescript'] 13 | }) 14 | ] 15 | }; 16 | -------------------------------------------------------------------------------- /scripts/move-type-declarations.js: -------------------------------------------------------------------------------- 1 | const sander = require('sander'); 2 | const glob = require('tiny-glob/sync'); 3 | 4 | for (const file of glob('src/**/*.js')) { 5 | sander.unlinkSync(file); 6 | } 7 | 8 | sander.rimrafSync('types'); 9 | for (const file of glob('src/**/*.d.ts')) { 10 | sander.renameSync(file).to(file.replace(/^src/, 'types')); 11 | } -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | // TODO write some code 2 | export function hello() { 3 | return 'hello world!'; 4 | } 5 | -------------------------------------------------------------------------------- /test/test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | import * as UNTITLED from '../src/index'; 3 | 4 | describe('UNTITLED', () => { 5 | it('returns hello world', () => { 6 | assert.equal(UNTITLED.hello(), 'hello world!'); 7 | }); 8 | 9 | it('has tests', () => { 10 | assert.ok(false); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": true, 4 | "diagnostics": true, 5 | "noImplicitThis": true, 6 | "noEmitOnError": true, 7 | "lib": ["es5", "es6", "dom"] 8 | }, 9 | "target": "ES5", 10 | "module": "ES6", 11 | "include": [ 12 | "src" 13 | ], 14 | "exclude": [ 15 | "node_modules" 16 | ] 17 | } --------------------------------------------------------------------------------