Skip to content
This repository was archived by the owner on Mar 26, 2022. It is now read-only.

Commit 0d25d4b

Browse files
committed
webpack v5, babel updates + core-js v3, reduce bundle size
1 parent 13a07a9 commit 0d25d4b

File tree

7 files changed

+18128
-6401
lines changed

7 files changed

+18128
-6401
lines changed

.eslintrc

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
2-
"parser": "babel-eslint",
2+
"env": {
3+
"browser": true,
4+
"jest": true
5+
},
36
"extends": [
47
"airbnb-base",
58
"plugin:flowtype/recommended"
69
],
10+
"parser": "babel-eslint",
711
"plugins": [
812
"flowtype",
13+
"import",
914
"jest"
1015
],
11-
"env": {
12-
"browser": true,
13-
"jest": true,
14-
},
1516
"settings": {
1617
"flowtype": {
1718
"onlyFilesWithFlowAnnotation": true
@@ -23,7 +24,7 @@
2324
}
2425
},
2526
"rules": {
26-
"arrow-body-style": ["error", "as-needed"],
27+
"arrow-body-style": ["warn", "as-needed"],
2728
"brace-style": ["error", "stroustrup"],
2829
"comma-dangle": ["error", "only-multiline"],
2930
"function-paren-newline": ["error", "consistent"],
@@ -43,6 +44,7 @@
4344
}
4445
],
4546
"lines-between-class-members": "off",
47+
"max-classes-per-file": "off",
4648
"max-len": [
4749
"error",
4850
{
@@ -67,6 +69,7 @@
6769
"OrderedList",
6870
"Map",
6971
"OrderedMap",
72+
"Seq",
7073
"Set",
7174
"OrderedSet",
7275
"SortableContainer",
@@ -76,7 +79,14 @@
7679
],
7780
"padded-blocks": "off",
7881
"prefer-destructuring": "warn",
79-
"space-before-function-paren": ["error", "never"],
82+
"space-before-function-paren": [
83+
"error",
84+
{
85+
"anonymous": "never",
86+
"named": "never",
87+
"asyncArrow": "always"
88+
}
89+
],
8090

8191
"flowtype/define-flow-type": "error",
8292
"flowtype/space-after-type-colon": ["error", "never"],
@@ -88,6 +98,7 @@
8898
{
8999
"devDependencies": [
90100
"config/**",
101+
"src/utils/testing/**",
91102
"**/*.test.js"
92103
]
93104
}
@@ -98,7 +109,6 @@
98109
"groups": ["builtin", "external", "internal", ["parent", "sibling"], "index"]
99110
}
100111
],
101-
102112
"import/prefer-default-export": "warn",
103113

104114
"jest/no-disabled-tests": "error",

config/babel/babel.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
module.exports = {
22
plugins: [
3-
'@babel/plugin-proposal-class-properties',
4-
'@babel/plugin-proposal-object-rest-spread',
5-
'@babel/plugin-transform-runtime',
3+
['@babel/plugin-transform-runtime', {
4+
corejs: 3,
5+
}],
66
],
77
presets: [
8-
'@babel/preset-env',
8+
['@babel/preset-env', {
9+
useBuiltIns: false,
10+
}],
911
'@babel/preset-flow',
1012
],
1113
};

config/lib/lib.config.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

config/lib/paths.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

config/webpack/webpack.config.js

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
1-
/* eslint-disable import/extensions */
1+
/* eslint-disable import/extensions, import/no-extraneous-dependencies */
22

33
const path = require('path');
4-
const Webpack = require('webpack');
4+
const webpack = require('webpack');
5+
const externals = require('webpack-node-externals');
6+
const TerserPlugin = require('terser-webpack-plugin');
57

6-
const LIB_CONFIG = require('../lib/lib.config.js');
7-
const LIB_PATHS = require('../lib/paths.config.js');
88
const PACKAGE = require('../../package.json');
99

