Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
{
"presets": [
"@babel/preset-react",
"@babel/preset-env"
]
}
"env": {
// Compatibility Profile.
// ES5 output and CommonJS module format.
"es5_cjs": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
},
// Future Profile.
// ES6 output with no module transformation (ES Modules syntax).
"es": {
"presets": [
["@babel/preset-env", {
"modules": false,
"targets": {
"node": "6.5"
}
}],
"@babel/preset-react"
]
},
// Bundled Profile.
// ES5 output and UMD module format.
"umd": {
"presets": [
["@babel/preset-env", {
"modules": false,
}],
"@babel/preset-react"
]
},
// Jest Profile.
// To be used by jest tests.
"test": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
}
}
31 changes: 23 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
node_modules
.DS_Store
dist/
typings/
*.orig
# Common aux folders
.awcache/
.vscode/
.idea/
.cache/

# Dependencies & Build
node_modules/
build/

# Aux files
*.cer
*.log
*/src/**/*.orig
*/src/**/*.js.map

# Win
desktop.ini

# MacOs
.DS_Store

# Yarn
yarn.lock
*.log
lib/
es/

# NPM
package-lock.json
2 changes: 2 additions & 0 deletions config/test/polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Polyfill requestAnimationFrame required by React >=16.0.0
require('raf/polyfill');
File renamed without changes.
25 changes: 25 additions & 0 deletions config/webpack/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const path = require('path');

// String helpers
const capitalizeString = s => s.charAt(0).toUpperCase() + s.slice(1);
const camelCaseString = dashedName => dashedName.split("-").map(
(s, i) => i > 0 ? capitalizeString(s) : s
).join("");

// Name helpers
const packageName = process.env.npm_package_name;
const packageNameCamelCase = camelCaseString(packageName);
const version = JSON.stringify(process.env.npm_package_version).replace(/"/g, '');
const getBundleFileName = min => `${packageName}-${version}${min ? ".min" : ''}.js`;

// Path helpers
const rootPath = path.resolve(__dirname, "../..");
const resolveFromRootPath = (...args) => path.join(rootPath, ...args);

// Export constants
exports.srcPath = resolveFromRootPath("src");
exports.buildPath = resolveFromRootPath("build",);
exports.distPath = resolveFromRootPath("build", "dist");
exports.version = version;
exports.packageNameCamelCase = packageNameCamelCase;
exports.getBundleFileName = getBundleFileName;
30 changes: 30 additions & 0 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const helpers = require('./helpers');

module.exports = (env, argv) => {
const minimizeBundle = Boolean(argv['optimize-minimize']);

return {
entry: ['./src/index.js'],
output: {
path: helpers.distPath,
filename: helpers.getBundleFileName(minimizeBundle),
library: helpers.packageNameCamelCase,
libraryTarget: 'umd',
},
externals: {
react: 'react',
},
optimization: {
minimize: minimizeBundle,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
};
};
7 changes: 7 additions & 0 deletions config/webpack/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const merge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');

module.exports = (env, argv) => merge(commonConfig(env, argv), {
mode: 'development',
devtool: 'inline-source-map',
});
17 changes: 17 additions & 0 deletions config/webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const merge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const CompressionPlugin = require('compression-webpack-plugin');

module.exports = (env, argv) => merge(commonConfig(env, argv), {
mode: 'production',
devtool: 'none',
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: "static",
openAnalyzer: false,
reportFilename: "report/report.html",
}),
new CompressionPlugin(),
],
});
2 changes: 1 addition & 1 deletion examples/00-example-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-loader-spinner": "^2.3.0",
"react-promise-tracker": "file:../../"
"react-promise-tracker": "file:../../build"
}
}
3 changes: 2 additions & 1 deletion examples/00-example-basic/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
resolve: {
extensions: [".js", ".jsx"],
alias: {
react: path.resolve('./node_modules/react')
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
},
},
entry: {
Expand Down
2 changes: 1 addition & 1 deletion examples/01-example-areas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-loader-spinner": "^2.3.0",
"react-promise-tracker": "file:../../"
"react-promise-tracker": "file:../../build"
}
}
3 changes: 2 additions & 1 deletion examples/01-example-areas/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
resolve: {
extensions: [".js", ".jsx"],
alias: {
react: path.resolve('./node_modules/react')
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
},
},
entry: {
Expand Down
2 changes: 1 addition & 1 deletion examples/02-example-delay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-loader-spinner": "^2.3.0",
"react-promise-tracker": "file:../../"
"react-promise-tracker": "file:../../build"
}
}
3 changes: 2 additions & 1 deletion examples/02-example-delay/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
resolve: {
extensions: [".js", ".jsx"],
alias: {
react: path.resolve('./node_modules/react')
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
},
},
entry: {
Expand Down
2 changes: 1 addition & 1 deletion examples/03-example-hoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-loader-spinner": "^2.3.0",
"react-promise-tracker": "file:../../"
"react-promise-tracker": "file:../../build"
}
}
3 changes: 2 additions & 1 deletion examples/03-example-hoc/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
resolve: {
extensions: [".js", ".jsx"],
alias: {
react: path.resolve('./node_modules/react')
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
},
},
entry: {
Expand Down
2 changes: 1 addition & 1 deletion examples/04-initial-load/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-loader-spinner": "^2.3.0",
"react-promise-tracker": "file:../../"
"react-promise-tracker": "file:../../build"
}
}
3 changes: 2 additions & 1 deletion examples/04-initial-load/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
resolve: {
extensions: [".js", ".jsx"],
alias: {
react: path.resolve('./node_modules/react')
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
},
},
entry: {
Expand Down
1 change: 1 addition & 0 deletions examples/05-typescript/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
{
Expand Down
3 changes: 2 additions & 1 deletion examples/05-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@babel/core": "^7.2.2",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0",
"@types/react": "^16.8.3",
"@types/react-dom": "^16.8.1",
"awesome-typescript-loader": "^5.2.1",
Expand All @@ -38,6 +39,6 @@
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react-loader-spinner": "^2.3.0",
"react-promise-tracker": "file:../.."
"react-promise-tracker": "file:../../build"
}
}
2 changes: 1 addition & 1 deletion examples/05-typescript/src/common/spinner/spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { usePromiseTracker } from 'react-promise-tracker';
import Loader from 'react-loader-spinner';
import './spinner.css';

export const Spinner = (props) => {
export const Spinner: React.FunctionComponent = () => {
const { promiseInProgress } = usePromiseTracker(null);

return (
Expand Down
6 changes: 5 additions & 1 deletion examples/05-typescript/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ var basePath = __dirname;
module.exports = {
context: path.join(basePath, "src"),
resolve: {
extensions: [".js", ".ts", ".tsx"]
extensions: [".js", ".ts", ".tsx"],
alias: {
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
}
},
entry: ["@babel/polyfill", "./index.tsx"],
output: {
Expand Down
Loading