Skip to content

Commit 524415f

Browse files
authored
Merge pull request #58 from Lemoncode/version-2.0
Version 2.0
2 parents d05e24a + c0487b4 commit 524415f

File tree

199 files changed

+4708
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+4708
-365
lines changed

.babelrc

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
{
22
"env": {
3-
// Compatibility Profile. ES5 output and CommonJS module format.
4-
"commonjs": {
3+
// Compatibility Profile.
4+
// ES5 output and CommonJS module format.
5+
"es5_cjs": {
56
"presets": [
6-
["env", {
7-
"useBuiltIns": false
8-
}],
9-
"react"
7+
"@babel/preset-env",
8+
"@babel/preset-react"
109
]
1110
},
12-
// Future Profile. ES6 output and module syntax.
11+
// Future Profile.
12+
// ES6 output with no module transformation (ES Modules syntax).
1313
"es": {
1414
"presets": [
15-
["env", {
16-
"useBuiltIns": false,
15+
["@babel/preset-env", {
1716
"modules": false,
1817
"targets": {
1918
"node": "6.5"
2019
}
2120
}],
22-
"react"
21+
"@babel/preset-react"
22+
]
23+
},
24+
// Bundled Profile.
25+
// ES5 output and UMD module format.
26+
"umd": {
27+
"presets": [
28+
["@babel/preset-env", {
29+
"modules": false,
30+
}],
31+
"@babel/preset-react"
2332
]
2433
},
34+
// Jest Profile.
35+
// To be used by jest tests.
2536
"test": {
26-
"presets": ["env", "react"]
37+
"presets": [
38+
"@babel/preset-env",
39+
"@babel/preset-react"
40+
]
2741
}
2842
}
2943
}

.gitignore

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
node_modules
2-
.DS_Store
3-
dist/
4-
typings/
5-
*.orig
1+
# Common aux folders
2+
.awcache/
3+
.vscode/
64
.idea/
7-
*/src/**/*.js.map
8-
yarn.lock
9-
*.log
5+
.cache/
6+
7+
# Dependencies & Build
8+
node_modules/
9+
build/
1010
lib/
11+
dist/
1112
es/
13+
14+
# Aux files
15+
*.cer
16+
*.log
17+
*/src/**/*.orig
18+
*/src/**/*.js.map
19+
20+
# Win
21+
desktop.ini
22+
23+
# MacOs
24+
.DS_Store
25+
26+
# Yarn
27+
yarn.lock
28+
29+
# NPM
1230
package-lock.json

.vscode/launch.json

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
1-
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"type": "node",
6-
"request": "launch",
7-
"name": "Jest single run",
8-
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
9-
"args": [
10-
"--verbose",
11-
"-i"
12-
],
13-
"console": "integratedTerminal",
14-
"internalConsoleOptions": "neverOpen"
15-
},
16-
]
17-
}
1+
2+
{
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"type": "node",
7+
"request": "launch",
8+
"name": "Jest single run",
9+
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
10+
"args": [
11+
"--verbose",
12+
"-i",
13+
"--no-cache"
14+
],
15+
"console": "integratedTerminal",
16+
"internalConsoleOptions": "neverOpen"
17+
},
18+
{
19+
"type": "node",
20+
"request": "launch",
21+
"name": "Jest watch run",
22+
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
23+
"args": [
24+
"--verbose",
25+
"-i",
26+
"--no-cache",
27+
"--watchAll"
28+
],
29+
"console": "integratedTerminal",
30+
"internalConsoleOptions": "neverOpen"
31+
},
32+
{
33+
"type": "node",
34+
"request": "launch",
35+
"name": "Jest current file",
36+
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
37+
"args": [
38+
"${fileBasename}",
39+
"--verbose",
40+
"-i",
41+
"--no-cache",
42+
"--watchAll"
43+
],
44+
"console": "integratedTerminal",
45+
"internalConsoleOptions": "neverOpen"
46+
}
47+
]
48+
}

config/test/polyfills.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Polyfill requestAnimationFrame required by React >=16.0.0
2+
require('raf/polyfill');
File renamed without changes.

config/webpack/helpers.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const path = require('path');
2+
3+
// String helpers
4+
const capitalizeString = s => s.charAt(0).toUpperCase() + s.slice(1);
5+
const camelCaseString = dashedName => dashedName.split("-").map(
6+
(s, i) => i > 0 ? capitalizeString(s) : s
7+
).join("");
8+
9+
// Name helpers
10+
const packageName = process.env.npm_package_name;
11+
const packageNameCamelCase = camelCaseString(packageName);
12+
const version = JSON.stringify(process.env.npm_package_version).replace(/"/g, '');
13+
const getBundleFileName = min => `${packageName}-${version}${min ? ".min" : ''}.js`;
14+
15+
// Path helpers
16+
const rootPath = path.resolve(__dirname, "../..");
17+
const resolveFromRootPath = (...args) => path.join(rootPath, ...args);
18+
19+
// Export constants
20+
exports.srcPath = resolveFromRootPath("src");
21+
exports.buildPath = resolveFromRootPath("build",);
22+
exports.distPath = resolveFromRootPath("build", "dist");
23+
exports.version = version;
24+
exports.packageNameCamelCase = packageNameCamelCase;
25+
exports.getBundleFileName = getBundleFileName;

config/webpack/webpack.common.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const helpers = require('./helpers');
2+
3+
module.exports = (env, argv) => {
4+
const minimizeBundle = Boolean(argv['optimize-minimize']);
5+
6+
return {
7+
entry: ['./src/index.js'],
8+
output: {
9+
path: helpers.distPath,
10+
filename: helpers.getBundleFileName(minimizeBundle),
11+
library: helpers.packageNameCamelCase,
12+
libraryTarget: 'umd',
13+
},
14+
externals: {
15+
react: 'react',
16+
},
17+
optimization: {
18+
minimize: minimizeBundle,
19+
},
20+
module: {
21+
rules: [
22+
{
23+
test: /\.js$/,
24+
exclude: /node_modules/,
25+
loader: 'babel-loader',
26+
},
27+
],
28+
},
29+
};
30+
};

config/webpack/webpack.dev.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const merge = require('webpack-merge');
2+
const commonConfig = require('./webpack.common.js');
3+
4+
module.exports = (env, argv) => merge(commonConfig(env, argv), {
5+
mode: 'development',
6+
devtool: 'inline-source-map',
7+
});

config/webpack/webpack.prod.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const merge = require('webpack-merge');
2+
const commonConfig = require('./webpack.common.js');
3+
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
4+
const CompressionPlugin = require('compression-webpack-plugin');
5+
6+
module.exports = (env, argv) => merge(commonConfig(env, argv), {
7+
mode: 'production',
8+
devtool: 'none',
9+
plugins: [
10+
new BundleAnalyzerPlugin({
11+
analyzerMode: "static",
12+
openAnalyzer: false,
13+
reportFilename: "report/report.html",
14+
}),
15+
new CompressionPlugin(),
16+
],
17+
});

examples/00-example-basic/.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
"@babel/preset-react",
4+
[
5+
"@babel/preset-env",
6+
{
7+
"useBuiltIns": "entry"
8+
}
9+
]
10+
]
11+
}

0 commit comments

Comments
 (0)