Skip to content

Commit

Permalink
Leverage TypeScript project references
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Jul 2, 2024
1 parent 7bf4c04 commit c17b71d
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coverage/
node_modules/
*.d.ts
types/
*.tsbuildinfo
*.log
.DS_Store
react-markdown.min.js
Expand Down
9 changes: 0 additions & 9 deletions index.js

This file was deleted.

9 changes: 9 additions & 0 deletions lib/exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type {ExtraProps} from 'hast-util-to-jsx-runtime'
export {
type AllowElement,
type Components,
type Options,
type UrlTransform,
defaultUrlTransform,
default
} from './index.js'
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const deprecations = [
* @returns {ReactElement}
* React element.
*/
export function Markdown(options) {
export default function Markdown(options) {
const allowedElements = options.allowedElements
const allowElement = options.allowElement
const children = options.children || ''
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@
],
"sideEffects": false,
"type": "module",
"exports": "./index.js",
"exports": {
"types": "./types/exports.d.ts",
"default": "./lib/index.js"
},
"files": [
"lib/",
"index.d.ts",
"index.js"
"types/"
],
"dependencies": {
"@types/hast": "^3.0.0",
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"checkJs": true,
"customConditions": ["development"],
"exactOptionalPropertyTypes": true,
"module": "node16",
"strict": true,
"target": "es2022"
}
}
14 changes: 14 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"composite": true,
"declaration": true,
"emitDeclarationOnly": true,
"lib": ["dom", "es2022"],
"outDir": "types/",
"rootDir": "lib/",
"target": "es2022",
"types": []
},
"include": ["lib/"]
}
17 changes: 6 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"checkJs": true,
"customConditions": ["development"],
"declaration": true,
"emitDeclarationOnly": true,
"exactOptionalPropertyTypes": true,
"jsx": "preserve",
"lib": ["dom", "es2022"],
"module": "node16",
"strict": true,
"target": "es2022"
"lib": ["es2022"],
"noEmit": true,
"types": ["node"]
},
"exclude": ["coverage/", "node_modules/"],
"include": ["**/*.js", "**/*.jsx", "lib/complex-types.d.ts"]
"exclude": ["coverage/", "lib/", "node_modules/"],
"references": [{"path": "./tsconfig.build.json"}]
}

0 comments on commit c17b71d

Please sign in to comment.