mirror of
https://github.com/bendtherules/react-fiber-traverse.git
synced 2026-08-18 13:52:36 +00:00
Init with yo typescript-react-lib
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
**/dist/
|
||||
**/node_modules/
|
||||
coverage/
|
||||
@@ -0,0 +1,37 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: {
|
||||
jsx: true
|
||||
}
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect'
|
||||
}
|
||||
},
|
||||
extends: [
|
||||
'plugin:react/recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier',
|
||||
'prettier/@typescript-eslint'
|
||||
],
|
||||
plugins: ['react', 'react-hooks', '@typescript-eslint'],
|
||||
rules: {
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-member-accessibility': 'off',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
'react-hooks/rules-of-hooks': 'error'
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.js'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-var-requires': 'off'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
compiled/
|
||||
coverage/
|
||||
dist/
|
||||
node_modules/
|
||||
@@ -0,0 +1,3 @@
|
||||
compiled/
|
||||
coverage/
|
||||
dist/
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"dist/react-fiber-traverse.cjs.development.js": {
|
||||
"bundled": 258,
|
||||
"minified": 203,
|
||||
"gzipped": 164
|
||||
},
|
||||
"dist/react-fiber-traverse.cjs.production.js": {
|
||||
"bundled": 163,
|
||||
"minified": 124,
|
||||
"gzipped": 125
|
||||
},
|
||||
"dist/react-fiber-traverse.esm.js": {
|
||||
"bundled": 234,
|
||||
"minified": 183,
|
||||
"gzipped": 154,
|
||||
"treeshaked": {
|
||||
"rollup": {
|
||||
"code": 87,
|
||||
"import_statements": 74
|
||||
},
|
||||
"webpack": {
|
||||
"code": 1168
|
||||
}
|
||||
}
|
||||
},
|
||||
"dist/react-fiber-traverse.umd.development.js": {
|
||||
"bundled": 611,
|
||||
"minified": 400,
|
||||
"gzipped": 259
|
||||
},
|
||||
"dist/react-fiber-traverse.umd.production.js": {
|
||||
"bundled": 477,
|
||||
"minified": 304,
|
||||
"gzipped": 216
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
notifications:
|
||||
email: false
|
||||
script:
|
||||
- npm t
|
||||
- $(npm bin)/codecov
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019-present bendtherules <abhasbhattacharya2@gmail.com>
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,71 @@
|
||||
# react-fiber-traverse
|
||||
|
||||
[![npm version][npmv-image]][npmv-url]
|
||||
[![build status][travis-image]][travis-url]
|
||||
[![coverage status][codecov-image]][codecov-url]
|
||||
[![npm downloads][npmd-image]][npmd-url]
|
||||
|
||||
> Traverse and other utils on top of React fiber tree
|
||||
|
||||
## Basic Usage
|
||||
|
||||
```jsx
|
||||
import React from 'react'
|
||||
import { render } from 'react-dom'
|
||||
|
||||
render(, document.getElementById('root'))
|
||||
```
|
||||
|
||||
## Live Examples
|
||||
|
||||
- [Basic Usage](https://codesandbox.io/)
|
||||
- [API Example](https://codesandbox.io/)
|
||||
- [UMD Build (Development)](https://codesandbox.io/)
|
||||
- [UMD Build (Production)](https://codesandbox.io/)
|
||||
|
||||
## API
|
||||
|
||||
**Props**
|
||||
|
||||
- `foo` - Something something.
|
||||
- `bar` - _Optional_ Something something. Defaults to `null`.
|
||||
|
||||
**Example**
|
||||
|
||||
```jsx
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ npm install react-fiber-traverse --save
|
||||
```
|
||||
|
||||
There are also UMD builds available via [unpkg](https://unpkg.com/):
|
||||
|
||||
- https://unpkg.com/react-fiber-traverse/dist/react-fiber-traverse.umd.development.js
|
||||
- https://unpkg.com/react-fiber-traverse/dist/react-fiber-traverse.umd.production.js
|
||||
|
||||
For the non-minified development version, make sure you have already included:
|
||||
|
||||
- [`React`](https://unpkg.com/react/umd/react.development.js)
|
||||
- [`ReactDOM`](https://unpkg.com/react-dom/umd/react-dom.development.js)
|
||||
- [`PropTypes`](https://unpkg.com/prop-types/prop-types.js)
|
||||
|
||||
For the minified production version, make sure you have already included:
|
||||
|
||||
- [`React`](https://unpkg.com/react/umd/react.production.min.js)
|
||||
- [`ReactDOM`](https://unpkg.com/react-dom/umd/react-dom.production.min.js)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/bendtherules/react-fiber-traverse/master.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/bendtherules/react-fiber-traverse
|
||||
[codecov-image]: https://img.shields.io/codecov/c/github/bendtherules/react-fiber-traverse.svg?style=flat-square
|
||||
[codecov-url]: https://codecov.io/gh/bendtherules/react-fiber-traverse
|
||||
[npmv-image]: https://img.shields.io/npm/v/react-fiber-traverse.svg?style=flat-square
|
||||
[npmv-url]: https://www.npmjs.com/package/react-fiber-traverse
|
||||
[npmd-image]: https://img.shields.io/npm/dm/react-fiber-traverse.svg?style=flat-square
|
||||
[npmd-url]: https://www.npmjs.com/package/react-fiber-traverse
|
||||
@@ -0,0 +1 @@
|
||||
comment: off
|
||||
@@ -0,0 +1 @@
|
||||
REACT_APP_DESCRIPTION=$npm_package_description
|
||||
@@ -0,0 +1 @@
|
||||
/node_modules
|
||||
@@ -0,0 +1,15 @@
|
||||
# reactFiberTraverse Basic Usage Example
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.<br>
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.<br>
|
||||
You will also see any lint errors in the console.
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "basic-usage",
|
||||
"description": "reactFiberTraverse Basic Usage Example",
|
||||
"keywords": [
|
||||
"react-fiber-traverse"
|
||||
],
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"react": "16.8.6",
|
||||
"react-dom": "16.8.6",
|
||||
"react-scripts": "3.0.1",
|
||||
"react-fiber-traverse": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>%REACT_APP_DESCRIPTION%</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg width="40" height="40" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="5" y="5" width="30" height="30" stroke="black" fill="transparent" stroke-width="5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 181 B |
@@ -0,0 +1,5 @@
|
||||
import C from 'react-fiber-traverse'
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
|
||||
ReactDOM.render(<C />, document.getElementById('root'))
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./react-fiber-traverse.cjs.production.js')
|
||||
} else {
|
||||
module.exports = require('./react-fiber-traverse.cjs.development.js')
|
||||
}
|
||||
Generated
+12243
File diff suppressed because it is too large
Load Diff
+110
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"name": "react-fiber-traverse",
|
||||
"version": "0.0.1",
|
||||
"description": "Traverse and other utils on top of React fiber tree",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/react-fiber-traverse.esm.js",
|
||||
"jsnext:main": "dist/react-fiber-traverse.esm.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"authors": "shelljs-authors > AUTHORS",
|
||||
"build": "run-s clean compile bundle",
|
||||
"bundle": "rollup -c",
|
||||
"changelog": "github_changelog_generator --no-issues --header-label \"# Changelog\" --future-release v$npm_package_version",
|
||||
"check:format": "prettier --list-different \"**/*.{js,ts,tsx}\"",
|
||||
"check:types": "tsc --noEmit",
|
||||
"clean": "run-p clean:*",
|
||||
"clean:compiled": "del compiled",
|
||||
"clean:coverage": "del coverage",
|
||||
"clean:dist": "del dist",
|
||||
"compile": "tsc -p tsconfig.base.json",
|
||||
"format": "prettier --write \"**/*.{js,ts,tsx}\"",
|
||||
"lint": "eslint . --ext .js,.ts",
|
||||
"postbundle": "del compiled && cp-cli ./index.js ./dist/index.js",
|
||||
"postversion": "git push && git push --tags && npm publish",
|
||||
"release": "npm version -m 'Release v%s'",
|
||||
"test": "run-s check:* lint build test:*",
|
||||
"test:cjs": "jest --config ./scripts/jest/config.cjs.js",
|
||||
"test:cjsprod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.cjs.js",
|
||||
"test:es": "jest --config ./scripts/jest/config.es.js",
|
||||
"test:src": "jest --config ./scripts/jest/config.src.js",
|
||||
"test:src:watch": "npm run test:src -- --watch",
|
||||
"test:umd": "jest --config ./scripts/jest/config.umd.js",
|
||||
"test:umdprod": "jest --config ./scripts/jest/config.umdprod.js",
|
||||
"version": "run-s test changelog authors && git add ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "github:bendtherules/react-fiber-traverse"
|
||||
},
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"react",
|
||||
"typescript"
|
||||
],
|
||||
"author": "bendtherules <abhasbhattacharya2@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "github:bendtherules/react-fiber-traverse/issues"
|
||||
},
|
||||
"homepage": "github:bendtherules/react-fiber-traverse",
|
||||
"peerDependencies": {
|
||||
"react": "^16.0.0",
|
||||
"react-dom": "^16.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.5.4",
|
||||
"prop-types": "^15.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.5.4",
|
||||
"@babel/plugin-proposal-class-properties": "7.5.0",
|
||||
"@babel/plugin-transform-runtime": "7.5.0",
|
||||
"@babel/preset-env": "7.5.4",
|
||||
"@babel/preset-react": "7.0.0",
|
||||
"@types/enzyme": "3.10.3",
|
||||
"@types/enzyme-adapter-react-16": "1.0.5",
|
||||
"@types/jest": "24.0.15",
|
||||
"@types/prop-types": "15.7.1",
|
||||
"@types/react": "16.8.23",
|
||||
"@types/react-dom": "16.8.4",
|
||||
"@typescript-eslint/eslint-plugin": "1.12.0",
|
||||
"@typescript-eslint/parser": "1.12.0",
|
||||
"babel-core": "6.26.3",
|
||||
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
|
||||
"codecov": "3.5.0",
|
||||
"cp-cli": "2.0.0",
|
||||
"cross-env": "5.2.0",
|
||||
"del-cli": "2.0.0",
|
||||
"enzyme": "3.10.0",
|
||||
"enzyme-adapter-react-16": "1.14.0",
|
||||
"eslint": "6.0.1",
|
||||
"eslint-config-prettier": "6.0.0",
|
||||
"eslint-plugin-react": "7.14.2",
|
||||
"eslint-plugin-react-hooks": "1.6.1",
|
||||
"jest": "24.8.0",
|
||||
"jest-prettyhtml-matchers": "1.0.22",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "1.18.2",
|
||||
"react": "16.8.6",
|
||||
"react-dom": "16.8.6",
|
||||
"react-test-renderer": "16.8.6",
|
||||
"regenerator-runtime": "0.13.2",
|
||||
"rollup": "1.17.0",
|
||||
"rollup-plugin-babel": "4.3.3",
|
||||
"rollup-plugin-commonjs": "10.0.1",
|
||||
"rollup-plugin-filesize": "6.1.1",
|
||||
"rollup-plugin-node-resolve": "5.2.0",
|
||||
"rollup-plugin-replace": "2.2.0",
|
||||
"rollup-plugin-size-snapshot": "0.9.0",
|
||||
"rollup-plugin-sourcemaps": "0.4.2",
|
||||
"rollup-plugin-terser": "5.1.1",
|
||||
"shelljs": "0.8.3",
|
||||
"shelljs-plugin-authors": "2.0.10",
|
||||
"ts-jest": "24.0.2",
|
||||
"typescript": "3.5.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base",
|
||||
":disableRateLimiting",
|
||||
":automergeMinor",
|
||||
":rebaseStalePrs"
|
||||
],
|
||||
"rangeStrategy": "bump",
|
||||
"packageRules": [
|
||||
{
|
||||
"depTypeList": ["peerDependencies"],
|
||||
"rangeStrategy": "widen"
|
||||
},
|
||||
{
|
||||
"depTypeList": ["devDependencies"],
|
||||
"rangeStrategy": "pin"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
import babel from 'rollup-plugin-babel'
|
||||
import commonjs from 'rollup-plugin-commonjs'
|
||||
import nodeResolve from 'rollup-plugin-node-resolve'
|
||||
import replace from 'rollup-plugin-replace'
|
||||
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
|
||||
import sourcemaps from 'rollup-plugin-sourcemaps'
|
||||
import { terser } from 'rollup-plugin-terser'
|
||||
import pkg from './package.json'
|
||||
|
||||
const CJS_DEV = 'CJS_DEV'
|
||||
const CJS_PROD = 'CJS_PROD'
|
||||
const ES = 'ES'
|
||||
const UMD_DEV = 'UMD_DEV'
|
||||
const UMD_PROD = 'UMD_PROD'
|
||||
|
||||
const input = './compiled/index.js'
|
||||
|
||||
const getGlobals = bundleType => {
|
||||
const baseGlobals = {
|
||||
'react-dom': 'ReactDOM',
|
||||
react: 'React'
|
||||
}
|
||||
|
||||
switch (bundleType) {
|
||||
case UMD_DEV:
|
||||
return { ...baseGlobals, 'prop-types': 'PropTypes' }
|
||||
case UMD_PROD:
|
||||
return baseGlobals
|
||||
default:
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
const getExternal = bundleType => {
|
||||
const peerDependencies = Object.keys(pkg.peerDependencies)
|
||||
const dependencies = Object.keys(pkg.dependencies)
|
||||
|
||||
// Hat-tip: https://github.com/rollup/rollup-plugin-babel/issues/148#issuecomment-399696316.
|
||||
const makeExternalPredicate = externals => {
|
||||
if (externals.length === 0) {
|
||||
return () => false
|
||||
}
|
||||
const pattern = new RegExp(`^(${externals.join('|')})($|/)`)
|
||||
return id => pattern.test(id)
|
||||
}
|
||||
|
||||
switch (bundleType) {
|
||||
case CJS_DEV:
|
||||
case CJS_PROD:
|
||||
case ES:
|
||||
return makeExternalPredicate([...peerDependencies, ...dependencies])
|
||||
case UMD_DEV:
|
||||
return makeExternalPredicate([...peerDependencies, 'prop-types'])
|
||||
default:
|
||||
return makeExternalPredicate(peerDependencies)
|
||||
}
|
||||
}
|
||||
|
||||
const isProduction = bundleType =>
|
||||
bundleType === CJS_PROD || bundleType === UMD_PROD
|
||||
|
||||
const getBabelConfig = bundleType => {
|
||||
const options = {
|
||||
babelrc: false,
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['@babel/env', { loose: true, modules: false }], '@babel/react'],
|
||||
plugins: ['@babel/transform-runtime'],
|
||||
runtimeHelpers: true
|
||||
}
|
||||
|
||||
switch (bundleType) {
|
||||
case ES:
|
||||
return {
|
||||
...options,
|
||||
plugins: [
|
||||
...options.plugins,
|
||||
['transform-react-remove-prop-types', { mode: 'wrap' }]
|
||||
]
|
||||
}
|
||||
case UMD_PROD:
|
||||
case CJS_PROD:
|
||||
return {
|
||||
...options,
|
||||
plugins: [
|
||||
...options.plugins,
|
||||
['transform-react-remove-prop-types', { removeImport: true }]
|
||||
]
|
||||
}
|
||||
default:
|
||||
return options
|
||||
}
|
||||
}
|
||||
|
||||
const getPlugins = bundleType => [
|
||||
nodeResolve(),
|
||||
commonjs({
|
||||
include: 'node_modules/**',
|
||||
namedExports: {
|
||||
'node_modules/prop-types/index.js': [
|
||||
'any',
|
||||
'array',
|
||||
'arrayOf',
|
||||
'bool',
|
||||
'element',
|
||||
'exact',
|
||||
'func',
|
||||
'instanceOf',
|
||||
'node',
|
||||
'number',
|
||||
'object',
|
||||
'objectOf',
|
||||
'oneOf',
|
||||
'oneOfType',
|
||||
'shape',
|
||||
'string',
|
||||
'symbol'
|
||||
]
|
||||
}
|
||||
}),
|
||||
babel(getBabelConfig(bundleType)),
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify(
|
||||
isProduction(bundleType) ? 'production' : 'development'
|
||||
)
|
||||
}),
|
||||
sourcemaps(),
|
||||
sizeSnapshot(),
|
||||
isProduction(bundleType) &&
|
||||
terser({
|
||||
sourcemap: true,
|
||||
output: { comments: false },
|
||||
compress: {
|
||||
keep_infinity: true, // eslint-disable-line @typescript-eslint/camelcase
|
||||
pure_getters: true // eslint-disable-line @typescript-eslint/camelcase
|
||||
},
|
||||
warnings: true,
|
||||
ecma: 5,
|
||||
toplevel: false
|
||||
})
|
||||
]
|
||||
|
||||
const getCjsConfig = bundleType => ({
|
||||
input,
|
||||
external: getExternal(bundleType),
|
||||
output: {
|
||||
file: `dist/react-fiber-traverse.cjs.${
|
||||
isProduction(bundleType) ? 'production' : 'development'
|
||||
}.js`,
|
||||
format: 'cjs',
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: getPlugins(bundleType)
|
||||
})
|
||||
|
||||
const getEsConfig = () => ({
|
||||
input,
|
||||
external: getExternal(ES),
|
||||
output: {
|
||||
file: pkg.module,
|
||||
format: 'es',
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: getPlugins(ES)
|
||||
})
|
||||
|
||||
const getUmdConfig = bundleType => ({
|
||||
input,
|
||||
external: getExternal(bundleType),
|
||||
output: {
|
||||
file: `dist/react-fiber-traverse.umd.${
|
||||
isProduction(bundleType) ? 'production' : 'development'
|
||||
}.js`,
|
||||
format: 'umd',
|
||||
globals: getGlobals(bundleType),
|
||||
name: 'reactFiberTraverse',
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: getPlugins(bundleType)
|
||||
})
|
||||
|
||||
export default [
|
||||
getCjsConfig(CJS_DEV),
|
||||
getCjsConfig(CJS_PROD),
|
||||
getEsConfig(),
|
||||
getUmdConfig(UMD_DEV),
|
||||
getUmdConfig(UMD_PROD)
|
||||
]
|
||||
@@ -0,0 +1,8 @@
|
||||
const srcConfig = require('./config.src')
|
||||
|
||||
module.exports = Object.assign({}, srcConfig, {
|
||||
collectCoverage: false,
|
||||
moduleNameMapper: {
|
||||
'^../src$': `<rootDir>/dist/index.js`
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
const srcConfig = require('./config.src')
|
||||
|
||||
module.exports = Object.assign({}, srcConfig, {
|
||||
collectCoverage: false,
|
||||
moduleNameMapper: {
|
||||
'^../src$': `<rootDir>/dist/react-fiber-traverse.esm.js`
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: ['src/*.{ts,tsx}'],
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
||||
preset: 'ts-jest',
|
||||
rootDir: process.cwd(),
|
||||
roots: ['<rootDir>/test'],
|
||||
setupFiles: ['<rootDir>/scripts/jest/setupEnvironment.ts'],
|
||||
setupFilesAfterEnv: ['<rootDir>/scripts/jest/setupJest.ts'],
|
||||
testMatch: ['<rootDir>/test/*.spec.ts?(x)'],
|
||||
transform: { '^.+\\.(js|tsx?)$': 'ts-jest' }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
const srcConfig = require('./config.src')
|
||||
|
||||
module.exports = Object.assign({}, srcConfig, {
|
||||
collectCoverage: false,
|
||||
moduleNameMapper: {
|
||||
'^../src$': `<rootDir>/dist/react-fiber-traverse.umd.development.js`
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
const srcConfig = require('./config.src')
|
||||
|
||||
module.exports = Object.assign({}, srcConfig, {
|
||||
collectCoverage: false,
|
||||
moduleNameMapper: {
|
||||
'^../src$': `<rootDir>/dist/react-fiber-traverse.umd.production.js`
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
import { configure } from 'enzyme'
|
||||
import Adapter from 'enzyme-adapter-react-16'
|
||||
|
||||
configure({ adapter: new Adapter() })
|
||||
@@ -0,0 +1,9 @@
|
||||
import { createPrettyHtmlMatchers } from 'jest-prettyhtml-matchers'
|
||||
|
||||
expect.extend(
|
||||
createPrettyHtmlMatchers({
|
||||
singleQuote: true,
|
||||
sortAttributes: true,
|
||||
wrapAttributes: true
|
||||
})
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
import * as PropTypes from 'prop-types'
|
||||
import * as React from 'react'
|
||||
|
||||
interface Props {
|
||||
text: string
|
||||
}
|
||||
|
||||
const C: React.SFC<Props> = ({ text }) => <p>{text}</p>
|
||||
|
||||
C.propTypes = {
|
||||
text: PropTypes.string.isRequired
|
||||
}
|
||||
|
||||
export default C
|
||||
@@ -0,0 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Component should render correctly 1`] = `"<p>text</p>"`;
|
||||
@@ -0,0 +1,21 @@
|
||||
import { mount, ReactWrapper } from 'enzyme'
|
||||
import * as React from 'react'
|
||||
import C from '../src'
|
||||
|
||||
describe('Component', () => {
|
||||
let container: HTMLDivElement
|
||||
let wrapper: ReactWrapper
|
||||
|
||||
beforeEach(() => {
|
||||
container = document.body.appendChild(document.createElement('div'))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(container)
|
||||
})
|
||||
|
||||
it('should render correctly', () => {
|
||||
wrapper = mount(<C text="text" />, { attachTo: container })
|
||||
expect(wrapper.html()).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"declaration": true,
|
||||
"declarationDir": "dist",
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": true,
|
||||
"jsx": "react",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"outDir": "compiled",
|
||||
"pretty": true,
|
||||
"removeComments": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"target": "es5"
|
||||
},
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.base.json",
|
||||
"exclude": ["node_modules"],
|
||||
"include": ["scripts", "src", "test"],
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"declaration": false,
|
||||
"declarationDir": null,
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user