Skip to content

Commit 6cf9462

Browse files
committed
refactor: Use only named exports, rather than a mix
1 parent 7fa49c9 commit 6cf9462

File tree

9 files changed

+13
-17
lines changed

9 files changed

+13
-17
lines changed

src/hydrate.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { ComponentChild } from 'preact';
22

3-
export default function hydrate(jsx: ComponentChild, parent?: Element | Document | ShadowRoot | DocumentFragment): void;
3+
export function hydrate(jsx: ComponentChild, parent?: Element | Document | ShadowRoot | DocumentFragment): void;

src/hydrate.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { render, hydrate as hydrativeRender } from 'preact';
22

33
let initialized;
44

5-
/** @type {typeof render} */
6-
export default function hydrate(jsx, parent) {
5+
/** @type {typeof hydrativeRender} */
6+
export function hydrate(jsx, parent) {
77
if (typeof window === 'undefined') return;
88
let isodata = document.querySelector('script[type=isodata]');
99
// @ts-ignore-next

src/index.d.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { default as prerender } from './prerender.js';
21
export * from './router.js';
3-
export { default as lazy, ErrorBoundary } from './lazy.js';
4-
export { default as hydrate } from './hydrate.js';
2+
export * from './lazy.js';
3+
export * from './hydrate.js';

src/index.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1+
// lack of wildcard export is intentional to avoid exposing `exec`
12
export { Router, LocationProvider, useLocation, Route, useRoute } from './router.js';
2-
export { default as lazy, ErrorBoundary } from './lazy.js';
3-
export { default as hydrate } from './hydrate.js';
4-
5-
export function prerender(vnode, options) {
6-
return import('./prerender.js').then(m => m.default(vnode, options));
7-
}
3+
export * from './lazy.js';
4+
export * from './hydrate.js';

src/lazy.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentChildren, VNode } from 'preact';
22

3-
export default function lazy<T>(load: () => Promise<{ default: T } | T>): T;
3+
export function lazy<T>(load: () => Promise<{ default: T } | T>): T;
44

55
export function ErrorBoundary(props: { children?: ComponentChildren; onError?: (error: Error) => void }): VNode;

src/lazy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { h, options } from 'preact';
22
import { useState, useRef } from 'preact/hooks';
33

4-
export default function lazy(load) {
4+
export function lazy(load) {
55
let p, c;
66
return props => {
77
const [, update] = useState(0);

src/prerender.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface PrerenderResult {
99
links?: Set<string>
1010
}
1111

12-
export default function prerender(
12+
export function prerender(
1313
vnode: VNode,
1414
options?: PrerenderOptions
1515
): Promise<PrerenderResult>;

src/prerender.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ options.vnode = vnode => {
1414
* @param {object} [options]
1515
* @param {object} [options.props] Additional props to merge into the root JSX element
1616
*/
17-
export default async function prerender(vnode, options) {
17+
export async function prerender(vnode, options) {
1818
options = options || {};
1919

2020
const props = options.props;

test/router.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { h, render } from 'preact';
33
import { useState } from 'preact/hooks';
44
import { html } from 'htm/preact';
55
import { LocationProvider, Router, useLocation, Route, useRoute } from '../src/router.js';
6-
import lazy, { ErrorBoundary } from '../src/lazy.js';
6+
import { lazy, ErrorBoundary } from '../src/lazy.js';
77

88
Object.defineProperty(window, 'scrollTo', { value() {} });
99

0 commit comments

Comments
 (0)