Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb63e8e

Browse files
committed
Add dist build
1 parent 2cc4eeb commit bb63e8e

File tree

5 files changed

+617
-39
lines changed

5 files changed

+617
-39
lines changed

‎markdown.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const execa = require("execa");
1+
const execa = require('execa');
22

33
module.exports = {
44
transforms: {
5-
COMPONENTS(content,options) {
6-
const json = execa.sync("scripts/extract-docs.js").stdout;
7-
const markdown = execa.sync("scripts/markdown-docs.js", {
5+
COMPONENTS() {
6+
const json = execa.sync('scripts/extract-docs.js').stdout;
7+
const markdown = execa.sync('scripts/markdown-docs.js', {
88
input: json
99
}).stdout;
1010
return markdown;

‎package.json

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,57 @@
33
"version": "0.0.0",
44
"main": "index.js",
55
"license": "MIT",
6+
"files": [
7+
"dist"
8+
],
9+
"main": "./dist/index.cjs.js",
10+
"module": "./dist/index.esm.js",
11+
"browser": {
12+
"./dist/index.cjs.js": "./dist/index.browser.cjs.js",
13+
"./dist/index.esm.js": "./dist/index.browser.esm.js"
14+
},
15+
"sideEffects": false,
616
"scripts": {
17+
"build:dist": "rollup -c",
718
"build:docs": "md-magic README.md && prettier --write README.md",
19+
"build": "npm run build:docs && npm run build:dist",
20+
"format": "eslint --fix .",
21+
"postbuild": "npm run size",
22+
"prebuild": "rimraf dist",
23+
"prepare": "npm run build:dist",
24+
"size": "bundlesize",
825
"start": "next dev"
926
},
27+
"bundlesize": [
28+
{
29+
"path": "./dist/index.browser.cjs.min.js",
30+
"compression": "none",
31+
"maxSize": "4KB"
32+
},
33+
{
34+
"path": "./dist/index.browser.cjs.min.js",
35+
"maxSize": "2KB"
36+
},
37+
{
38+
"path": "./dist/index.browser.esm.min.js",
39+
"compression": "none",
40+
"maxSize": "4KB"
41+
},
42+
{
43+
"path": "./dist/index.browser.esm.min.js",
44+
"maxSize": "2KB"
45+
}
46+
],
47+
"peerDependencies": {
48+
"react": "^16.8.0"
49+
},
1050
"devDependencies": {
51+
"@babel/cli": "^7.7.0",
52+
"@babel/core": "^7.7.2",
53+
"@babel/preset-env": "^7.7.1",
54+
"@babel/preset-react": "^7.7.0",
55+
"@rollup/plugin-replace": "^2.2.1",
56+
"bundlesize": "^0.18.0",
1157
"escape-html": "^1.0.3",
1258
"eslint": "^6.6.0",
1359
"eslint-config-prettier": "^6.5.0",
@@ -21,7 +67,12 @@
2167
"react": "^16.12.0",
2268
"react-docgen": "^4.1.1",
2369
"react-docgen-displayname-handler": "^2.1.3",
24-
"react-dom": "^16.12.0"
70+
"react-dom": "^16.12.0",
71+
"rollup": "^1.27.0",
72+
"rollup-plugin-babel": "^4.3.3",
73+
"rollup-plugin-commonjs": "^10.1.0",
74+
"rollup-plugin-node-resolve": "^5.2.0",
75+
"rollup-plugin-terser": "^5.1.2"
2576
},
2677
"dependencies": {
2778
"prop-types": "^15.7.2"

‎rollup.config.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import resolve from 'rollup-plugin-node-resolve';
2+
import commonjs from 'rollup-plugin-commonjs';
3+
import babel from 'rollup-plugin-babel';
4+
import replace from '@rollup/plugin-replace';
5+
import { terser } from 'rollup-plugin-terser';
6+
import pkg from './package.json';
7+
8+
const baseConfig = {
9+
input: 'src/index.js',
10+
external: ['react', 'react-dom', 'prop-types'],
11+
output: [
12+
{ file: pkg.main, format: 'cjs' },
13+
{ file: pkg.module, format: 'es' }
14+
],
15+
plugins: [
16+
babel({
17+
presets: [['@babel/preset-env', { loose: true }], '@babel/preset-react'],
18+
babelrc: false,
19+
exclude: 'node_modules/**'
20+
}),
21+
resolve(),
22+
commonjs()
23+
]
24+
};
25+
26+
const browserConfig = {
27+
...baseConfig,
28+
output: [
29+
{ file: pkg.browser[pkg.main], format: 'cjs' },
30+
{ file: pkg.browser[pkg.module], format: 'es' }
31+
],
32+
plugins: [
33+
replace({
34+
'process.browser': JSON.stringify(true)
35+
}),
36+
...baseConfig.plugins
37+
]
38+
};
39+
40+
const configs = [
41+
baseConfig,
42+
browserConfig,
43+
{
44+
...browserConfig,
45+
output: [
46+
{
47+
file: pkg.browser[pkg.main].replace(/\.js$/, '.min.js'),
48+
format: 'cjs'
49+
}
50+
],
51+
plugins: [...browserConfig.plugins, terser({ toplevel: true })]
52+
},
53+
// FIXME: Due to a bug in rollup-plugin-terser, multiple outputs need to be
54+
// split into separate configurations.
55+
{
56+
...browserConfig,
57+
output: [
58+
{
59+
file: pkg.browser[pkg.module].replace(/\.js$/, '.min.js'),
60+
format: 'es'
61+
}
62+
],
63+
plugins: [...browserConfig.plugins, terser({ toplevel: true })]
64+
}
65+
];
66+
67+
export default configs;

‎scripts/markdown-docs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function renderType(value, extraRows = [], depth = 0, topLevel = false) {
126126
}
127127
if (value.name === 'enum') {
128128
return `One&nbsp;of... <br>\n${indent}&nbsp;&nbsp;${value.value
129-
.map(t => renderValue(t,depth+1))
129+
.map(v => renderValue(v))
130130
.join(` <br>\n${indent}&nbsp;&nbsp;`)}`;
131131
}
132132
if (value.name === 'union') {
@@ -157,7 +157,7 @@ const CODE_CHARS = {
157157
'\u00A0': '<code title="non-breaking space">\\u00A0</code>'
158158
};
159159

160-
function renderValue(value,indent=0) {
160+
function renderValue(value) {
161161
if (!value) {
162162
return '';
163163
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /