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

Commit

Permalink
feat: remove types (#136)
Browse files Browse the repository at this point in the history
Types are always broken, please add them to https://github.com/DefinitelyTyped/DefinitelyTyped.
  • Loading branch information
gregberge authored May 4, 2019
1 parent e4e4390 commit 6c5cd4d
Show file tree
Hide file tree
Showing 15 changed files with 1,133 additions and 1,552 deletions.
69 changes: 36 additions & 33 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { STYLED_ENGINE = 'styled-components' } = process.env
const { STYLED_ENGINE = 'styled-components', NODE_ENV } = process.env

const getStyledEnginePlugins = () => {
if (process.env.NODE_ENV === 'test') return []
function getStyledEnginePlugins() {
if (NODE_ENV === 'test') return []

switch (STYLED_ENGINE) {
case 'emotion':
Expand All @@ -13,37 +13,40 @@ const getStyledEnginePlugins = () => {
}
}

let config = {
presets: [
['@babel/preset-env', { loose: true, modules: false }],
'@babel/preset-react',
],
plugins: [
...getStyledEnginePlugins(),
[
'babel-plugin-transform-rename-import',
{
replacements: [
{
original: '(.*)styled-engine$',
replacement: `$1styled-engine/${STYLED_ENGINE}`,
},
],
},
],
'babel-plugin-annotate-pure-calls',
'@babel/plugin-proposal-object-rest-spread',
['@babel/plugin-proposal-class-properties', { loose: true }],
],
}
module.exports = api => {
api.cache(true)

if (process.env.NODE_ENV === 'test') {
config = Object.assign({}, config, {
const config = {
presets: [
['@babel/preset-env', { loose: true, modules: false }],
'@babel/preset-react',
],
plugins: [
...config.plugins,
['@babel/plugin-transform-modules-commonjs', { loose: true }],
...getStyledEnginePlugins(),
[
'babel-plugin-transform-rename-import',
{
replacements: [
{
original: '(.*)styled-engine$',
replacement: `$1styled-engine/${STYLED_ENGINE}`,
},
],
},
],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
})
}
}

if (NODE_ENV === 'test') {
return {
...config,
plugins: [
...config.plugins,
['@babel/plugin-transform-modules-commonjs', { loose: true }],
],
}
}

module.exports = config
return config
}
120 changes: 50 additions & 70 deletions config/rollup.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,26 @@
import path from 'path'
import resolve from 'rollup-plugin-node-resolve'
import nodeResolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
import commonjs from 'rollup-plugin-commonjs'
import copy from 'rollup-plugin-cpy'
import { uglify } from 'rollup-plugin-uglify'
import { terser } from 'rollup-plugin-terser'
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'

export const getRollupConfig = ({
pkg,
pwd,
buildName,
name,
copyTypeScriptDefs,
}) => {
export const getRollupConfig = ({ pwd, buildName, name }) => {
const SOURCE_DIR = path.resolve(pwd, 'src')
const DIST_DIR = path.resolve(pwd, 'dist')
const CORE_DIR = path.resolve(pwd, '../shared/core')

const baseConfig = {
input: `${SOURCE_DIR}/index.js`,
const input = `${SOURCE_DIR}/index.js`
const external = id => !id.startsWith('.') && !id.startsWith('/')
const getBabelOptions = ({ useESModules }) => ({
exclude: '**/node_modules/**',
runtimeHelpers: true,
configFile: path.join(pwd, '../../babel.config.js'),
plugins: [
babel({
exclude: 'node_modules/**',
configFile: path.join(pwd, '../../babel.config.js'),
}),
...(copyTypeScriptDefs
? [
copy({
files: `${CORE_DIR}/*.d.ts`,
dest: `${DIST_DIR}/shared`,
}),
copy({
files: `${SOURCE_DIR}/*.d.ts`,
dest: DIST_DIR,
}),
]
: []),
],
}

const esConfig = Object.assign({}, baseConfig, {
output: {
file: `${DIST_DIR}/${buildName}.es.js`,
format: 'es',
},
external: [
...Object.keys(pkg.peerDependencies || {}),
...Object.keys(pkg.dependencies || {}),
'react-transition-group/Transition',
'babel-plugin-annotate-pure-calls',
['@babel/plugin-transform-runtime', { useESModules }],
],
})

const cjsConfig = Object.assign({}, esConfig, {
output: {
file: `${DIST_DIR}/${buildName}.cjs.js`,
format: 'cjs',
},
})

const globals = {
classnames: 'classNames',
polished: 'polished',
Expand All @@ -71,41 +34,58 @@ export const getRollupConfig = ({
'styled-components': 'styled',
}

const umdConfig = Object.assign({}, baseConfig, {
const umdConfig = {
input,
output: {
name,
file: `${DIST_DIR}/${buildName}.js`,
file: `${DIST_DIR}/${buildName}.umd.js`,
format: 'umd',
name,
globals,
exports: 'named',
sourcemap: false,
},
external: Object.keys(globals),
plugins: [...baseConfig.plugins, resolve({ browser: true }), commonjs()],
})
plugins: [
babel(getBabelOptions({ useESModules: false })),
nodeResolve(),
commonjs(),
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }),
],
}

const minConfig = Object.assign({}, umdConfig, {
const minConfig = {
input,
output: {
...umdConfig.output,
file: `${DIST_DIR}/${buildName}.min.js`,
format: 'umd',
name,
globals,
},
external: Object.keys(globals),
plugins: [
...umdConfig.plugins,
babel(getBabelOptions({ useESModules: true })),
nodeResolve(),
commonjs(),
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false,
},
}),
terser(),
],
})
}

const cjsConfig = {
input,
output: { file: `${DIST_DIR}/${buildName}.cjs.js`, format: 'cjs' },
external,
plugins: [babel(getBabelOptions({ useESModules: false })), sizeSnapshot()],
}

const esmConfig = {
input,
output: { file: `${DIST_DIR}/${buildName}.es.js`, format: 'esm' },
external,
plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()],
}

if (process.env.WATCH_MODE) {
return [esConfig, cjsConfig]
return [esmConfig, cjsConfig]
}

return [esConfig, cjsConfig, umdConfig, minConfig]
return [esmConfig, cjsConfig, umdConfig, minConfig]
}
32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
}
],
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/plugin-external-helpers": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-object-rest-spread": "^7.4.3",
"@babel/plugin-transform-modules-commonjs": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@emotion/core": "^10.0.10",
"@emotion/styled": "^10.0.10",
"@material-ui/system": "^3.0.0-alpha.2",
"@types/react": "^16.8.13",
"@types/react": "^16.8.16",
"@types/styled-components": "^4.1.14",
"babel-core": "^7.0.0-0",
"babel-eslint": "^10.0.1",
Expand All @@ -52,39 +52,37 @@
"conventional-github-releaser": "^3.1.2",
"conventional-recommended-bump": "^4.1.1",
"cross-env": "^5.2.0",
"docz": "^1.0.3",
"docz-theme-default": "^1.0.3",
"docz": "^1.1.0",
"docz-theme-default": "^1.1.0",
"emotion-theming": "^10.0.10",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.12.1",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.1.0",
"eslint-config-prettier": "^4.2.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.6.0",
"favicons-webpack-plugin": "^0.0.9",
"jest": "^24.7.1",
"jest-styled-components": "^6.3.1",
"lerna": "^3.13.3",
"lerna": "^3.13.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-test-renderer": "^16.8.6",
"remark-external-links": "^4.0.0",
"rollup": "^1.10.0",
"rollup": "^1.11.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-cpy": "^1.1.0",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.2",
"rollup-plugin-size-snapshot": "^0.8.0",
"rollup-plugin-terser": "^4.0.4",
"shx": "^0.3.2",
"standard-version": "^5.0.2",
"styled-components": "^4.2.0",
"styled-system": "^4.1.0",
"terser": "3.17.0",
"typescript": "^3.4.3",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.30.0"
},
Expand Down
21 changes: 21 additions & 0 deletions packages/core-em/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"/Users/neoziro/Projects/smooth-ui/packages/core-em/dist/smooth-ui-core-em.es.js": {
"bundled": 105657,
"minified": 72464,
"gzipped": 15505,
"treeshaked": {
"rollup": {
"code": 495,
"import_statements": 495
},
"webpack": {
"code": 2169
}
}
},
"/Users/neoziro/Projects/smooth-ui/packages/core-em/dist/smooth-ui-core-em.cjs.js": {
"bundled": 112821,
"minified": 78916,
"gzipped": 16368
}
}
7 changes: 3 additions & 4 deletions packages/core-em/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"sideEffects": false,
"main": "dist/smooth-ui-core-em.cjs.js",
"module": "dist/smooth-ui-core-em.es.js",
"jsnext:main": "dist/smooth-ui-core-em.es.js",
"types": "dist/index.d.ts",
"author": "Greg Bergé <berge.greg@gmail.com>",
"license": "MIT",
"scripts": {
Expand All @@ -26,12 +24,13 @@
"access": "public"
},
"dependencies": {
"@babel/runtime": "^7.4.4",
"@smooth-ui/system": "^10.0.7",
"polished": "^3.2.0",
"popper.js": "^1.15.0",
"prop-types": "^15.7.2",
"react-focus-lock": "^1.18.3",
"react-remove-scroll": "^1.0.6",
"react-focus-lock": "^1.19.1",
"react-remove-scroll": "^1.0.7",
"react-transition-group": "^4.0.0"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/core-em/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export default getRollupConfig({
name: 'smoothUI',
buildName: 'smooth-ui-core-em',
pkg,
copyTypeScriptDefs: true,
})
27 changes: 0 additions & 27 deletions packages/core-em/src/index.d.ts

This file was deleted.

Loading

0 comments on commit 6c5cd4d

Please sign in to comment.