Skip to content

Commit aed73bb

Browse files
committed
More typescript and rollup
1 parent feba575 commit aed73bb

File tree

5 files changed

+156
-64
lines changed

5 files changed

+156
-64
lines changed

packages/mdx/package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"diff": "^4.0.2",
2828
"hast-util-to-estree": "^1.4.0",
2929
"is-plain-obj": "^3.0.0",
30-
"node-fetch": "^2.0.0",
3130
"mdx-bundler": "^8.0.1",
31+
"node-fetch": "^2.0.0",
3232
"remark-rehype": "^8.1.0",
3333
"shiki": "^0.10.1",
3434
"unified": "^9.2.2",
@@ -37,25 +37,27 @@
3737
"use-spring": "^0.2.3"
3838
},
3939
"devDependencies": {
40-
"@rollup/plugin-json": "^4.1.0",
4140
"@mdx-js/mdx": "^2.0.0",
41+
"@rollup/plugin-json": "^4.1.0",
42+
"@types/diff": "^5.0.2",
4243
"@types/node": "^17.0.21",
4344
"@types/node-fetch": "^2.6.1",
4445
"@types/react": "^17.0.39",
46+
"autoprefixer": "^9.8.2",
47+
"cssnano": "^4.1.10",
4548
"esbuild": "^0.13.2",
4649
"mdx-bundler": "^6.0.1",
4750
"next": "^12.1.0",
4851
"react": "^17.0.2",
4952
"react-dom": "^17.0.2",
5053
"react-json-view": "^1.21.3",
51-
"sass": "^1.49.9",
52-
"typescript": "^3.9.5",
53-
"vite": "^2.8.6",
5454
"rollup": "^2.41.2",
55-
"autoprefixer": "^9.8.2",
56-
"cssnano": "^4.1.10",
55+
"rollup-plugin-delete": "^2.0.0",
5756
"rollup-plugin-postcss": "^4.0.0",
5857
"rollup-plugin-typescript2": "^0.27.1",
58+
"sass": "^1.49.9",
59+
"typescript": "^4.6.2",
60+
"vite": "^2.8.6",
5961
"vitest": "^0.5.9"
6062
},
6163
"peerDependencies": {

packages/mdx/rollup.config.js

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,67 @@ import typescript from "rollup-plugin-typescript2"
66
// import copy from "rollup-plugin-copy"
77
import path from "path"
88
import json from "@rollup/plugin-json"
9-
import fs from "fs"
9+
import del from "rollup-plugin-delete"
1010

11-
const createConfig = filename => ({
12-
input: `src/${filename}.tsx`,
13-
output: [
14-
// {
15-
// file: `./dist/${filename}.js`,
16-
// format: "umd",
17-
// name: "ch", //todo get by parameter
18-
// },
11+
export default function makeConfig(commandOptions) {
12+
return [
1913
{
20-
file: `./dist/${filename}.cjs.js`,
21-
format: "cjs",
14+
input: "src/index.scss",
15+
output: {
16+
file: "dist/index.css",
17+
format: "es",
18+
},
19+
plugins: [
20+
del({ targets: "dist/*" }),
21+
postcss({
22+
extract: path.resolve("dist/index.css"),
23+
plugins: [autoprefixer(), cssnano()],
24+
}),
25+
],
2226
},
2327
{
24-
file: `./dist/${filename}.esm.js`,
25-
format: "es",
28+
input: `src/index.tsx`,
29+
output: [
30+
{
31+
file: `./dist/index.cjs.js`,
32+
format: "cjs",
33+
},
34+
{
35+
file: `./dist/index.esm.js`,
36+
format: "es",
37+
},
38+
],
39+
// external: ["react"],
40+
plugins: [
41+
json({ compact: true }),
42+
typescript({
43+
tsconfigOverride: {
44+
compilerOptions: { jsx: "react" },
45+
},
46+
}),
47+
],
2648
},
27-
],
28-
// external: ["react"],
29-
plugins: [
30-
json({ compact: true }),
31-
typescript({
32-
tsconfigOverride: {
33-
compilerOptions: { jsx: "react" },
34-
},
35-
}),
36-
postcss({
37-
extract: path.resolve("dist/index.css"),
38-
plugins: [autoprefixer(), cssnano()],
39-
}),
40-
// copy({
41-
// targets: [{ src: "src/index.scss", dest: "dist" }],
42-
// }),
43-
],
44-
})
45-
46-
export default function makeConfig(commandOptions) {
47-
const { inputs = ["index"] } = JSON.parse(
48-
fs.readFileSync("package.json", "utf8")
49-
)
50-
return inputs.map(createConfig)
49+
{
50+
input: `src/components.tsx`,
51+
output: [
52+
{
53+
file: `./dist/components.cjs.js`,
54+
format: "cjs",
55+
},
56+
{
57+
file: `./dist/components.esm.js`,
58+
format: "es",
59+
},
60+
],
61+
// external: ["react"],
62+
plugins: [
63+
json({ compact: true }),
64+
typescript({
65+
tsconfigOverride: {
66+
compilerOptions: { jsx: "react" },
67+
},
68+
}),
69+
],
70+
},
71+
]
5172
}

packages/mdx/src/smooth-code/tween.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ export type TweenParams =
1010
}
1111

1212
export function tween(params: TweenParams, t: number) {
13-
if (params.fixed) return params.value
14-
const [start, end] = params.interval
15-
const [from, to] = params.extremes
16-
if (t < start) return from
17-
if (t > end) return to
18-
const x = (t - start) / (end - start)
19-
const ease = params.ease || easing.linear
20-
return from + ease(x) * (to - from)
13+
// needs === true for typescript...
14+
if (params.fixed === true) {
15+
return params.value
16+
} else {
17+
const [start, end] = params.interval
18+
const [from, to] = params.extremes
19+
if (t < start) return from
20+
if (t > end) return to
21+
const x = (t - start) / (end - start)
22+
const ease = params.ease || easing.linear
23+
return from + ease(x) * (to - from)
24+
}
2125
}
2226

2327
export function stagger(

packages/mdx/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
"node_modules/*"
3232
]
3333
},
34-
// remove
3534
"downlevelIteration": true,
3635
"resolveJsonModule": true,
37-
"target": "es5",
36+
"target": "es6",
3837
"allowJs": true,
3938
"skipLibCheck": true,
4039
"forceConsistentCasingInFileNames": true,
4140
"noEmit": true,
42-
"isolatedModules": true
41+
"isolatedModules": true,
42+
"incremental": true
4343
},
4444
"exclude": [
4545
"node_modules"

yarn.lock

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,11 @@
12251225
dependencies:
12261226
"@types/ms" "*"
12271227

1228+
"@types/diff@^5.0.2":
1229+
version "5.0.2"
1230+
resolved "https://registry.yarnpkg.com/@types/diff/-/diff-5.0.2.tgz#dd565e0086ccf8bc6522c6ebafd8a3125c91c12b"
1231+
integrity sha512-uw8eYMIReOwstQ0QKF0sICefSy8cNO/v7gOTiIy9SbwuHyEecJUm7qlgueOO5S1udZ5I/irVydHVwMchgzbKTg==
1232+
12281233
"@types/estree-jsx@^0.0.1":
12291234
version "0.0.1"
12301235
resolved "https://registry.yarnpkg.com/@types/estree-jsx/-/estree-jsx-0.0.1.tgz#c36d7a1afeb47a95a8ee0b7bc8bc705db38f919d"
@@ -1252,6 +1257,14 @@
12521257
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83"
12531258
integrity sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw==
12541259

1260+
"@types/glob@^7.1.1":
1261+
version "7.2.0"
1262+
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
1263+
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
1264+
dependencies:
1265+
"@types/minimatch" "*"
1266+
"@types/node" "*"
1267+
12551268
"@types/hast@^2.0.0":
12561269
version "2.3.4"
12571270
resolved "https://registry.yarnpkg.com/@types/hast/-/hast-2.3.4.tgz#8aa5ef92c117d20d974a82bdfb6a648b08c0bafc"
@@ -1288,7 +1301,7 @@
12881301
resolved "https://registry.yarnpkg.com/@types/mdx/-/mdx-2.0.1.tgz#e4c05d355d092d7b58db1abfe460e53f41102ac8"
12891302
integrity sha512-JPEv4iAl0I+o7g8yVWDwk30es8mfVrjkvh5UeVR2sYPpZCK44vrAPsbJpIS+rJAUxLgaSAMKTEH5Vn5qd9XsrQ==
12901303

1291-
"@types/minimatch@^3.0.3":
1304+
"@types/minimatch@*", "@types/minimatch@^3.0.3":
12921305
version "3.0.5"
12931306
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"
12941307
integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==
@@ -2655,6 +2668,20 @@ define-properties@^1.1.3:
26552668
dependencies:
26562669
object-keys "^1.0.12"
26572670

2671+
del@^5.1.0:
2672+
version "5.1.0"
2673+
resolved "https://registry.yarnpkg.com/del/-/del-5.1.0.tgz#d9487c94e367410e6eff2925ee58c0c84a75b3a7"
2674+
integrity sha512-wH9xOVHnczo9jN2IW68BabcecVPxacIA3g/7z6vhSU/4stOKQzeCRK0yD0A24WiAAUJmmVpWqrERcTxnLo3AnA==
2675+
dependencies:
2676+
globby "^10.0.1"
2677+
graceful-fs "^4.2.2"
2678+
is-glob "^4.0.1"
2679+
is-path-cwd "^2.2.0"
2680+
is-path-inside "^3.0.1"
2681+
p-map "^3.0.0"
2682+
rimraf "^3.0.0"
2683+
slash "^3.0.0"
2684+
26582685
delayed-stream@~1.0.0:
26592686
version "1.0.0"
26602687
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
@@ -3297,7 +3324,7 @@ fast-deep-equal@^3.1.1:
32973324
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
32983325
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
32993326

3300-
fast-glob@^3.1.1, fast-glob@^3.2.9:
3327+
fast-glob@^3.0.3, fast-glob@^3.1.1, fast-glob@^3.2.9:
33013328
version "3.2.11"
33023329
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
33033330
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
@@ -3679,6 +3706,20 @@ glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6:
36793706
once "^1.3.0"
36803707
path-is-absolute "^1.0.0"
36813708

3709+
globby@^10.0.1:
3710+
version "10.0.2"
3711+
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.2.tgz#277593e745acaa4646c3ab411289ec47a0392543"
3712+
integrity sha512-7dUi7RvCoT/xast/o/dLN53oqND4yk0nsHkhRgn9w65C4PofCLOoJ39iSOg+qVDdWQPIEj+eszMHQ+aLVwwQSg==
3713+
dependencies:
3714+
"@types/glob" "^7.1.1"
3715+
array-union "^2.1.0"
3716+
dir-glob "^3.0.1"
3717+
fast-glob "^3.0.3"
3718+
glob "^7.1.3"
3719+
ignore "^5.1.1"
3720+
merge2 "^1.2.3"
3721+
slash "^3.0.0"
3722+
36823723
globby@^11.0.2:
36833724
version "11.1.0"
36843725
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
@@ -3963,7 +4004,7 @@ ignore@^3.3.5:
39634004
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
39644005
integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==
39654006

3966-
ignore@^5.2.0:
4007+
ignore@^5.1.1, ignore@^5.2.0:
39674008
version "5.2.0"
39684009
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
39694010
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
@@ -4269,6 +4310,16 @@ is-obj@^2.0.0:
42694310
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982"
42704311
integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==
42714312

4313+
is-path-cwd@^2.2.0:
4314+
version "2.2.0"
4315+
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb"
4316+
integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==
4317+
4318+
is-path-inside@^3.0.1:
4319+
version "3.0.3"
4320+
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283"
4321+
integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==
4322+
42724323
is-plain-obj@^1.0.0, is-plain-obj@^1.1.0:
42734324
version "1.1.0"
42744325
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
@@ -5025,7 +5076,7 @@ merge-stream@^2.0.0:
50255076
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
50265077
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
50275078

5028-
merge2@^1.3.0, merge2@^1.4.1:
5079+
merge2@^1.2.3, merge2@^1.3.0, merge2@^1.4.1:
50295080
version "1.4.1"
50305081
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
50315082
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
@@ -5928,6 +5979,13 @@ p-map-series@^2.1.0:
59285979
resolved "https://registry.yarnpkg.com/p-map-series/-/p-map-series-2.1.0.tgz#7560d4c452d9da0c07e692fdbfe6e2c81a2a91f2"
59295980
integrity sha512-RpYIIK1zXSNEOdwxcfe7FdvGcs7+y5n8rifMhMNWvaxRNMPINJHF5GDeuVxWqnfrcHPSCnp7Oo5yNXHId9Av2Q==
59305981

5982+
p-map@^3.0.0:
5983+
version "3.0.0"
5984+
resolved "https://registry.yarnpkg.com/p-map/-/p-map-3.0.0.tgz#d704d9af8a2ba684e2600d9a215983d4141a979d"
5985+
integrity sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==
5986+
dependencies:
5987+
aggregate-error "^3.0.0"
5988+
59315989
p-map@^4.0.0:
59325990
version "4.0.0"
59335991
resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b"
@@ -7275,13 +7333,20 @@ rimraf@^2.6.3:
72757333
dependencies:
72767334
glob "^7.1.3"
72777335

7278-
rimraf@^3.0.2:
7336+
rimraf@^3.0.0, rimraf@^3.0.2:
72797337
version "3.0.2"
72807338
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
72817339
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
72827340
dependencies:
72837341
glob "^7.1.3"
72847342

7343+
rollup-plugin-delete@^2.0.0:
7344+
version "2.0.0"
7345+
resolved "https://registry.yarnpkg.com/rollup-plugin-delete/-/rollup-plugin-delete-2.0.0.tgz#262acf80660d48c3b167fb0baabd0c3ab985c153"
7346+
integrity sha512-/VpLMtDy+8wwRlDANuYmDa9ss/knGsAgrDhM+tEwB1npHwNu4DYNmDfUL55csse/GHs9Q+SMT/rw9uiaZ3pnzA==
7347+
dependencies:
7348+
del "^5.1.0"
7349+
72857350
rollup-plugin-postcss@^4.0.0:
72867351
version "4.0.2"
72877352
resolved "https://registry.yarnpkg.com/rollup-plugin-postcss/-/rollup-plugin-postcss-4.0.2.tgz#15e9462f39475059b368ce0e49c800fa4b1f7050"
@@ -8135,10 +8200,10 @@ typescript-memoize@^1.0.0-alpha.3:
81358200
resolved "https://registry.yarnpkg.com/typescript-memoize/-/typescript-memoize-1.1.0.tgz#4a8f512d06fc995167c703a3592219901db8bc79"
81368201
integrity sha512-LQPKVXK8QrBBkL/zclE6YgSWn0I8ew5m0Lf+XL00IwMhlotqRLlzHV+BRrljVQIc+NohUAuQP7mg4HQwrx5Xbg==
81378202

8138-
typescript@^3.9.5:
8139-
version "3.9.10"
8140-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
8141-
integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==
8203+
typescript@^4.6.2:
8204+
version "4.6.2"
8205+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"
8206+
integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==
81428207

81438208
typical@^4.0.0:
81448209
version "4.0.0"

0 commit comments

Comments
 (0)