Skip to content

Commit 3954d20

Browse files
committed
feat: move to TypeScript
closes #13 #11
1 parent 8e844cf commit 3954d20

13 files changed

+91
-21
lines changed

Diff for: bili.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @type {import('bili').Config} */
22
module.exports = {
33
externals: ['vue'],
4+
input: 'src/index.ts',
45
output: {
56
format: ['cjs', 'es', 'umd', 'umd-min'],
67
fileName: 'vue-content-loader.[format][min][ext]',

Diff for: package.json

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"files": [
1515
"dist"
1616
],
17+
"types": "dist/index.d.ts",
1718
"sideEffects": false,
1819
"scripts": {
1920
"prepublishOnly": "npm run build",
@@ -39,6 +40,8 @@
3940
"bili": "^5.0.5",
4041
"jest": "^26.6.3",
4142
"poi": "12.10.3",
43+
"rollup-plugin-typescript2": "^0.29.0",
44+
"typescript": "^4.1.3",
4245
"vue": "^3.0.5",
4346
"vue-loader": "^16.1.2",
4447
"vue-router": "^4.0.3"

Diff for: src/BulletListLoader.js renamed to src/BulletListLoader.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { defineComponent } from 'vue'
12
import ContentLoader from './ContentLoader'
23

3-
const BulletListLoader = (props, { attrs }) => {
4-
return (
4+
const BulletListLoader = defineComponent((props, { attrs }) => {
5+
return () => (
56
<ContentLoader {...attrs}>
67
<circle cx="10" cy="20" r="8" />
78
<rect x="25" y="15" rx="5" ry="5" width="220" height="10" />
@@ -13,6 +14,6 @@ const BulletListLoader = (props, { attrs }) => {
1314
<rect x="25" y="105" rx="5" ry="5" width="220" height="10" />
1415
</ContentLoader>
1516
)
16-
}
17+
})
1718

1819
export default BulletListLoader

Diff for: src/CodeLoader.js renamed to src/CodeLoader.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { defineComponent } from 'vue'
12
import ContentLoader from './ContentLoader'
23

3-
const CodeLoader = (props, { attrs }) => {
4-
return (
4+
const CodeLoader = defineComponent((props, { attrs }) => {
5+
return () => (
56
<ContentLoader {...attrs}>
67
<rect x="0" y="0" rx="3" ry="3" width="70" height="10" />
78
<rect x="80" y="0" rx="3" ry="3" width="100" height="10" />
@@ -17,6 +18,6 @@ const CodeLoader = (props, { attrs }) => {
1718
<rect x="0" y="60" rx="3" ry="3" width="30" height="10" />
1819
</ContentLoader>
1920
)
20-
}
21+
})
2122

2223
export default CodeLoader
File renamed without changes.
+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { defineComponent } from 'vue'
12
import ContentLoader from './ContentLoader'
23

3-
const FacebookLoader = (props, { attrs }) => {
4-
return (
4+
const FacebookLoader = defineComponent((props, { attrs }) => {
5+
return () => (
56
<ContentLoader {...attrs}>
67
<rect x="70" y="15" rx="4" ry="4" width="117" height="6.4" />
78
<rect x="70" y="35" rx="3" ry="3" width="85" height="6.4" />
@@ -11,6 +12,6 @@ const FacebookLoader = (props, { attrs }) => {
1112
<circle cx="30" cy="30" r="30" />
1213
</ContentLoader>
1314
)
14-
}
15+
})
1516

1617
export default FacebookLoader
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { defineComponent } from 'vue'
12
import ContentLoader from './ContentLoader'
23

3-
const InstagramLoader = (props, { attrs }) => {
4-
return (
4+
const InstagramLoader = defineComponent((props, { attrs }) => {
5+
return () => (
56
<ContentLoader {...attrs} viewBox="0 0 400 480">
67
<circle cx="30" cy="30" r="30" />
78

@@ -10,6 +11,6 @@ const InstagramLoader = (props, { attrs }) => {
1011
<rect x="0" y="70" rx="5" ry="5" width="400" height="400" />
1112
</ContentLoader>
1213
)
13-
}
14+
})
1415

1516
export default InstagramLoader

Diff for: src/ListLoader.js renamed to src/ListLoader.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { defineComponent } from 'vue'
12
import ContentLoader from './ContentLoader'
23

3-
const ListLoader = (props, { attrs }) => {
4-
return (
4+
const ListLoader = defineComponent((props, { attrs }) => {
5+
return () => (
56
<ContentLoader {...attrs}>
67
<rect x="0" y="0" rx="3" ry="3" width="250" height="10" />
78
<rect x="20" y="20" rx="3" ry="3" width="220" height="10" />
@@ -11,6 +12,6 @@ const ListLoader = (props, { attrs }) => {
1112
<rect x="20" y="100" rx="3" ry="3" width="80" height="10" />
1213
</ContentLoader>
1314
)
14-
}
15+
})
1516

1617
export default ListLoader

Diff for: src/index.js renamed to src/index.ts

File renamed without changes.

Diff for: src/uid.js renamed to src/uid.ts

File renamed without changes.

Diff for: stories/Storybook.vue

+1-6
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ export default {
5353
},
5454
5555
currentComponent() {
56-
if (this.current) {
57-
const { story } = this.current
58-
return typeof story.component === 'function'
59-
? story.component()
60-
: story.component
61-
}
56+
return this.current?.story.component;
6257
},
6358
6459
currentTitle() {

Diff for: tsconfig.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"include": ["src/**/*.ts", "src/**/*.tsx"],
3+
"exclude": ["node_modules", "dist"],
4+
"compilerOptions": {
5+
"rootDir": "src",
6+
"target": "es5",
7+
"module": "esnext",
8+
"jsx": "preserve",
9+
"moduleResolution": "node",
10+
"declaration": true,
11+
"sourceMap": true,
12+
"strict": true,
13+
"noImplicitAny": true,
14+
"esModuleInterop": true,
15+
"forceConsistentCasingInFileNames": true
16+
}
17+
}

Diff for: yarn.lock

+49
Original file line numberDiff line numberDiff line change
@@ -5080,6 +5080,15 @@ from2@^2.1.0:
50805080
inherits "^2.0.1"
50815081
readable-stream "^2.0.0"
50825082

5083+
5084+
version "8.1.0"
5085+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
5086+
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
5087+
dependencies:
5088+
graceful-fs "^4.2.0"
5089+
jsonfile "^4.0.0"
5090+
universalify "^0.1.0"
5091+
50835092
fs-extra@^9.0.0:
50845093
version "9.0.1"
50855094
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"
@@ -6634,6 +6643,13 @@ json5@^2.1.2:
66346643
dependencies:
66356644
minimist "^1.2.5"
66366645

6646+
jsonfile@^4.0.0:
6647+
version "4.0.0"
6648+
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
6649+
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
6650+
optionalDependencies:
6651+
graceful-fs "^4.1.6"
6652+
66376653
jsonfile@^6.0.1:
66386654
version "6.1.0"
66396655
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
@@ -8910,6 +8926,13 @@ resolve-url@^0.2.1:
89108926
version "0.2.1"
89118927
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
89128928

8929+
8930+
version "1.17.0"
8931+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444"
8932+
integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==
8933+
dependencies:
8934+
path-parse "^1.0.6"
8935+
89138936
resolve@^1.10.0, resolve@^1.8.1:
89148937
version "1.11.1"
89158938
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e"
@@ -9034,6 +9057,17 @@ rollup-plugin-terser@^6.1.0:
90349057
serialize-javascript "^3.0.0"
90359058
terser "^4.7.0"
90369059

9060+
rollup-plugin-typescript2@^0.29.0:
9061+
version "0.29.0"
9062+
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.29.0.tgz#b7ad83f5241dbc5bdf1e98d9c3fca005ffe39e1a"
9063+
integrity sha512-YytahBSZCIjn/elFugEGQR5qTsVhxhUwGZIsA9TmrSsC88qroGo65O5HZP/TTArH2dm0vUmYWhKchhwi2wL9bw==
9064+
dependencies:
9065+
"@rollup/pluginutils" "^3.1.0"
9066+
find-cache-dir "^3.3.1"
9067+
fs-extra "8.1.0"
9068+
resolve "1.17.0"
9069+
tslib "2.0.1"
9070+
90379071
rollup-pluginutils@^2.8.2:
90389072
version "2.8.2"
90399073
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
@@ -10028,6 +10062,11 @@ trim-right@^1.0.1:
1002810062
version "1.0.1"
1002910063
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
1003010064

10065+
10066+
version "2.0.1"
10067+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"
10068+
integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==
10069+
1003110070
tslib@^1.9.0:
1003210071
version "1.10.0"
1003310072
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
@@ -10099,6 +10138,11 @@ typedarray@^0.0.6:
1009910138
version "0.0.6"
1010010139
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1010110140

10141+
typescript@^4.1.3:
10142+
version "4.1.3"
10143+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
10144+
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
10145+
1010210146
1010310147
version "3.4.10"
1010410148
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"
@@ -10165,6 +10209,11 @@ unique-slug@^2.0.0:
1016510209
dependencies:
1016610210
imurmurhash "^0.1.4"
1016710211

10212+
universalify@^0.1.0:
10213+
version "0.1.2"
10214+
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
10215+
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
10216+
1016810217
universalify@^1.0.0:
1016910218
version "1.0.0"
1017010219
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"

0 commit comments

Comments
 (0)