Skip to content

Commit

Permalink
upgrade other examples
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyreilly committed Mar 17, 2018
1 parent a56b895 commit 3e33f8f
Show file tree
Hide file tree
Showing 9 changed files with 2,468 additions and 389 deletions.
24 changes: 0 additions & 24 deletions examples/core-js/internal/webpack/shared.js

This file was deleted.

39 changes: 3 additions & 36 deletions examples/core-js/internal/webpack/webpack.config.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,29 @@ const ForkTsCheckerNotifierWebpackPlugin = require('fork-ts-checker-notifier-web
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

// * Only necessary until https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/48 has been merged and released
// START
const chalk = require("chalk");
const os = require("os");

function formatterForLineAndColumnUrlClicking(message, useColors) {
const colors = new chalk.constructor({ enabled: useColors });
const messageColor = message.isWarningSeverity() ? colors.bold.yellow : colors.bold.red;
const fileAndNumberColor = colors.bold.cyan;
const codeColor = colors.grey;

return [
messageColor(message.getSeverity().toUpperCase() + " in ") +
fileAndNumberColor(message.getFile() + "(" + message.getLine() + "," + message.getCharacter() + ")") +
messageColor(':'),
codeColor(message.getFormattedCode() + ': ') + message.getContent()
].join(os.EOL);
}
// END

const shared = require('./shared');
const main = [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'core-js',
'whatwg-fetch',
'./src/index.tsx'
];
const vendor = shared.makeVendorEntry({ mainModules: main, modulesToExclude: ['semantic-ui-css'] })

module.exports = {
context: process.cwd(), // to automatically find tsconfig.json
entry: {
main: main,
vendor: vendor
main
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
publicPath: "/"
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js' }),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new ForkTsCheckerNotifierWebpackPlugin({ title: 'TypeScript', excludeWarnings: false }),
new ForkTsCheckerWebpackPlugin({
tslint: true,
checkSyntacticErrors: true,
formatter: formatterForLineAndColumnUrlClicking,
watch: ['./src'] // optional but improves performance (fewer stat calls)
}),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
new ForkTsCheckerNotifierWebpackPlugin({ title: 'TypeScript', excludeWarnings: false }),
new HtmlWebpackPlugin({
inject: true,
template: 'src/index.html'
Expand All @@ -84,6 +50,7 @@ module.exports = {
},
devtool: 'inline-source-map',
devServer: {
clientLogLevel: 'warning',
open: true,
hot: true,
historyApiFallback: true,
Expand Down
15 changes: 1 addition & 14 deletions examples/core-js/internal/webpack/webpack.config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,29 @@ const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const shared = require('./shared');
const main = [
'core-js',
'whatwg-fetch',
'./src/index.tsx'
];
const vendor = shared.makeVendorEntry({ mainModules: main, modulesToExclude: ['semantic-ui-css'] })

module.exports = {
context: process.cwd(), // to automatically find tsconfig.json
entry: {
main: main,
vendor: vendor
main: main
},
output: {
path: path.join(process.cwd(), 'dist'),
filename: '[name].js',
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js' }),
new ForkTsCheckerWebpackPlugin({
async: false,
memoryLimit: 4096,
checkSyntacticErrors: true
}),
new webpack.NoEmitOnErrorsPlugin(),
new UglifyJSPlugin(/*{
unused: true,
dead_code: true
}*/),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new HtmlWebpackPlugin({
hash: true,
inject: true,
Expand Down
18 changes: 9 additions & 9 deletions examples/core-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "webpack-dev-server --progress --color --config internal/webpack/webpack.config.development.js",
"start": "webpack-dev-server --progress --color --mode development --config internal/webpack/webpack.config.development.js",
"prebuild": "rimraf ./dist/*",
"build": "webpack --color --config internal/webpack/webpack.config.production.js",
"build": "webpack --color --mode production --config internal/webpack/webpack.config.production.js",
"test:watch": "jest --watchAll",
"test": "jest --ci --runInBand"
},
Expand Down Expand Up @@ -43,9 +43,9 @@
"@types/react-test-renderer": "^16.0.0",
"@types/react-transition-group": "^2.0.2",
"file-loader": "^1.0.0",
"fork-ts-checker-notifier-webpack-plugin": "^0.2.0",
"fork-ts-checker-webpack-plugin": "^0.2.8",
"html-webpack-plugin": "^2.28.0",
"fork-ts-checker-notifier-webpack-plugin": "^0.4.0",
"fork-ts-checker-webpack-plugin": "^0.4.1",
"html-webpack-plugin": "^3.0.0",
"jest": "^21.1.0",
"jest-junit": "^3.1.0",
"react-hot-loader": "^3.0.0",
Expand All @@ -54,14 +54,14 @@
"rimraf": "^2.6.1",
"source-map-loader": "^0.2.1",
"ts-jest": "^21.0.1",
"ts-loader": "^3.0.0",
"ts-loader": "^4.0.0",
"tslib": "^1.7.1",
"tslint": "^5.5.0",
"tslint-react": "^3.2.0",
"typescript": "^2.5.2",
"uglifyjs-webpack-plugin": "^1.0.0",
"webpack": "^3.7.1",
"webpack-dev-server": "^2.9.2"
"webpack": "^4.0.0",
"webpack-cli": "^2.0.12",
"webpack-dev-server": "^3.0.0"
},
"dependencies": {
"core-js": "^2.4.1",
Expand Down
Loading

0 comments on commit 3e33f8f

Please sign in to comment.