Skip to content

Commit 87de16d

Browse files
committed
chore: add typing
1 parent c2c265a commit 87de16d

7 files changed

Lines changed: 123 additions & 14 deletions

File tree

.changeset/poor-crabs-provide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vnphanquang/green-check': patch
3+
---
4+
5+
export typing in build output

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
"files": [
2424
"dist"
2525
],
26-
"main": "./dist/greencheck..umd.cjs",
27-
"module": "./dist/greencheck.js",
26+
"main": "./dist/index.umd.cjs",
27+
"module": "./dist/index.js",
28+
"types": "./dist/index.d.ts",
2829
"exports": {
2930
".": {
30-
"import": "./dist/greencheck.js",
31-
"require": "./dist/greencheck.umd.js"
31+
"import": "./dist/index.js",
32+
"require": "./dist/index.umd.js",
33+
"types": "./dist/index.d.ts"
3234
}
3335
},
3436
"scripts": {
@@ -38,7 +40,7 @@
3840
"dev": "vite",
3941
"build": "vite build",
4042
"preview": "vite preview",
41-
"prepublishOnly": "pnpm run build",
43+
"prepublishOnly": "pnpm run build && publint",
4244
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
4345
"ci:publish": "changeset publish && pnpm install"
4446
},
@@ -55,6 +57,7 @@
5557
"husky": "^9.1.1",
5658
"lint-staged": "^15.2.7",
5759
"prettier": "3.3.3",
60+
"publint": "^0.2.9",
5861
"stylelint": "^16.7.0",
5962
"stylelint-config-clean-order": "^6.1.0",
6063
"stylelint-config-html": "^1.1.0",

pnpm-lock.yaml

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module '@vnphanquang/green-check' {
2+
class GreenCheck extends HTMLElement {}
3+
4+
export { GreenCheck };
5+
}

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference types="vite/client" />
2+
13
import css from './template.css?raw';
24
import html from './template.html?raw';
35

@@ -23,7 +25,7 @@ export class GreenCheck extends HTMLElement {
2325
if (hostname) {
2426
const greencheck = await (await fetch(GREENCHECK_API_ENDPOINT + encodedHostname)).json();
2527
if (greencheck.green) {
26-
this.setAttribute('green', true);
28+
this.toggleAttribute('green', true);
2729
title = 'Green hosting';
2830
line1 = hostname.slice(0, 30);
2931
line2 = 'Hosted by ' + greencheck.hosted_by;

tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"checkJs": true,
6+
"noEmit": true,
7+
"strict": true,
8+
"target": "es2020",
9+
"module": "es2022",
10+
"moduleResolution": "node",
11+
"allowSyntheticDefaultImports": true,
12+
"noUnusedLocals": true,
13+
"noUnusedParameters": true
14+
},
15+
"include": ["src/**/*"],
16+
"exclude": ["node_modules"]
17+
}

vite.config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { resolve } from 'path';
2+
23
import { defineConfig } from 'vite';
34

45
export default defineConfig({
5-
build: {
6-
lib: {
7-
entry: resolve(__dirname, 'src/index.js'),
8-
name: 'GreenCheck',
9-
fileName: 'greencheck',
10-
},
6+
build: {
7+
lib: {
8+
entry: resolve(__dirname, 'src/index.js'),
9+
name: 'GreenCheck',
10+
fileName: 'index',
11+
},
1112
},
12-
})
13-
13+
});

0 commit comments

Comments
 (0)