Skip to content

Commit 3c39784

Browse files
author
Evgeny Zakharov
committed
feat: update rollup config
1 parent 331f401 commit 3c39784

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@types/jest": "^27.5.1",
2929
"esbuild": "^0.14.39",
3030
"eslint": "^8.16.0",
31-
"eslint-kit": "^5.1.1",
31+
"eslint-kit": "^5.1.4",
3232
"jest": "^28.1.0",
3333
"jest-serializer-path": "^0.1.15",
3434
"rollup": "^2.73.0",

rollup.config.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,50 @@
1+
/* eslint-disable import/no-default-export */
2+
/* eslint-disable no-unused-vars */
3+
14
import { defineConfig } from 'rollup'
25
import bundleSize from 'rollup-plugin-bundle-size'
36
import dts from 'rollup-plugin-dts'
47
import esbuild from 'rollup-plugin-esbuild'
58
import { terser } from 'rollup-plugin-terser'
9+
import pkg from './package.json'
10+
11+
const MINIFY = true
612

713
const src = (file) => `src/${file}`
814
const dist = (file) => `dist/${file}`
915

10-
const bundle = (input, config) =>
16+
const bundle = (input, { plugins = [], ...config }) =>
1117
defineConfig({
1218
...config,
1319
input,
20+
plugins: plugins.filter(Boolean).concat(bundleSize()),
21+
22+
// do not bundle packages
1423
external: (id) => !/^[./]/.test(id),
15-
plugins: [...(config.plugins || []), bundleSize()],
1624
})
1725

1826
const config = defineConfig([
27+
/* Compiled JS (CommonJS, ESM) */
1928
bundle(src('index.ts'), {
20-
plugins: [esbuild(), terser()],
29+
plugins: [esbuild(), MINIFY && terser()],
2130
output: [
2231
{
23-
file: dist('index.js'),
32+
file: pkg.main,
2433
format: 'cjs',
2534
},
2635
{
27-
file: dist('index.mjs'),
36+
file: pkg.module,
2837
format: 'es',
2938
},
3039
],
3140
}),
41+
42+
/* TS declarations */
3243
bundle(src('index.ts'), {
3344
plugins: [dts()],
3445
output: [
3546
{
36-
file: dist('index.d.ts'),
47+
file: pkg.types,
3748
format: 'es',
3849
},
3950
],

yarn.lock

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,15 @@ eslint-import-resolver-custom-alias@^1.3.0:
16581658
glob-parent "^5.1.0"
16591659
resolve "^1.3.0"
16601660

1661+
eslint-import-resolver-jsconfig@^1.1.0:
1662+
version "1.1.0"
1663+
resolved "https://registry.yarnpkg.com/eslint-import-resolver-jsconfig/-/eslint-import-resolver-jsconfig-1.1.0.tgz#7e2ea0868205fff33fd1d9ed79642cdeaa1e42df"
1664+
integrity sha512-MEiD/zyEkVVwnblRI058/0liYrKXMUwgAtM4EKrTldrThb1AvgPIQeR4emDKC2IotTuWF7KzekvGP+KLhtM3rw==
1665+
dependencies:
1666+
find-root "^1.1.0"
1667+
glob-parent "^6.0.1"
1668+
resolve "^1.20.0"
1669+
16611670
eslint-import-resolver-node@^0.3.6:
16621671
version "0.3.6"
16631672
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd"
@@ -1677,10 +1686,10 @@ eslint-import-resolver-typescript@^2.7.1:
16771686
resolve "^1.22.0"
16781687
tsconfig-paths "^3.14.1"
16791688

1680-
eslint-kit@^5.1.1:
1681-
version "5.1.1"
1682-
resolved "https://registry.yarnpkg.com/eslint-kit/-/eslint-kit-5.1.1.tgz#6b6548dfde43dede2fb303de483d86fae0b35b05"
1683-
integrity sha512-4At5ZZLoyZcwJ2TBTWJniMVWMf4nlRN1GQ6i5wOd4MOfQLvMMmq5Jev1yviewE3OxeBlzgyOF83x+HhrLaVtNg==
1689+
eslint-kit@^5.1.4:
1690+
version "5.1.4"
1691+
resolved "https://registry.yarnpkg.com/eslint-kit/-/eslint-kit-5.1.4.tgz#521a20953e4b5a89043c3772ee6f0c5047fb5342"
1692+
integrity sha512-LjzkcERD8wEMzN72M/fe3lxKlvpUJ2nZYr3RC0Af/TLvpdvGeE/CaO4SvazK4hoUEbhsIYZj6VTwAkUYhBaRCw==
16841693
dependencies:
16851694
"@babel/core" "^7.18.0"
16861695
"@babel/eslint-parser" "^7.17.0"
@@ -1690,6 +1699,7 @@ eslint-kit@^5.1.1:
16901699
"@typescript-eslint/parser" "5.27.0"
16911700
babel-preset-solid "^1.4.2"
16921701
eslint-import-resolver-custom-alias "^1.3.0"
1702+
eslint-import-resolver-jsconfig "^1.1.0"
16931703
eslint-import-resolver-typescript "^2.7.1"
16941704
eslint-plugin-effector "0.6.0"
16951705
eslint-plugin-import "2.26.0"
@@ -2071,6 +2081,11 @@ fill-range@^7.0.1:
20712081
dependencies:
20722082
to-regex-range "^5.0.1"
20732083

2084+
find-root@^1.1.0:
2085+
version "1.1.0"
2086+
resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4"
2087+
integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==
2088+
20742089
find-up@^2.1.0:
20752090
version "2.1.0"
20762091
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"

0 commit comments

Comments
 (0)