diff --git a/.gitignore b/.gitignore index affeb21..586ce3d 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/html/jsx-runtime.js b/html/jsx-runtime.js deleted file mode 100644 index 4777df1..0000000 --- a/html/jsx-runtime.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @typedef {import('../lib/runtime.js').JSXProps}} JSXProps - */ - -export * from '../lib/runtime-html.js' diff --git a/jsx-runtime.js b/jsx-runtime.js deleted file mode 100644 index 0bf51b2..0000000 --- a/jsx-runtime.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @typedef {import('./lib/runtime.js').JSXProps}} JSXProps - */ - -export * from './lib/runtime-html.js' diff --git a/package.json b/package.json index 1e63895..dbaec7f 100644 --- a/package.json +++ b/package.json @@ -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" ], @@ -115,6 +109,9 @@ } } ], - "prettier": true + "prettier": true, + "rules": { + "n/file-extension-in-import": "off" + } } } diff --git a/readme.md b/readme.md index 1ff6e5f..b523782 100644 --- a/readme.md +++ b/readme.md @@ -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])` @@ -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. diff --git a/svg/jsx-runtime.js b/svg/jsx-runtime.js deleted file mode 100644 index f34e22b..0000000 --- a/svg/jsx-runtime.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @typedef {import('../lib/runtime.js').JSXProps}} JSXProps - */ - -export * from '../lib/runtime-svg.js' diff --git a/test-d/automatic-h.tsx b/test-d/automatic-h.tsx index c732e1e..7783458 100644 --- a/test-d/automatic-h.tsx +++ b/test-d/automatic-h.tsx @@ -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 diff --git a/test-d/index.ts b/test-d/index.ts index fc47f3b..5ea683c 100644 --- a/test-d/index.ts +++ b/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(h()) expectType(s()) @@ -43,11 +42,3 @@ expectType( s('circle', {cx: 120, cy: 120, r: 100}) ]) ) - -expectType(jsx(Fragment, {})) -expectType(jsx(Fragment, {children: h('x')})) -expectType(jsx('a', {})) -expectType(jsx('a', {children: 'a'})) -expectType(jsx('a', {children: h('x')})) -expectType(jsxs('a', {children: ['a', 'b']})) -expectType(jsxs('a', {children: [h('x'), h('y')]})) diff --git a/test/core.js b/test/core.js index b985be6..887b7f9 100644 --- a/test/core.js +++ b/test/core.js @@ -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'] ) } @@ -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'] ) }