Skip to content

Commit

Permalink
Change how Preact's render/hydrate functions are re-export via th…
Browse files Browse the repository at this point in the history
…e `preact/dom` namespace to match changes in upstream
  • Loading branch information
danielrozenberg committed Jul 12, 2023
1 parent 00745f5 commit 7c410c7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
9 changes: 0 additions & 9 deletions build-system/common/update-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,6 @@ function patchShadowDom() {

writeIfUpdated(patchedName, file);
}
/**
* Adds a missing export statement to the preact module.
*/
function patchPreact() {
fs.ensureDirSync('node_modules/preact/dom');
const file = `export { render, hydrate } from 'preact';`;
writeIfUpdated('node_modules/preact/dom/index.js', file);
}

/**
* Deletes the map file for rrule, which breaks closure compiler.
Expand Down Expand Up @@ -235,7 +227,6 @@ function updatePackages() {
patchIntersectionObserver();
patchResizeObserver();
patchShadowDom();
patchPreact();
removeRruleSourcemap();
if (isCiBuild()) {
runNpmChecks();
Expand Down
12 changes: 0 additions & 12 deletions src/preact/preact-dom.d.ts

This file was deleted.

12 changes: 12 additions & 0 deletions src/preact/preact-dom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Re-export render/hydrate from 'preact' as 'preact/dom' (see ./tsconfig.json)
* in order to make it more consistent with React. This makes remapping the
* imports for React builds simple (preact/dom --> react-dom).
*
* @fileoverview
*/

export {hydrate, render} from 'preact';

// eslint-disable-next-line no-restricted-syntax
declare module 'preact/dom' {}
7 changes: 6 additions & 1 deletion src/preact/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"**/*.d.ts",
"../core/**/globals.d.ts",
"../**/base-element.d.ts"
]
],
"compilerOptions": {
"paths": {
"preact/dom": ["./preact-dom.ts"]
}
}
}

0 comments on commit 7c410c7

Please sign in to comment.