Skip to content

Commit

Permalink
refactor(pkg): uses typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
rohmanhm committed Feb 24, 2019
1 parent bad1004 commit 3dcaf87
Show file tree
Hide file tree
Showing 14 changed files with 1,233 additions and 1,591 deletions.
12 changes: 0 additions & 12 deletions .babelrc

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.DS_Store
node_modules

*.log
*.log
dist
.rpt2*
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!dist
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"licenser.author": "MH Rohman",
"licenser.license": "MIT"
}
2 changes: 1 addition & 1 deletion dist/nullfined.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/nullfined.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions index.js

This file was deleted.

55 changes: 20 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,41 @@
"description": "Convert any null value to undefined",
"version": "1.0.0",
"main": "dist/nullfined.js",
"module": "index.js",
"types": "types/index.d.ts",
"license": "MIT",
"author": {
"name": "Roman Masyhar",
"email": "[email protected]",
"url": "https://github.com/rohmanhm"
},
"files": [
"src",
"dist"
],
"repository": "rohmanhm/nullfined",
"devDependencies": {
"ava": "^1.0.1",
"babel-cli": "^6.24.1",
"babel-eslint": "^8.0.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-latest": "^6.24.1",
"babelrc-rollup": "^3.0.0",
"eslint-config-airbnb-base": "^12.0.0",
"eslint": "^5.0.0",
"eslint-plugin-import": "^2.2.0",
"rollup": "^0.65.0",
"rollup-plugin-babel": "^3.0.0",
"rollup-plugin-uglify": "^4.0.0",
"xo": "^0.22.0"
"ava": "^1.2.1",
"lodash.camelcase": "^4.3.0",
"rollup": "^1.2.3",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.1",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.19.2",
"rollup-plugin-uglify": "^6.0.2",
"tslint": "^5.13.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.3.3333"
},
"dependencies": {
"vaper": "^0.0.1"
"vaper": "^1.0.1-0"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"test": "xo && ava"
},
"xo": {
"extends": "airbnb-base",
"plugins": [
"import"
],
"rules": {
"unicorn/filename-case": [
"error",
{
"case": "camelCase"
}
]
}
"test": "ava"
},
"ava": {
"verbose": true
"verbose": true,
"ignore": [
"rollup.config.js",
"test"
]
}
}
41 changes: 28 additions & 13 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
import babel from 'rollup-plugin-babel';
import babelrc from 'babelrc-rollup'; // eslint-disable-line import/extensions
import uglify from 'rollup-plugin-uglify';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import sourceMaps from 'rollup-plugin-sourcemaps';
import typescript from 'rollup-plugin-typescript2';
import camelCase from 'lodash.camelcase';
import { uglify } from 'rollup-plugin-uglify';

const pkg = require('./package.json');

const external = Object.keys(pkg.dependencies);

const libraryName = 'nullfined';

export default {
entry: pkg.module,
plugins: [
babel(babelrc()),
uglify(),
],
external,
targets: [
input: 'src/index.ts',
output: [
{
dest: pkg.main,
file: pkg.main,
name: camelCase(libraryName),
format: 'umd',
moduleName: 'Nullfined',
sourceMap: true,
sourcemap: true,
},
],
plugins: [
// Compile TypeScript files
typescript({ useTsconfigDeclarationDir: true }),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),

// Resolve source maps to the original source
sourceMaps(),
uglify(),
],
external,
};
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2019 rohmanhm
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

import vaper from 'vaper'

export default function<T = any>(data: T): T {
return vaper(null, undefined)(data)
}
15 changes: 15 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"declaration": true,
"declarationDir": "types",
"esModuleInterop": true,
"moduleResolution": "node",
"sourceMap": true,
"baseUrl": "./src",
"outDir": "dist",
"noImplicitAny": true
},
"exclude": ["node_modules", "dist", "types"]
}
9 changes: 9 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"defaultSeverity": "error",
"extends": ["tslint:recommended", "tslint-config-standard"],
"jsRules": {},
"rules": {
"interface-name": false
},
"rulesDirectory": []
}
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function <T = any>(data: T): T;
Loading

0 comments on commit 3dcaf87

Please sign in to comment.