Skip to content

Commit 9d9fc2f

Browse files
committed
Test the npm package with Babel
1 parent 2f6bd6d commit 9d9fc2f

File tree

12 files changed

+128
-9
lines changed

12 files changed

+128
-9
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build/
2-
npm-package-test/build/
2+
npm-package-test/Babel/build/
3+
npm-package-test/TypeScript/build/
34
coverage/

npm-package-test/Babel/App.jsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @ts-check
2+
3+
import * as React from 'react';
4+
import * as ReactDOM from 'react-dom';
5+
6+
import { FormWithConstraints, FieldFeedbacks, FieldFeedback } from 'react-form-with-constraints';
7+
8+
import 'file-loader?name=[path][name].[ext]!./index.html';
9+
10+
class Form extends FormWithConstraints {
11+
render() {
12+
return (
13+
<form onSubmit={this.handleSubmit.bind(this)} noValidate>
14+
<input type="email" name="username" defaultValue="John Doe" required />
15+
<FieldFeedbacks for="username">
16+
<FieldFeedback when="*" />
17+
</FieldFeedbacks>
18+
19+
<button>Submit</button>
20+
</form>
21+
);
22+
}
23+
}
24+
25+
ReactDOM.render(<Form />, document.getElementById('app'));
File renamed without changes.

npm-package-test/Babel/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "npm-package-test-babel",
3+
"version": "0.0.1",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/tkrotoff/ReactFormWithConstraints.git"
7+
},
8+
"description": "Simple form validation for React",
9+
"license": "MIT",
10+
11+
"scripts": {
12+
"clean": "rm -rf build",
13+
"build": "webpack -d --env.development",
14+
"test": "./test.sh"
15+
},
16+
17+
"dependencies": {
18+
"react-form-with-constraints": "../.."
19+
},
20+
21+
"devDependencies": {
22+
"babel-core": "latest",
23+
"babel-preset-react": "latest",
24+
25+
"webpack": "latest",
26+
"babel-loader": "latest",
27+
"file-loader": "latest"
28+
}
29+
}

npm-package-test/test.sh renamed to npm-package-test/Babel/test.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
echo '** Running rm -rf node_modules'
33
rm -rf node_modules
44

5-
echo '** Running (cd .. && npm install)'
6-
(cd .. && npm install)
5+
echo '** Running (cd ../.. && npm install)'
6+
(cd ../.. && npm install)
77

88
echo '** Running npm install'
99
npm install
1010

11-
echo '** Running (cd .. && rm -rf node_modules)'
12-
(cd .. && rm -rf node_modules)
11+
echo '** Running (cd ../.. && rm -rf node_modules)'
12+
(cd ../.. && rm -rf node_modules)
1313

1414
echo '** Running npm run build'
1515
npm run build
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const path = require('path');
2+
const optimize = require('webpack').optimize;
3+
4+
module.exports = {
5+
entry: {
6+
'App': './App.jsx',
7+
8+
'react-form-with-constraints': 'react-form-with-constraints',
9+
react: ['react', 'prop-types', 'react-dom']
10+
},
11+
12+
output: {
13+
path: path.join(__dirname, 'build'),
14+
filename: '[name].js'
15+
},
16+
17+
plugins: [
18+
new optimize.CommonsChunkPlugin({names: ['react-form-with-constraints', 'react']})
19+
],
20+
21+
resolve: {
22+
extensions: ['.js', '.jsx']
23+
},
24+
25+
module: {
26+
rules: [
27+
{ test: /\.jsx?$/, loader: 'babel-loader', options: {presets: ['react']} }
28+
]
29+
}
30+
};
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
7+
<title>npm-package-test</title>
8+
</head>
9+
10+
<body>
11+
<div id="app"></div>
12+
13+
<script src="react.js"></script>
14+
<script src="react-form-with-constraints.js"></script>
15+
<script src="App.js"></script>
16+
</body>
17+
</html>

npm-package-test/package.json renamed to npm-package-test/TypeScript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "npm-package-test",
2+
"name": "npm-package-test-typescript",
33
"version": "0.0.1",
44
"repository": {
55
"type": "git",
@@ -15,7 +15,7 @@
1515
},
1616

1717
"dependencies": {
18-
"react-form-with-constraints": "../"
18+
"react-form-with-constraints": "../.."
1919
},
2020

2121
"devDependencies": {

npm-package-test/TypeScript/test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
echo '** Running rm -rf node_modules'
3+
rm -rf node_modules
4+
5+
echo '** Running (cd ../.. && npm install)'
6+
(cd ../.. && npm install)
7+
8+
echo '** Running npm install'
9+
npm install
10+
11+
echo '** Running (cd ../.. && rm -rf node_modules)'
12+
(cd ../.. && rm -rf node_modules)
13+
14+
echo '** Running npm run build'
15+
npm run build

npm-package-test/webpack.config.ts renamed to npm-package-test/TypeScript/webpack.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
2-
import { optimize } from 'webpack';
2+
import { Configuration, optimize } from 'webpack';
33

4-
module.exports = {
4+
const config: Configuration = {
55
entry: {
66
'App': './App.tsx',
77

@@ -28,3 +28,5 @@ module.exports = {
2828
]
2929
}
3030
};
31+
32+
export = config;

0 commit comments

Comments
 (0)