10+
const BANNER = `
11+
${PACKAGE.name} - v${PACKAGE.version}
12+
${PACKAGE.description}
13+
${PACKAGE.homepage}
14+
15+
Copyright (c) 2017-${(new Date()).getFullYear()}, OpenLattice, Inc. All rights reserved.
16+
`;
17+
1018
module.exports = (webpackEnvironment) => {
1119

1220
const env = webpackEnvironment || {};
1321

14-
/*
15-
* constants
16-
*/
22+
//
23+
// constants
24+
//
1725

1826
const BABEL_CONFIG = path.resolve(__dirname, '../babel/babel.config.js');
1927
const ENV_DEV = 'development';
2028
const ENV_PROD = 'production';
21-
const LIB_NAMESPACE = 'ReqSeq';
22-
const LIB_FILE_NAME = 'index.js';
2329

24-
/*
25-
* loaders
26-
*/
30+
const ROOT = path.resolve(__dirname, '../..');
31+
const BUILD = path.resolve(ROOT, 'build');
32+
const NODE = path.resolve(ROOT, 'node_modules');
33+
const SOURCE = path.resolve(ROOT, 'src');
34+
35+
//
36+
// loaders
37+
//
2738

2839
const BABEL_LOADER = {
2940
test: /\.js$/,
3041
exclude: /node_modules/,
3142
include: [
32-
LIB_PATHS.ABS.SOURCE,
43+
SOURCE,
3344
],
3445
use: {
3546
loader: 'babel-loader',
@@ -39,30 +50,39 @@ module.exports = (webpackEnvironment) => {
3950
},
4051
};
4152

42-
/*
43-
* plugins
44-
*/
53+
//
54+
// plugins
55+
//
4556

46-
const BANNER_PLUGIN = new Webpack.BannerPlugin({
47-
banner: LIB_CONFIG.BANNER,
57+
const BANNER_PLUGIN = new webpack.BannerPlugin({
58+
banner: BANNER,
4859
entryOnly: true,
4960
});
5061

51-
const DEFINE_PLUGIN = new Webpack.DefinePlugin({
62+
const DEFINE_PLUGIN = new webpack.DefinePlugin({
5263
__ENV_DEV__: JSON.stringify(!!env.development),
5364
__ENV_PROD__: JSON.stringify(!!env.production),
5465
__PACKAGE__: JSON.stringify(PACKAGE.name),
5566
__VERSION__: JSON.stringify(`v${PACKAGE.version}`),
5667
});
5768

58-
/*
59-
* base webpack config
60-
*/
69+
//
70+
// base webpack config
71+
//
6172

6273
return {
6374
bail: true,
75+
devtool: false,
6476
entry: [
65-
LIB_PATHS.ABS.ENTRY,
77+
path.resolve(ROOT, 'src/index.js'),
78+
],
79+
externals: [
80+
// https://github.com/liady/webpack-node-externals
81+
externals({
82+
allowlist: [
83+
/babel/,
84+
],
85+
}),
6686
],
6787
mode: env.production ? ENV_PROD : ENV_DEV,
6888
module: {
@@ -72,13 +92,18 @@ module.exports = (webpackEnvironment) => {
7292
},
7393
optimization: {
7494
minimize: !!env.production,
95+
minimizer: [
96+
new TerserPlugin({
97+
extractComments: false,
98+
}),
99+
],
75100
},
76101
output: {
77-
library: LIB_NAMESPACE,
102+
filename: 'index.js',
103+
library: 'ReqSeq',
78104
libraryTarget: 'umd',
79-
path: LIB_PATHS.ABS.BUILD,
105+
path: BUILD,
80106
publicPath: '/',
81-
filename: LIB_FILE_NAME,
82107
},
83108
performance: {
84109
hints: false, // disable performance hints for now
@@ -90,8 +115,8 @@ module.exports = (webpackEnvironment) => {
90115
resolve: {
91116
extensions: ['.js'],
92117
modules: [
93-
LIB_PATHS.ABS.SOURCE,
94-
LIB_PATHS.ABS.NODE,
118+
SOURCE,
119+
NODE,
95120
]
96121
},
97122
target: 'web',

0 commit comments

Comments
 (0)