Skip to content

Commit

Permalink
Remove hastscript/html (auto runtime) from exports
Browse files Browse the repository at this point in the history
Use `hastscript`.
  • Loading branch information
wooorm committed Aug 1, 2023
1 parent 6976cbb commit 7e27d65
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -4,6 +4,6 @@ coverage/
node_modules/
test/jsx-*.js
yarn.lock
**/*.d.ts
*.d.ts
!lib/jsx-classic.d.ts
!lib/jsx-automatic.d.ts
5 changes: 0 additions & 5 deletions html/jsx-runtime.js

This file was deleted.

5 changes: 0 additions & 5 deletions jsx-runtime.js

This file was deleted.

19 changes: 8 additions & 11 deletions package.json
Expand Up @@ -33,19 +33,13 @@
"types": "index.d.ts",
"exports": {
".": "./index.js",
"./jsx-runtime": "./jsx-runtime.js",
"./jsx-dev-runtime": "./jsx-runtime.js",
"./html/jsx-runtime": "./html/jsx-runtime.js",
"./html/jsx-dev-runtime": "./html/jsx-runtime.js",
"./svg/jsx-runtime": "./svg/jsx-runtime.js",
"./svg/jsx-dev-runtime": "./svg/jsx-runtime.js"
"./jsx-runtime": "./lib/runtime-html.js",
"./jsx-dev-runtime": "./lib/runtime-html.js",
"./svg/jsx-runtime": "./lib/runtime-svg.js",
"./svg/jsx-dev-runtime": "./lib/runtime-svg.js"
},
"files": [
"lib/",
"html/",
"svg/",
"jsx-runtime.d.ts",
"jsx-runtime.js",
"index.d.ts",
"index.js"
],
Expand Down Expand Up @@ -115,6 +109,9 @@
}
}
],
"prettier": true
"prettier": true,
"rules": {
"n/file-extension-in-import": "off"
}
}
}
8 changes: 4 additions & 4 deletions readme.md
Expand Up @@ -150,8 +150,8 @@ This package exports the identifiers [`h`][h] and [`s`][s].
There is no default export.

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

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

Expand Down Expand Up @@ -258,8 +258,8 @@ The syntax tree is [hast][].
## JSX
This package can be used with JSX.
You should use the automatic JSX runtime set to `hastscript` (also available as
the more explicit name `hastscript/html`) or `hastscript/svg`.
You should use the automatic JSX runtime set to `hastscript` or
`hastscript/svg`.
> 👉 **Note**: while `h` supports dots (`.`) for classes or number signs (`#`)
> for IDs in `selector`, those are not supported in JSX.
Expand Down
5 changes: 0 additions & 5 deletions svg/jsx-runtime.js

This file was deleted.

2 changes: 1 addition & 1 deletion test-d/automatic-h.tsx
Expand Up @@ -4,7 +4,7 @@
import {expectType} from 'tsd'
import type {Root, Element} from 'hast'
import {h} from '../index.js'
import {Fragment, jsx, jsxs} from '../jsx-runtime.js'
import {Fragment, jsx, jsxs} from '../lib/runtime-html.js'

type Result = Element | Root

Expand Down
9 changes: 0 additions & 9 deletions test-d/index.ts
@@ -1,7 +1,6 @@
import {expectType} from 'tsd'
import type {Root, Element} from 'hast'
import {h, s} from '../index.js'
import {Fragment, jsx, jsxs} from '../jsx-runtime.js'

expectType<Root>(h())
expectType<Root>(s())
Expand Down Expand Up @@ -43,11 +42,3 @@ expectType<Element>(
s('circle', {cx: 120, cy: 120, r: 100})
])
)

expectType<Root>(jsx(Fragment, {}))
expectType<Root>(jsx(Fragment, {children: h('x')}))
expectType<Element>(jsx('a', {}))
expectType<Element>(jsx('a', {children: 'a'}))
expectType<Element>(jsx('a', {children: h('x')}))
expectType<Element>(jsxs('a', {children: ['a', 'b']}))
expectType<Element>(jsxs('a', {children: [h('x'), h('y')]}))
21 changes: 3 additions & 18 deletions test/core.js
Expand Up @@ -4,29 +4,14 @@ import {h, s} from '../index.js'

test('core', async function (t) {
await t.test('should expose the public api (`/`)', async function () {
assert.deepEqual(Object.keys(await import('../index.js')).sort(), [
'h',
's'
])
assert.deepEqual(Object.keys(await import('hastscript')).sort(), ['h', 's'])
})

await t.test(
'should expose the public api (`/jsx-runtime`)',
async function () {
assert.deepEqual(Object.keys(await import('../jsx-runtime.js')).sort(), [
'Fragment',
'jsx',
'jsxDEV',
'jsxs'
])
}
)

await t.test(
'should expose the public api (`/html/jsx-runtime`)',
async function () {
assert.deepEqual(
Object.keys(await import('../html/jsx-runtime.js')).sort(),
Object.keys(await import('hastscript/jsx-runtime')).sort(),
['Fragment', 'jsx', 'jsxDEV', 'jsxs']
)
}
Expand All @@ -36,7 +21,7 @@ test('core', async function (t) {
'should expose the public api (`/svg/jsx-runtime`)',
async function () {
assert.deepEqual(
Object.keys(await import('../svg/jsx-runtime.js')).sort(),
Object.keys(await import('hastscript/svg/jsx-runtime')).sort(),
['Fragment', 'jsx', 'jsxDEV', 'jsxs']
)
}
Expand Down

0 comments on commit 7e27d65

Please sign in to comment.