From 80dd66cb2b771e46f36bf9bc414b5bc83f92057b Mon Sep 17 00:00:00 2001 From: Mateusz Drewniak Date: Sat, 29 Oct 2022 12:14:23 +0200 Subject: [PATCH 1/2] Add an explicit export default for compatibility with esbuild --- compat/client.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compat/client.mjs b/compat/client.mjs index 7f89f74710..a8b6ccc4db 100644 --- a/compat/client.mjs +++ b/compat/client.mjs @@ -15,3 +15,8 @@ export function hydrateRoot(container, children) { hydrate(children, container) return createRoot(container) } + +export default { + createRoot, + hydrateRoot +} From 50d3837cee29dee0de1cf7429d6361c1a3c7eec4 Mon Sep 17 00:00:00 2001 From: Mateusz Drewniak Date: Sat, 29 Oct 2022 16:32:30 +0200 Subject: [PATCH 2/2] Add a test for default exports from `preact/compat/client` --- compat/test/browser/exports.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compat/test/browser/exports.test.js b/compat/test/browser/exports.test.js index 577124fad2..cced23da45 100644 --- a/compat/test/browser/exports.test.js +++ b/compat/test/browser/exports.test.js @@ -1,8 +1,23 @@ import Compat from 'preact/compat'; +import CompatClient from 'preact/compat/client'; // eslint-disable-next-line no-duplicate-imports import * as Named from 'preact/compat'; +// eslint-disable-next-line no-duplicate-imports +import * as NamedClient from 'preact/compat/client'; describe('compat exports', () => { + describe('client', () => { + it('should have a default export', () => { + expect(CompatClient.createRoot).to.be.a('function'); + expect(CompatClient.hydrateRoot).to.be.a('function'); + }); + + it('should have named exports', () => { + expect(NamedClient.createRoot).to.be.a('function'); + expect(NamedClient.hydrateRoot).to.be.a('function'); + }); + }); + it('should have a default export', () => { expect(Compat.createElement).to.be.a('function'); expect(Compat.Component).to.be.a('function');