Merge pull request #37 from transitive-bullshit/feature/typescript-support-v2
add typescript support v2
This commit is contained in:
parent
faba0e5f9e
commit
c0769c2743
45 changed files with 2544 additions and 6662 deletions
|
@ -2,14 +2,14 @@
|
|||
"name": "{{name}}-example",
|
||||
"homepage": "https://{{author}}.github.io/{{name}}",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^16.4.1",
|
||||
"react-dom": "^16.4.1",
|
||||
"{{name}}": "{{#if yarn}}link:..{{else}}*{{/if}}",
|
||||
"react-scripts": "^1.1.4"
|
||||
"react-scripts": "^1.1.4",
|
||||
"{{name}}": "file:.."
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
|
@ -1,7 +1,3 @@
|
|||
/**
|
||||
* @class ExampleComponent
|
||||
*/
|
||||
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,9 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
21
packages/create-freesewing-pattern/template/typescript/.gitignore
vendored
Normal file
21
packages/create-freesewing-pattern/template/typescript/.gitignore
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
|
||||
# builds
|
||||
build
|
||||
dist
|
||||
.rpt2_cache
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
|
@ -0,0 +1,31 @@
|
|||
# {{name}}
|
||||
|
||||
> {{description}}
|
||||
|
||||
[](https://www.npmjs.com/package/{{name}}) [](https://standardjs.com)
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install --save {{name}}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx
|
||||
import * as React from 'react'
|
||||
|
||||
import MyComponent from '{{name}}'
|
||||
|
||||
class Example extends React.Component {
|
||||
render () {
|
||||
return (
|
||||
<MyComponent />
|
||||
)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
{{license}} © [{{author}}](https://github.com/{{author}})
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "{{name}}-example",
|
||||
"homepage": "https://{{author}}.github.io/{{name}}",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^16.4.1",
|
||||
"react-dom": "^16.4.1",
|
||||
"react-scripts": "^1.1.4",
|
||||
"{{name}}": "file:.."
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#000000">
|
||||
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||
|
||||
<title>{{name}}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<noscript>
|
||||
You need to enable JavaScript to run this app.
|
||||
</noscript>
|
||||
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"short_name": "{{name}}",
|
||||
"name": "{{name}}",
|
||||
"start_url": "./index.html",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
import React, { Component } from 'react'
|
||||
|
||||
import ExampleComponent from '{{name}}'
|
||||
|
||||
export default class App extends Component {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<ExampleComponent text='Modern React component module' />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: sans-serif;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
|
||||
import './index.css'
|
||||
import App from './App'
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'))
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "{{name}}",
|
||||
"version": "1.0.0",
|
||||
"description": "{{description}}",
|
||||
"author": "{{author}}",
|
||||
"license": "{{license}}",
|
||||
"repository": "{{repo}}",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.es.js",
|
||||
"jsnext:main": "dist/index.es.js",
|
||||
"scripts": {
|
||||
"test": "cross-env CI=1 react-scripts-ts test --env=jsdom",
|
||||
"test:watch": "react-scripts-ts test --env=jsdom",
|
||||
"build": "rollup -c",
|
||||
"start": "rollup -c -w",
|
||||
"prepare": "{{manager}} run build",
|
||||
"predeploy": "cd example && {{manager}} install && {{manager}} run build",
|
||||
"deploy": "gh-pages -d example/build"
|
||||
},
|
||||
"dependencies": {},
|
||||
"peerDependencies": {
|
||||
"prop-types": "^15.5.4",
|
||||
"react": "^15.0.0 || ^16.0.0",
|
||||
"react-dom": "^15.0.0 || ^16.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^23.1.5",
|
||||
"@types/react": "^16.3.13",
|
||||
"@types/react-dom": "^16.0.5",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"cross-env": "^5.1.4",
|
||||
"gh-pages": "^1.2.0",
|
||||
"react": "^16.2.0",
|
||||
"react-dom": "^16.2.0",
|
||||
"react-scripts-ts": "^2.16.0",
|
||||
"react": "^16.4.1",
|
||||
"react-dom": "^16.4.1",
|
||||
"react-scripts-ts": "2.15.1",
|
||||
"rollup": "^0.62.0",
|
||||
"rollup-plugin-babel": "^3.0.7",
|
||||
"rollup-plugin-commonjs": "^9.1.3",
|
||||
"rollup-plugin-node-resolve": "^3.3.0",
|
||||
"rollup-plugin-peer-deps-external": "^2.2.0",
|
||||
"rollup-plugin-postcss-modules": "^1.0.8",
|
||||
"rollup-plugin-typescript2": "^0.13.0",
|
||||
"rollup-plugin-url": "^1.4.0",
|
||||
"typescript": "^2.8.3"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
import typescript from 'rollup-plugin-typescript2'
|
||||
import commonjs from 'rollup-plugin-commonjs'
|
||||
import external from 'rollup-plugin-peer-deps-external'
|
||||
import postcss from 'rollup-plugin-postcss-modules'
|
||||
import resolve from 'rollup-plugin-node-resolve'
|
||||
import url from 'rollup-plugin-url'
|
||||
|
||||
import pkg from './package.json'
|
||||
|
||||
export default {
|
||||
input: 'src/index.tsx',
|
||||
output: [
|
||||
{
|
||||
file: pkg.main,
|
||||
format: 'cjs',
|
||||
sourcemap: true
|
||||
},
|
||||
{
|
||||
file: pkg.module,
|
||||
format: 'es',
|
||||
sourcemap: true
|
||||
}
|
||||
],
|
||||
plugins: [
|
||||
external(),
|
||||
postcss({
|
||||
modules: true,
|
||||
writeDefinitions: true
|
||||
}),
|
||||
url(),
|
||||
resolve(),
|
||||
typescript({
|
||||
rollupCommonJSResolveHack: true
|
||||
}),
|
||||
commonjs()
|
||||
]
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* @class ExampleComponent
|
||||
*/
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
import styles from './styles.css'
|
||||
|
||||
export type Props = { text: string }
|
||||
|
||||
export default class ExampleComponent extends React.Component<Props> {
|
||||
render() {
|
||||
const {
|
||||
text
|
||||
} = this.props
|
||||
|
||||
return (
|
||||
<div className={styles.test}>
|
||||
Example Component: {text}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
/* add css styles here (optional) */
|
||||
|
||||
.test {
|
||||
display: inline-block;
|
||||
margin: 2em auto;
|
||||
border: 2px solid #000;
|
||||
font-size: 2em;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import ExampleComponent from './'
|
||||
|
||||
describe('ExampleComponent', () => {
|
||||
it('is truthy', () => {
|
||||
expect(ExampleComponent).toBeTruthy()
|
||||
})
|
||||
})
|
8
packages/create-freesewing-pattern/template/typescript/src/typings.d.ts
vendored
Normal file
8
packages/create-freesewing-pattern/template/typescript/src/typings.d.ts
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Default CSS definition for typescript,
|
||||
* will be overridden with file-specific definitions by rollup
|
||||
*/
|
||||
declare module '*.css' {
|
||||
const content: { [className: string]: string };
|
||||
export default content;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "build",
|
||||
"module": "esnext",
|
||||
"target": "es5",
|
||||
"lib": ["es6", "dom", "es2016", "es2017"],
|
||||
"sourceMap": true,
|
||||
"allowJs": false,
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"moduleResolution": "node",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "build", "dist", "example", "rollup.config.js"]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue