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

Commit 6c5cd4d

Browse files
authored
feat: remove types (#136)
Types are always broken, please add them to https://github.com/DefinitelyTyped/DefinitelyTyped.
1 parent e4e4390 commit 6c5cd4d

File tree

15 files changed

+1133
-1552
lines changed

15 files changed

+1133
-1552
lines changed

babel.config.js

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const { STYLED_ENGINE = 'styled-components' } = process.env
1+
const { STYLED_ENGINE = 'styled-components', NODE_ENV } = process.env
22

3-
const getStyledEnginePlugins = () => {
4-
if (process.env.NODE_ENV === 'test') return []
3+
function getStyledEnginePlugins() {
4+
if (NODE_ENV === 'test') return []
55

66
switch (STYLED_ENGINE) {
77
case 'emotion':
@@ -13,37 +13,40 @@ const getStyledEnginePlugins = () => {
1313
}
1414
}
1515

16-
let config = {
17-
presets: [
18-
['@babel/preset-env', { loose: true, modules: false }],
19-
'@babel/preset-react',
20-
],
21-
plugins: [
22-
...getStyledEnginePlugins(),
23-
[
24-
'babel-plugin-transform-rename-import',
25-
{
26-
replacements: [
27-
{
28-
original: '(.*)styled-engine$',
29-
replacement: `$1styled-engine/${STYLED_ENGINE}`,
30-
},
31-
],
32-
},
33-
],
34-
'babel-plugin-annotate-pure-calls',
35-
'@babel/plugin-proposal-object-rest-spread',
36-
['@babel/plugin-proposal-class-properties', { loose: true }],
37-
],
38-
}
16+
module.exports = api => {
17+
api.cache(true)
3918

40-
if (process.env.NODE_ENV === 'test') {
41-
config = Object.assign({}, config, {
19+
const config = {
20+
presets: [
21+
['@babel/preset-env', { loose: true, modules: false }],
22+
'@babel/preset-react',
23+
],
4224
plugins: [
43-
...config.plugins,
44-
['@babel/plugin-transform-modules-commonjs', { loose: true }],
25+
...getStyledEnginePlugins(),
26+
[
27+
'babel-plugin-transform-rename-import',
28+
{
29+
replacements: [
30+
{
31+
original: '(.*)styled-engine$',
32+
replacement: `$1styled-engine/${STYLED_ENGINE}`,
33+
},
34+
],
35+
},
36+
],
37+
['@babel/plugin-proposal-class-properties', { loose: true }],
4538
],
46-
})
47-
}
39+
}
40+
41+
if (NODE_ENV === 'test') {
42+
return {
43+
...config,
44+
plugins: [
45+
...config.plugins,
46+
['@babel/plugin-transform-modules-commonjs', { loose: true }],
47+
],
48+
}
49+
}
4850

49-
module.exports = config
51+
return config
52+
}

config/rollup.js

Lines changed: 50 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,26 @@
11
import path from 'path'
2-
import resolve from 'rollup-plugin-node-resolve'
2+
import nodeResolve from 'rollup-plugin-node-resolve'
33
import babel from 'rollup-plugin-babel'
44
import replace from 'rollup-plugin-replace'
55
import commonjs from 'rollup-plugin-commonjs'
6-
import copy from 'rollup-plugin-cpy'
7-
import { uglify } from 'rollup-plugin-uglify'
6+
import { terser } from 'rollup-plugin-terser'
7+
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
88

9-
export const getRollupConfig = ({
10-
pkg,
11-
pwd,
12-
buildName,
13-
name,
14-
copyTypeScriptDefs,
15-
}) => {
9+
export const getRollupConfig = ({ pwd, buildName, name }) => {
1610
const SOURCE_DIR = path.resolve(pwd, 'src')
1711
const DIST_DIR = path.resolve(pwd, 'dist')
18-
const CORE_DIR = path.resolve(pwd, '../shared/core')
19-
20-
const baseConfig = {
21-
input: `${SOURCE_DIR}/index.js`,
12+
const input = `${SOURCE_DIR}/index.js`
13+
const external = id => !id.startsWith('.') && !id.startsWith('/')
14+
const getBabelOptions = ({ useESModules }) => ({
15+
exclude: '**/node_modules/**',
16+
runtimeHelpers: true,
17+
configFile: path.join(pwd, '../../babel.config.js'),
2218
plugins: [
23-
babel({
24-
exclude: 'node_modules/**',
25-
configFile: path.join(pwd, '../../babel.config.js'),
26-
}),
27-
...(copyTypeScriptDefs
28-
? [
29-
copy({
30-
files: `${CORE_DIR}/*.d.ts`,
31-
dest: `${DIST_DIR}/shared`,
32-
}),
33-
copy({
34-
files: `${SOURCE_DIR}/*.d.ts`,
35-
dest: DIST_DIR,
36-
}),
37-
]
38-
: []),
39-
],
40-
}
41-
42-
const esConfig = Object.assign({}, baseConfig, {
43-
output: {
44-
file: `${DIST_DIR}/${buildName}.es.js`,
45-
format: 'es',
46-
},
47-
external: [
48-
...Object.keys(pkg.peerDependencies || {}),
49-
...Object.keys(pkg.dependencies || {}),
50-
'react-transition-group/Transition',
19+
'babel-plugin-annotate-pure-calls',
20+
['@babel/plugin-transform-runtime', { useESModules }],
5121
],
5222
})
5323

54-
const cjsConfig = Object.assign({}, esConfig, {
55-
output: {
56-
file: `${DIST_DIR}/${buildName}.cjs.js`,
57-
format: 'cjs',
58-
},
59-
})
60-
6124
const globals = {
6225
classnames: 'classNames',
6326
polished: 'polished',
@@ -71,41 +34,58 @@ export const getRollupConfig = ({
7134
'styled-components': 'styled',
7235
}
7336

74-
const umdConfig = Object.assign({}, baseConfig, {
37+
const umdConfig = {
38+
input,
7539
output: {
76-
name,
77-
file: `${DIST_DIR}/${buildName}.js`,
40+
file: `${DIST_DIR}/${buildName}.umd.js`,
7841
format: 'umd',
42+
name,
7943
globals,
80-
exports: 'named',
81-
sourcemap: false,
8244
},
8345
external: Object.keys(globals),
84-
plugins: [...baseConfig.plugins, resolve({ browser: true }), commonjs()],
85-
})
46+
plugins: [
47+
babel(getBabelOptions({ useESModules: false })),
48+
nodeResolve(),
49+
commonjs(),
50+
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }),
51+
],
52+
}
8653

87-
const minConfig = Object.assign({}, umdConfig, {
54+
const minConfig = {
55+
input,
8856
output: {
89-
...umdConfig.output,
9057
file: `${DIST_DIR}/${buildName}.min.js`,
58+
format: 'umd',
59+
name,
60+
globals,
9161
},
62+
external: Object.keys(globals),
9263
plugins: [
93-
...umdConfig.plugins,
64+
babel(getBabelOptions({ useESModules: true })),
65+
nodeResolve(),
66+
commonjs(),
9467
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
95-
uglify({
96-
compress: {
97-
pure_getters: true,
98-
unsafe: true,
99-
unsafe_comps: true,
100-
warnings: false,
101-
},
102-
}),
68+
terser(),
10369
],
104-
})
70+
}
71+
72+
const cjsConfig = {
73+
input,
74+
output: { file: `${DIST_DIR}/${buildName}.cjs.js`, format: 'cjs' },
75+
external,
76+
plugins: [babel(getBabelOptions({ useESModules: false })), sizeSnapshot()],
77+
}
78+
79+
const esmConfig = {
80+
input,
81+
output: { file: `${DIST_DIR}/${buildName}.es.js`, format: 'esm' },
82+
external,
83+
plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()],
84+
}
10585

10686
if (process.env.WATCH_MODE) {
107-
return [esConfig, cjsConfig]
87+
return [esmConfig, cjsConfig]
10888
}
10989

110-
return [esConfig, cjsConfig, umdConfig, minConfig]
90+
return [esmConfig, cjsConfig, umdConfig, minConfig]
11191
}

package.json

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
}
2727
],
2828
"devDependencies": {
29-
"@babel/cli": "^7.4.3",
30-
"@babel/core": "^7.4.3",
29+
"@babel/cli": "^7.4.4",
30+
"@babel/core": "^7.4.4",
3131
"@babel/plugin-external-helpers": "^7.2.0",
32-
"@babel/plugin-proposal-class-properties": "^7.4.0",
33-
"@babel/plugin-proposal-object-rest-spread": "^7.4.3",
34-
"@babel/plugin-transform-modules-commonjs": "^7.4.3",
35-
"@babel/preset-env": "^7.4.3",
32+
"@babel/plugin-proposal-class-properties": "^7.4.4",
33+
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
34+
"@babel/plugin-transform-runtime": "^7.4.4",
35+
"@babel/preset-env": "^7.4.4",
3636
"@babel/preset-react": "^7.0.0",
3737
"@emotion/core": "^10.0.10",
3838
"@emotion/styled": "^10.0.10",
3939
"@material-ui/system": "^3.0.0-alpha.2",
40-
"@types/react": "^16.8.13",
40+
"@types/react": "^16.8.16",
4141
"@types/styled-components": "^4.1.14",
4242
"babel-core": "^7.0.0-0",
4343
"babel-eslint": "^10.0.1",
@@ -52,39 +52,37 @@
5252
"conventional-github-releaser": "^3.1.2",
5353
"conventional-recommended-bump": "^4.1.1",
5454
"cross-env": "^5.2.0",
55-
"docz": "^1.0.3",
56-
"docz-theme-default": "^1.0.3",
55+
"docz": "^1.1.0",
56+
"docz-theme-default": "^1.1.0",
5757
"emotion-theming": "^10.0.10",
5858
"enzyme": "^3.9.0",
5959
"enzyme-adapter-react-16": "^1.12.1",
6060
"eslint": "^5.16.0",
6161
"eslint-config-airbnb": "^17.1.0",
62-
"eslint-config-prettier": "^4.1.0",
62+
"eslint-config-prettier": "^4.2.0",
6363
"eslint-plugin-import": "^2.17.2",
6464
"eslint-plugin-jsx-a11y": "^6.2.1",
65-
"eslint-plugin-react": "^7.12.4",
65+
"eslint-plugin-react": "^7.13.0",
6666
"eslint-plugin-react-hooks": "^1.6.0",
6767
"favicons-webpack-plugin": "^0.0.9",
6868
"jest": "^24.7.1",
6969
"jest-styled-components": "^6.3.1",
70-
"lerna": "^3.13.3",
70+
"lerna": "^3.13.4",
7171
"react": "^16.8.6",
7272
"react-dom": "^16.8.6",
7373
"react-test-renderer": "^16.8.6",
7474
"remark-external-links": "^4.0.0",
75-
"rollup": "^1.10.0",
75+
"rollup": "^1.11.2",
7676
"rollup-plugin-babel": "^4.3.2",
7777
"rollup-plugin-commonjs": "^9.3.4",
78-
"rollup-plugin-cpy": "^1.1.0",
7978
"rollup-plugin-node-resolve": "^4.2.3",
8079
"rollup-plugin-replace": "^2.2.0",
81-
"rollup-plugin-uglify": "^6.0.2",
80+
"rollup-plugin-size-snapshot": "^0.8.0",
81+
"rollup-plugin-terser": "^4.0.4",
8282
"shx": "^0.3.2",
8383
"standard-version": "^5.0.2",
8484
"styled-components": "^4.2.0",
8585
"styled-system": "^4.1.0",
86-
"terser": "3.17.0",
87-
"typescript": "^3.4.3",
8886
"uglifyjs-webpack-plugin": "^2.1.2",
8987
"webpack": "^4.30.0"
9088
},

packages/core-em/.size-snapshot.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"/Users/neoziro/Projects/smooth-ui/packages/core-em/dist/smooth-ui-core-em.es.js": {
3+
"bundled": 105657,
4+
"minified": 72464,
5+
"gzipped": 15505,
6+
"treeshaked": {
7+
"rollup": {
8+
"code": 495,
9+
"import_statements": 495
10+
},
11+
"webpack": {
12+
"code": 2169
13+
}
14+
}
15+
},
16+
"/Users/neoziro/Projects/smooth-ui/packages/core-em/dist/smooth-ui-core-em.cjs.js": {
17+
"bundled": 112821,
18+
"minified": 78916,
19+
"gzipped": 16368
20+
}
21+
}

packages/core-em/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
"sideEffects": false,
1414
"main": "dist/smooth-ui-core-em.cjs.js",
1515
"module": "dist/smooth-ui-core-em.es.js",
16-
"jsnext:main": "dist/smooth-ui-core-em.es.js",
17-
"types": "dist/index.d.ts",
1816
"author": "Greg Bergé <berge.greg@gmail.com>",
1917
"license": "MIT",
2018
"scripts": {
@@ -26,12 +24,13 @@
2624
"access": "public"
2725
},
2826
"dependencies": {
27+
"@babel/runtime": "^7.4.4",
2928
"@smooth-ui/system": "^10.0.7",
3029
"polished": "^3.2.0",
3130
"popper.js": "^1.15.0",
3231
"prop-types": "^15.7.2",
33-
"react-focus-lock": "^1.18.3",
34-
"react-remove-scroll": "^1.0.6",
32+
"react-focus-lock": "^1.19.1",
33+
"react-remove-scroll": "^1.0.7",
3534
"react-transition-group": "^4.0.0"
3635
},
3736
"peerDependencies": {

packages/core-em/rollup.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ export default getRollupConfig({
66
name: 'smoothUI',
77
buildName: 'smooth-ui-core-em',
88
pkg,
9-
copyTypeScriptDefs: true,
109
})

packages/core-em/src/index.d.ts

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

0 commit comments

Comments
 (0)