Skip to content

Commit 96a1cfc

Browse files
fix(esm): fix ESM types by adding .mts declaration files
1 parent 95e0e42 commit 96a1cfc

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Build directory
22
dist/
3+
esm/types.ts
34
lib/
45

56
# Logs

esm/client/html-to-dom.d.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { DOMNode } from '../types';
2+
3+
export default function HTMLDOMParser(html: string): DOMNode[];

esm/index.d.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './server/html-to-dom.mjs';
2+
export type * from './types';

esm/server/html-to-dom.d.mts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ParserOptions } from 'htmlparser2';
2+
import type { DOMNode } from '../types';
3+
4+
export default function HTMLDOMParser(
5+
html: string,
6+
options?: ParserOptions,
7+
): DOMNode[];

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,24 @@
55
"author": "Mark <mark@remarkablemark.org>",
66
"main": "./lib/index.js",
77
"module": "./esm/index.mjs",
8-
"types": "./lib/index.d.ts",
98
"exports": {
109
".": {
11-
"types": "./lib/index.d.ts",
1210
"import": "./esm/index.mjs",
1311
"require": "./lib/index.js"
1412
},
1513
"./lib/client/*": {
16-
"types": "./lib/client/*.d.ts",
1714
"import": "./esm/client/*.mjs",
1815
"require": "./lib/client/*.js"
1916
},
2017
"./lib/server/*": {
21-
"types": "./lib/server/*.d.ts",
2218
"import": "./esm/server/*.mjs",
2319
"require": "./lib/server/*.js"
2420
}
2521
},
2622
"scripts": {
27-
"build": "run-p build:*",
23+
"build": "run-s build:*",
2824
"build:cjs": "tsc",
25+
"build:esm": "awk '!/sourceMappingURL/' lib/types.d.ts > esm/types.ts",
2926
"build:umd": "rollup --config --failAfterWarnings",
3027
"clean": "rm -rf .nyc_output coverage dist lib",
3128
"lint": "eslint . --ignore-path .gitignore",

0 commit comments

Comments
 (0)