Skip to content

Commit a2eae32

Browse files
author
Evgeny Zakharov
authored
Merge pull request #11 from js-templates/feat/update-rollup-config
Update rollup config
2 parents 4cd27f2 + 5e29ba9 commit a2eae32

File tree

3 files changed

+68
-12
lines changed

3 files changed

+68
-12
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
},
2626
"dependencies": {},
2727
"devDependencies": {
28+
"@rollup/plugin-typescript": "^8.3.2",
2829
"@types/jest": "^27.5.1",
2930
"esbuild": "^0.14.39",
3031
"eslint": "^8.16.0",
31-
"eslint-kit": "^5.1.1",
32+
"eslint-kit": "^5.1.4",
3233
"jest": "^28.1.0",
3334
"jest-serializer-path": "^0.1.15",
3435
"rollup": "^2.73.0",

rollup.config.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,52 @@
1+
/* eslint-disable import/no-default-export */
2+
/* eslint-disable no-unused-vars */
3+
4+
import typescript from '@rollup/plugin-typescript'
15
import { defineConfig } from 'rollup'
26
import bundleSize from 'rollup-plugin-bundle-size'
37
import dts from 'rollup-plugin-dts'
48
import esbuild from 'rollup-plugin-esbuild'
59
import { terser } from 'rollup-plugin-terser'
10+
import pkg from './package.json'
11+
12+
const TYPECHECK = true
13+
const MINIFY = true
614

715
const src = (file) => `src/${file}`
816
const dist = (file) => `dist/${file}`
917

10-
const bundle = (input, config) =>
18+
const bundle = (input, { plugins = [], ...config }) =>
1119
defineConfig({
1220
...config,
1321
input,
22+
plugins: plugins.filter(Boolean).concat(bundleSize()),
23+
24+
// do not bundle packages
1425
external: (id) => !/^[./]/.test(id),
15-
plugins: [...(config.plugins || []), bundleSize()],
1626
})
1727

1828
const config = defineConfig([
29+
/* Compiled JS (CommonJS, ESM) */
1930
bundle(src('index.ts'), {
20-
plugins: [esbuild(), terser()],
31+
plugins: [TYPECHECK && typescript(), esbuild(), MINIFY && terser()],
2132
output: [
2233
{
23-
file: dist('index.js'),
34+
file: pkg.main,
2435
format: 'cjs',
2536
},
2637
{
27-
file: dist('index.mjs'),
38+
file: pkg.module,
2839
format: 'es',
2940
},
3041
],
3142
}),
43+
44+
/* TS declarations */
3245
bundle(src('index.ts'), {
3346
plugins: [dts()],
3447
output: [
3548
{
36-
file: dist('index.d.ts'),
49+
file: pkg.types,
3750
format: 'es',
3851
},
3952
],

yarn.lock

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,23 @@
687687
"@nodelib/fs.scandir" "2.1.5"
688688
fastq "^1.6.0"
689689

690+
"@rollup/plugin-typescript@^8.3.2":
691+
version "8.3.2"
692+
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.3.2.tgz#e1b719e2ed3e752bbc092001656c48378f2d15f0"
693+
integrity sha512-MtgyR5LNHZr3GyN0tM7gNO9D0CS+Y+vflS4v/PHmrX17JCkHUYKvQ5jN5o3cz1YKllM3duXUqu3yOHwMPUxhDg==
694+
dependencies:
695+
"@rollup/pluginutils" "^3.1.0"
696+
resolve "^1.17.0"
697+
698+
"@rollup/pluginutils@^3.1.0":
699+
version "3.1.0"
700+
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
701+
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
702+
dependencies:
703+
"@types/estree" "0.0.39"
704+
estree-walker "^1.0.1"
705+
picomatch "^2.2.2"
706+
690707
"@rollup/pluginutils@^4.1.1":
691708
version "4.2.1"
692709
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz#e6c6c3aba0744edce3fb2074922d3776c0af2a6d"
@@ -747,6 +764,11 @@
747764
dependencies:
748765
"@babel/types" "^7.3.0"
749766

767+
768+
version "0.0.39"
769+
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
770+
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
771+
750772
"@types/graceful-fs@^4.1.3":
751773
version "4.1.5"
752774
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
@@ -1658,6 +1680,15 @@ eslint-import-resolver-custom-alias@^1.3.0:
16581680
glob-parent "^5.1.0"
16591681
resolve "^1.3.0"
16601682

1683+
eslint-import-resolver-jsconfig@^1.1.0:
1684+
version "1.1.0"
1685+
resolved "https://registry.yarnpkg.com/eslint-import-resolver-jsconfig/-/eslint-import-resolver-jsconfig-1.1.0.tgz#7e2ea0868205fff33fd1d9ed79642cdeaa1e42df"
1686+
integrity sha512-MEiD/zyEkVVwnblRI058/0liYrKXMUwgAtM4EKrTldrThb1AvgPIQeR4emDKC2IotTuWF7KzekvGP+KLhtM3rw==
1687+
dependencies:
1688+
find-root "^1.1.0"
1689+
glob-parent "^6.0.1"
1690+
resolve "^1.20.0"
1691+
16611692
eslint-import-resolver-node@^0.3.6:
16621693
version "0.3.6"
16631694
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd"
@@ -1677,10 +1708,10 @@ eslint-import-resolver-typescript@^2.7.1:
16771708
resolve "^1.22.0"
16781709
tsconfig-paths "^3.14.1"
16791710

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==
1711+
eslint-kit@^5.1.4:
1712+
version "5.1.4"
1713+
resolved "https://registry.yarnpkg.com/eslint-kit/-/eslint-kit-5.1.4.tgz#521a20953e4b5a89043c3772ee6f0c5047fb5342"
1714+
integrity sha512-LjzkcERD8wEMzN72M/fe3lxKlvpUJ2nZYr3RC0Af/TLvpdvGeE/CaO4SvazK4hoUEbhsIYZj6VTwAkUYhBaRCw==
16841715
dependencies:
16851716
"@babel/core" "^7.18.0"
16861717
"@babel/eslint-parser" "^7.17.0"
@@ -1690,6 +1721,7 @@ eslint-kit@^5.1.1:
16901721
"@typescript-eslint/parser" "5.27.0"
16911722
babel-preset-solid "^1.4.2"
16921723
eslint-import-resolver-custom-alias "^1.3.0"
1724+
eslint-import-resolver-jsconfig "^1.1.0"
16931725
eslint-import-resolver-typescript "^2.7.1"
16941726
eslint-plugin-effector "0.6.0"
16951727
eslint-plugin-import "2.26.0"
@@ -1963,6 +1995,11 @@ estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0:
19631995
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
19641996
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==
19651997

1998+
estree-walker@^1.0.1:
1999+
version "1.0.1"
2000+
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
2001+
integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==
2002+
19662003
estree-walker@^2.0.1:
19672004
version "2.0.2"
19682005
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
@@ -2071,6 +2108,11 @@ fill-range@^7.0.1:
20712108
dependencies:
20722109
to-regex-range "^5.0.1"
20732110

2111+
find-root@^1.1.0:
2112+
version "1.1.0"
2113+
resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4"
2114+
integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==
2115+
20742116
find-up@^2.1.0:
20752117
version "2.1.0"
20762118
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
@@ -3638,7 +3680,7 @@ resolve.exports@^1.1.0:
36383680
resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9"
36393681
integrity sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==
36403682

3641-
resolve@^1.10.0, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.3.0:
3683+
resolve@^1.10.0, resolve@^1.17.0, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.3.0:
36423684
version "1.22.0"
36433685
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198"
36443686
integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==

0 commit comments

Comments
 (0)