Skip to content

Commit 7e27d65

Browse files
committed
Remove hastscript/html (auto runtime) from exports
Use `hastscript`.
1 parent 6976cbb commit 7e27d65

File tree

9 files changed

+17
-59
lines changed

9 files changed

+17
-59
lines changed

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ coverage/
44
node_modules/
55
test/jsx-*.js
66
yarn.lock
7-
**/*.d.ts
7+
*.d.ts
88
!lib/jsx-classic.d.ts
99
!lib/jsx-automatic.d.ts

Diff for: html/jsx-runtime.js

-5
This file was deleted.

Diff for: jsx-runtime.js

-5
This file was deleted.

Diff for: package.json

+8-11
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,13 @@
3333
"types": "index.d.ts",
3434
"exports": {
3535
".": "./index.js",
36-
"./jsx-runtime": "./jsx-runtime.js",
37-
"./jsx-dev-runtime": "./jsx-runtime.js",
38-
"./html/jsx-runtime": "./html/jsx-runtime.js",
39-
"./html/jsx-dev-runtime": "./html/jsx-runtime.js",
40-
"./svg/jsx-runtime": "./svg/jsx-runtime.js",
41-
"./svg/jsx-dev-runtime": "./svg/jsx-runtime.js"
36+
"./jsx-runtime": "./lib/runtime-html.js",
37+
"./jsx-dev-runtime": "./lib/runtime-html.js",
38+
"./svg/jsx-runtime": "./lib/runtime-svg.js",
39+
"./svg/jsx-dev-runtime": "./lib/runtime-svg.js"
4240
},
4341
"files": [
4442
"lib/",
45-
"html/",
46-
"svg/",
47-
"jsx-runtime.d.ts",
48-
"jsx-runtime.js",
4943
"index.d.ts",
5044
"index.js"
5145
],
@@ -115,6 +109,9 @@
115109
}
116110
}
117111
],
118-
"prettier": true
112+
"prettier": true,
113+
"rules": {
114+
"n/file-extension-in-import": "off"
115+
}
119116
}
120117
}

Diff for: readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ This package exports the identifiers [`h`][h] and [`s`][s].
150150
There is no default export.
151151

152152
The export map supports the automatic JSX runtime.
153-
You can pass `hastscript` (or `hastscript/html`) or `hastscript/svg` to your
154-
build tool (TypeScript, Babel, SWC) with an `importSource` option or similar.
153+
You can pass `hastscript` or `hastscript/svg` to your build tool (TypeScript,
154+
Babel, SWC) with an `importSource` option or similar.
155155

156156
### `h(selector?[, properties][, …children])`
157157

@@ -258,8 +258,8 @@ The syntax tree is [hast][].
258258
## JSX
259259
260260
This package can be used with JSX.
261-
You should use the automatic JSX runtime set to `hastscript` (also available as
262-
the more explicit name `hastscript/html`) or `hastscript/svg`.
261+
You should use the automatic JSX runtime set to `hastscript` or
262+
`hastscript/svg`.
263263
264264
> 👉 **Note**: while `h` supports dots (`.`) for classes or number signs (`#`)
265265
> for IDs in `selector`, those are not supported in JSX.

Diff for: svg/jsx-runtime.js

-5
This file was deleted.

Diff for: test-d/automatic-h.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import {expectType} from 'tsd'
55
import type {Root, Element} from 'hast'
66
import {h} from '../index.js'
7-
import {Fragment, jsx, jsxs} from '../jsx-runtime.js'
7+
import {Fragment, jsx, jsxs} from '../lib/runtime-html.js'
88

99
type Result = Element | Root
1010

Diff for: test-d/index.ts

-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {expectType} from 'tsd'
22
import type {Root, Element} from 'hast'
33
import {h, s} from '../index.js'
4-
import {Fragment, jsx, jsxs} from '../jsx-runtime.js'
54

65
expectType<Root>(h())
76
expectType<Root>(s())
@@ -43,11 +42,3 @@ expectType<Element>(
4342
s('circle', {cx: 120, cy: 120, r: 100})
4443
])
4544
)
46-
47-
expectType<Root>(jsx(Fragment, {}))
48-
expectType<Root>(jsx(Fragment, {children: h('x')}))
49-
expectType<Element>(jsx('a', {}))
50-
expectType<Element>(jsx('a', {children: 'a'}))
51-
expectType<Element>(jsx('a', {children: h('x')}))
52-
expectType<Element>(jsxs('a', {children: ['a', 'b']}))
53-
expectType<Element>(jsxs('a', {children: [h('x'), h('y')]}))

Diff for: test/core.js

+3-18
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,14 @@ import {h, s} from '../index.js'
44

55
test('core', async function (t) {
66
await t.test('should expose the public api (`/`)', async function () {
7-
assert.deepEqual(Object.keys(await import('../index.js')).sort(), [
8-
'h',
9-
's'
10-
])
7+
assert.deepEqual(Object.keys(await import('hastscript')).sort(), ['h', 's'])
118
})
129

1310
await t.test(
1411
'should expose the public api (`/jsx-runtime`)',
15-
async function () {
16-
assert.deepEqual(Object.keys(await import('../jsx-runtime.js')).sort(), [
17-
'Fragment',
18-
'jsx',
19-
'jsxDEV',
20-
'jsxs'
21-
])
22-
}
23-
)
24-
25-
await t.test(
26-
'should expose the public api (`/html/jsx-runtime`)',
2712
async function () {
2813
assert.deepEqual(
29-
Object.keys(await import('../html/jsx-runtime.js')).sort(),
14+
Object.keys(await import('hastscript/jsx-runtime')).sort(),
3015
['Fragment', 'jsx', 'jsxDEV', 'jsxs']
3116
)
3217
}
@@ -36,7 +21,7 @@ test('core', async function (t) {
3621
'should expose the public api (`/svg/jsx-runtime`)',
3722
async function () {
3823
assert.deepEqual(
39-
Object.keys(await import('../svg/jsx-runtime.js')).sort(),
24+
Object.keys(await import('hastscript/svg/jsx-runtime')).sort(),
4025
['Fragment', 'jsx', 'jsxDEV', 'jsxs']
4126
)
4227
}

0 commit comments

Comments
 (0)