Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# testing

# production
/dist
/lib
/build

# workspace
.vscode
Expand All @@ -15,6 +16,7 @@
.env.development.local
.env.test.local
.env.production.local
.rpt2_cache
npm-debug.log*
yarn-debug.log*
yarn-error.log*
96 changes: 95 additions & 1 deletion package-lock.json

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

25 changes: 16 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
"type": "git",
"url": "https://github.com/csvenke/react-semantics.git"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "lib/index.min.js",
"types": "lib/types/index.d.ts",
"files": [
"dist"
"lib/index.min.js",
"lib/types/index.d.ts",
"lib/types/components"
],
"private": false,
"license": "MIT",
Expand Down Expand Up @@ -43,18 +45,23 @@
"react-dom": "^16.4.1",
"react": "^16.4.1",
"rimraf": "^2.6.2",
"rollup-plugin-typescript2": "^0.16.1",
"rollup-plugin-uglify": "^4.0.0",
"rollup": "^0.63.4",
"ts-jest": "^23.0.1",
"tslint-config-prettier": "^1.14.0",
"tslint-plugin-prettier": "^1.3.0",
"tslint": "^5.11.0",
"typescript": "^2.9.2"
},
"scripts": {
"build": "npm run clean:build && npm run lint && npm run prettify && npm run test && tsc -p ./tsconfig.build.json",
"clean:build": "rimraf ./dist",
"lint": "tslint -c tslint.json './src/**/*'",
"lintfix": "tslint -c tslint.json --fix './src/**/*'",
"prettify": "prettier -c .prettierrc --write \"src/**/*.@(ts|tsx)\"",
"build": "npm run clean:build && npm run lint && npm run test && rollup -c",
"clean:build": "rimraf ./lib",
"lint": "npm run lint:write './src/**/*'",
"lint:fix": "npm run lint:write --fix './src/**/*'",
"lint:write": "tslint -c tslint.json",
"prettier": "npm run prettier:write \"src/**/*.@(ts|tsx)\"",
"prettier:write": "prettier -c .prettierrc --write",
"test": "jest"
},
"husky": {
Expand All @@ -77,7 +84,7 @@
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/dist/"
"<rootDir>/lib/"
],
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.ts",
"moduleFileExtensions": [
Expand Down
31 changes: 31 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import typescript from 'rollup-plugin-typescript2';
import { uglify } from 'rollup-plugin-uglify';
import pkg from './package.json';

const externals = [
...(Object.keys(pkg.dependencies) || {}),
...(Object.keys(pkg.peerDependencies) || {}),
];

const createConfig = ({ output } = {}) => ({
input: 'src/index.ts',
output,
external: externals,
plugins: [
typescript({
useTsconfigDeclarationDir: true,
tsconfig: './tsconfig.build.json',
typescript: require('typescript'),
}),
uglify(),
],
});

export default [
createConfig({
output: {
file: pkg.main,
format: 'cjs',
},
}),
];
6 changes: 4 additions & 2 deletions src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import * as PropTypes from 'prop-types';
import * as React from 'react';

import SwitchCase, { ISwitchCaseProps } from './SwitchCase';
import SwitchDefault from './SwitchDefault';
import SwitchDefault, { ISwitchDefaultProps } from './SwitchDefault';

type SwitchChildProps = ISwitchCaseProps & ISwitchDefaultProps;

export interface ISwitchProps {
/** Conditional statement. */
Expand Down Expand Up @@ -46,7 +48,7 @@ class Switch extends React.Component<ISwitchProps> {

React.Children.forEach(
this.props.children,
(element: React.ReactElement<ISwitchCaseProps>) => {
(element: React.ReactElement<SwitchChildProps>) => {
if (match === undefined && React.isValidElement(element)) {
const caseValue = element.props.value;
child = element;
Expand Down
15 changes: 11 additions & 4 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"outDir": "./lib",
"sourceMap": false,
"declaration": true,
"removeComments": false
"removeComments": false,
"declarationDir": "lib/types"
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
"include": [
"src/index.ts",
"src/components/**/index.ts"
],
"exclude": [
"src/**/*.test.ts",
"src/**/*.test.tsx"
]
}
9 changes: 5 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out",
"outDir": "./build",
"baseUrl": ".",
"typeRoots": ["./node_modules/@types"],
"target": "es5",
Expand All @@ -12,8 +12,9 @@
"sourceMap": true,
"allowSyntheticDefaultImports": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": false
"noUnusedParameters": true
},
"exclude": ["node_modules", "dist"]
"include": [
"src/**/*"
]
}