Skip to content

Commit

Permalink
fix(esm): fix ESM types by adding .mts declaration files
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Dec 16, 2023
1 parent 95e0e42 commit 96a1cfc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build directory
dist/
esm/types.ts
lib/

# Logs
Expand Down
3 changes: 3 additions & 0 deletions esm/client/html-to-dom.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { DOMNode } from '../types';

export default function HTMLDOMParser(html: string): DOMNode[];
2 changes: 2 additions & 0 deletions esm/index.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './server/html-to-dom.mjs';
export type * from './types';
7 changes: 7 additions & 0 deletions esm/server/html-to-dom.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ParserOptions } from 'htmlparser2';
import type { DOMNode } from '../types';

export default function HTMLDOMParser(
html: string,
options?: ParserOptions,
): DOMNode[];
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@
"author": "Mark <mark@remarkablemark.org>",
"main": "./lib/index.js",
"module": "./esm/index.mjs",
"types": "./lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./esm/index.mjs",
"require": "./lib/index.js"
},
"./lib/client/*": {
"types": "./lib/client/*.d.ts",
"import": "./esm/client/*.mjs",
"require": "./lib/client/*.js"
},
"./lib/server/*": {
"types": "./lib/server/*.d.ts",
"import": "./esm/server/*.mjs",
"require": "./lib/server/*.js"
}
},
"scripts": {
"build": "run-p build:*",
"build": "run-s build:*",
"build:cjs": "tsc",
"build:esm": "awk '!/sourceMappingURL/' lib/types.d.ts > esm/types.ts",
"build:umd": "rollup --config --failAfterWarnings",
"clean": "rm -rf .nyc_output coverage dist lib",
"lint": "eslint . --ignore-path .gitignore",
Expand Down

0 comments on commit 96a1cfc

Please sign in to comment.