refactor(example): use create-react-app instead of parcel

This commit is contained in:
moklick
2019-10-09 19:04:25 +02:00
parent 3eea88d533
commit e144c9cd72
30 changed files with 31016 additions and 40214 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
{
"baseUrl": "http://localhost:1234",
"baseUrl": "http://localhost:3000",
"viewportWidth": 1280,
"viewportHeight": 720
}
+1 -1
View File
@@ -1,6 +1,6 @@
describe('Advanced Flow Rendering', () => {
it('renders a flow with sone nodes', () => {
cy.visit('/advanced.html');
cy.visit('/');
cy.get('.react-flow__renderer');
+1 -1
View File
@@ -1,6 +1,6 @@
describe('Basic Flow Rendering', () => {
it('renders a flow with three nodes', () => {
cy.visit('/index.html');
cy.visit('/basic');
cy.get('.react-flow__renderer');
cy.get('.react-flow__node').should('have.length', 4);
+78 -27994
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+9556 -10114
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+23
View File
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+68
View File
@@ -0,0 +1,68 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `yarn 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.
### `yarn test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `yarn build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `yarn build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
+21140
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
{
"name": "example",
"version": "0.1.0",
"private": true,
"dependencies": {
"react-dom": "^16.10.2",
"react-flow": "file:../",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

+43
View File
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

+25
View File
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
+2
View File
@@ -0,0 +1,2 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
@@ -1,6 +1,6 @@
import React from 'react';
import { Handle } from '../../../src';
import { Handle } from 'react-flow';
export default({ data, styles }) => (
<div
@@ -1,6 +1,6 @@
import React from 'react';
import { Handle } from '../../../src';
import { Handle } from 'react-flow';
export default ({ data, styles }) => {
return (
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import Graph, { isEdge, removeElements, addEdge, getOutgoers, MiniMap, Controls } from '../../../src';
import Graph, { isEdge, removeElements, addEdge, getOutgoers, MiniMap, Controls } from 'react-flow';
import SpecialNode from './SpecialNode';
import InputNode from './InputNode';
@@ -44,6 +44,8 @@ class App extends PureComponent {
input: input || 'write something'
}
};
} else {
return e;
}
})}
));
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import Graph, { removeElements, addEdge, getOutgoers } from '../../../src';
import Graph, { removeElements, addEdge, getOutgoers } from 'react-flow';
const onNodeDragStop = node => console.log('drag stop', node);
+7
View File
@@ -0,0 +1,7 @@
html, body {
margin: 0;
}
html, body, #root {
height: 100%;
}
+21
View File
@@ -0,0 +1,21 @@
import React from '../../node_modules/react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import Advanced from './Advanced';
import Basic from './Basic';
import './index.css';
ReactDOM.render((
<Router>
<Switch>
<Route path="/basic">
<Basic />
</Route>
<Route path="/">
<Advanced />
</Route>
</Switch>
</Router>
), document.getElementById('root'));
-34
View File
@@ -1,34 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>react-flow example</title>
<style>
html, body {
margin: 0;
}
html, body, #root {
height: 100%;
}
.controls {
position: absolute;
bottom: 10px;
left: 10px;
z-index: 4;
}
.react-flow__handle.connecting {
background: orange;
}
.react-flow__handle.valid {
background: green;
}
</style>
</head>
<body>
<div id="root"></div>
<script src="advanced/scripts/index.js"></script>
</body>
</html>
-9
View File
@@ -1,9 +0,0 @@
import React from 'react';
import { render } from 'react-dom';
import { unstable_trace as trace } from 'scheduler/tracing';
import ExampleGraph from './ExampleGraph';
trace('initial render', performance.now(), () =>
render(<ExampleGraph />, document.getElementById('root'))
);
-9
View File
@@ -1,9 +0,0 @@
import React from 'react';
import { render } from 'react-dom';
import { unstable_trace as trace } from 'scheduler/tracing';
import ExampleGraph from './ExampleGraph';
trace('initial render', performance.now(), () =>
render(<ExampleGraph />, document.getElementById('root'))
);
-28
View File
@@ -1,28 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>react-flow example</title>
<style>
html, body {
margin: 0;
}
html, body, #root {
height: 100%;
}
.controls {
position: absolute;
bottom: 10px;
left: 10px;
z-index: 4;
}
</style>
</head>
<body>
<div id="root"></div>
<script src="basic/scripts/index.js"></script>
</body>
</html>
-2005
View File
File diff suppressed because it is too large Load Diff
+4 -8
View File
@@ -23,11 +23,9 @@
"babel-preset-react-app": "^9.0.2",
"cypress": "^3.4.1",
"husky": "^3.0.8",
"parcel-bundler": "^1.12.4",
"postcss-nested": "^4.1.2",
"prop-types": "^15.7.2",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"rollup": "^1.23.1",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-bundle-size": "^1.0.3",
@@ -46,16 +44,14 @@
"wait-on": "^3.3.0"
},
"peerDependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0",
"prop-types": "^15.0.0-0"
"react": "^16.9.0"
},
"scripts": {
"build": "rollup -c --environment NODE_ENV:production",
"watch": "rollup -w -c",
"dev": "parcel examples/*.html -d examples/build",
"build:example": "parcel build examples/*.html -d examples/build",
"dev:wait": "start-server-and-test dev http-get://localhost:1234/index.html",
"dev": "cd example && npm start",
"build:example": "cd example && npm run build",
"dev:wait": "start-server-and-test dev http-get://localhost:3000",
"cy:run": "cypress run",
"cy:open": "cypress open",
"cypress": "npm run dev:wait cy:open",
+6 -5
View File
@@ -6,7 +6,6 @@ import bundleSize from 'rollup-plugin-bundle-size';
import visualizer from 'rollup-plugin-visualizer';
import svg from 'rollup-plugin-svg';
import replace from 'rollup-plugin-replace';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import pkg from './package.json';
@@ -23,14 +22,16 @@ export default [{
output: [{
file: pkg.main,
format: 'cjs',
sourcemap: true
sourcemap: true,
exports: 'named'
}, {
file: pkg.module,
format: 'es',
sourcemap: true
format: 'esm',
sourcemap: true,
exports: 'named'
}],
external: ['react', 'react-dom'],
plugins: [
peerDepsExternal(),
bundleSize(),
postcss(),
babel({