Skip to content

Commit

Permalink
chore(*): move to Jest and Typescript
Browse files Browse the repository at this point in the history
- got rid of nwb
- using tsc for builds and webpack for dev
- now using a hook for most logic
- Upgraded to React 16.8.x

BREAKING CHANGE: Using named exports
  • Loading branch information
rahsheen committed Mar 5, 2019
1 parent b545d7c commit 84a2576
Show file tree
Hide file tree
Showing 9 changed files with 10,033 additions and 12,291 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/coverage
/demo/dist
/es
/lib
/node_modules
/umd
/build
/dist
/examples/dist
npm-debug.log*
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src
examples
.babelrc
.gitignore
webpack.config.js
13 changes: 13 additions & 0 deletions examples/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<title>My Component Demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
</body>
</html>
6 changes: 3 additions & 3 deletions demo/src/index.js → examples/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from "react"
import { render } from "react-dom"
import { Wizard } from "../../build/lib/"
import { Wizard } from "../../src"

class Demo extends Component {
class App extends Component {
render() {
return (
<div>
Expand Down Expand Up @@ -52,4 +52,4 @@ class Demo extends Component {
}
}

render(<Demo />, document.querySelector("#demo"))
render(<App />, document.getElementById("root"))
7 changes: 0 additions & 7 deletions nwb.config.js

This file was deleted.

22,179 changes: 9,920 additions & 12,259 deletions package-lock.json

Large diffs are not rendered by default.

50 changes: 34 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
"version": "0.0.0-development",
"description": "@rahsheen/react-wizard React component",
"main": "lib/index.js",
"module": "es/index.js",
"module": "lib/index.js",
"files": [
"css",
"es",
"lib",
"umd"
"lib"
],
"scripts": {
"build": "tsc && nwb build-react-component",
"build:ts": "tsc",
"clean": "nwb clean-module && nwb clean-demo",
"prepublishOnly": "npm run build",
"start": "nwb serve-react-demo",
"build:demo": "webpack --mode production",
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"build:umd": "tsc --module umd --target es5 --outDir dist/umd",
"clean": "rm -rf build",
"prepublishOnly": "npm run build:ts",
"start": "webpack-dev-server --mode development",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
Expand All @@ -24,28 +26,40 @@
},
"dependencies": {},
"peerDependencies": {
"react": "16.x"
"react": "16.x",
"react-dom": "16.x"
},
"devDependencies": {
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@types/jest": "^24.0.9",
"@types/node": "^11.10.4",
"@types/react-dom": "^16.8.2",
"@types/react": "^16.8.6",
"@types/react-dom": "^16.8.2",
"awesome-typescript-loader": "^5.2.1",
"babel-cli": "^6.26.0",
"babel-jest": "^24.1.0",
"jest-dom": "^3.1.2",
"babel-loader": "^8.0.5",
"css-loader": "^2.1.0",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.1.0",
"nwb": "0.23.x",
"jest-dom": "^3.1.2",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-test-renderer": "^16.8.3",
"react-testing-library": "^6.0.0",
"react": "^16.8.3",
"rollup": "^1.4.1",
"semantic-release": "^15.13.3",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
"travis-deploy-once": "^5.0.11",
"ts-jest": "^24.0.0",
"typescript": "^3.3.3333"
"typescript": "^3.3.3333",
"uglifyjs": "^2.4.11",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.2.1"
},
"author": "Rahsheen A. Porter",
"homepage": "https://rporter.tech",
Expand All @@ -55,6 +69,10 @@
"url": "https://github.com/rahsheen/react-wizard.git"
},
"keywords": [
"react-component"
"react-component",
"react",
"hooks",
"wizard",
"multi-step"
]
}
8 changes: 3 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"outDir": "build/lib",
"outDir": "lib",
"module": "commonjs",
"target": "es5",
"lib": ["es5", "es6", "es7", "es2017", "dom"],
Expand All @@ -13,16 +13,14 @@
"removeComments": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"declaration": false,
"declaration": false,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": [
"node_modules",
"build",
"build/lib",
"scripts",
"es",
"lib",
Expand All @@ -35,4 +33,4 @@
"src/**/*.stories.js",
"src/**/*.stories.ts"
]
}
}
53 changes: 53 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const htmlWebpackPlugin = new HtmlWebpackPlugin({
template: path.join(__dirname, "examples/src/index.html"),
filename: "./index.html"
})

module.exports = {
entry: path.join(__dirname, "examples/src/index.js"),
output: {
path: path.join(__dirname, "examples/dist"),
filename: "bundle.js"
},

// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",

resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"]
},

module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{
test: /\.tsx?$/,
loader: "awesome-typescript-loader"
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},

// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},

// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
// externals: {
// react: "React",
// "react-dom": "ReactDOM"
// },
plugins: [htmlWebpackPlugin],
devServer: {
port: 3000
}
}

0 comments on commit 84a2576

Please sign in to comment.