Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module.exports = function (api) {
import mangle from './mangle.json' with { type: 'json' };

export default function (api) {
api.cache(true);

const noModules = String(process.env.BABEL_NO_MODULES) === 'true';

const rename = {};
const mangle = require('./mangle.json');
for (let prop in mangle.props.props) {
let name = prop;
if (name[0] === '$') {
Expand Down Expand Up @@ -47,4 +48,4 @@ module.exports = function (api) {
}
]
};
};
}
2 changes: 1 addition & 1 deletion compat/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as preact from '../src/index';
import * as preact from '../src/index.js';

export function createRoot(container: preact.ContainerNode): {
render(children: preact.ComponentChild): void;
Expand Down
13 changes: 8 additions & 5 deletions compat/client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { render, hydrate, unmountComponentAtNode } = require('preact/compat');
import { render, hydrate, unmountComponentAtNode } from 'preact/compat';

function createRoot(container) {
export function createRoot(container) {
return {
// eslint-disable-next-line
render: function (children) {
Expand All @@ -13,9 +13,12 @@ function createRoot(container) {
};
}

exports.createRoot = createRoot;

exports.hydrateRoot = function (container, children) {
export function hydrateRoot(container, children) {
hydrate(children, container);
return createRoot(container);
}

export default {
createRoot,
hydrateRoot
};
24 changes: 0 additions & 24 deletions compat/client.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions compat/jsx-dev-runtime.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('preact/compat');
import 'preact/compat';

module.exports = require('preact/jsx-runtime');
export * from 'preact/jsx-runtime';
3 changes: 0 additions & 3 deletions compat/jsx-dev-runtime.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions compat/jsx-runtime.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('preact/compat');
import 'preact/compat';

module.exports = require('preact/jsx-runtime');
export * from 'preact/jsx-runtime';
3 changes: 0 additions & 3 deletions compat/jsx-runtime.mjs

This file was deleted.

4 changes: 1 addition & 3 deletions compat/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"name": "preact-compat",
"amdName": "preactCompat",
"private": true,
"description": "A React compatibility layer for Preact",
"type": "module",
"main": "dist/compat.js",
"module": "dist/compat.mjs",
"umd:main": "dist/compat.umd.js",
"source": "src/index.js",
"types": "src/index.d.ts",
"license": "MIT",
Expand Down
30 changes: 19 additions & 11 deletions compat/scheduler.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
// see scheduler.mjs
/* eslint-disable */

function unstable_runWithPriority(priority, callback) {
// This file includes experimental React APIs exported from the "scheduler"
// npm package. Despite being explicitely marked as unstable some libraries
// already make use of them. This file is not a full replacement for the
// scheduler package, but includes the necessary shims to make those libraries
// work with Preact.

export var unstable_ImmediatePriority = 1;
export var unstable_UserBlockingPriority = 2;
export var unstable_NormalPriority = 3;
export var unstable_LowPriority = 4;
export var unstable_IdlePriority = 5;

/**
* @param {number} priority
* @param {() => void} callback
*/
export function unstable_runWithPriority(priority, callback) {
return callback();
}

module.exports = {
unstable_ImmediatePriority: 1,
unstable_UserBlockingPriority: 2,
unstable_NormalPriority: 3,
unstable_LowPriority: 4,
unstable_IdlePriority: 5,
unstable_runWithPriority,
unstable_now: performance.now.bind(performance)
};
export var unstable_now = performance.now.bind(performance);
23 changes: 0 additions & 23 deletions compat/scheduler.mjs

This file was deleted.

13 changes: 0 additions & 13 deletions compat/server.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
// @ts-nocheck TS loses its mind over the mixed module systems here.
// It's not ideal, but works at runtime and we're not shipping mixed type definitions.

import { renderToString } from 'preact-render-to-string';
import { renderToPipeableStream } from 'preact-render-to-string/stream-node';
import { renderToReadableStream } from 'preact-render-to-string/stream';

export {
renderToString,
renderToString as renderToStaticMarkup
} from 'preact-render-to-string';

export { renderToPipeableStream } from 'preact-render-to-string/stream-node';
export { renderToReadableStream } from 'preact-render-to-string/stream';
export = {
renderToString: typeof renderToString,
renderToStaticMarkup: typeof renderToString,
renderToPipeableStream: typeof renderToPipeableStream,
renderToReadableStream: typeof renderToReadableStream
};
45 changes: 13 additions & 32 deletions compat/server.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
/* eslint-disable */
var renderToString;
try {
const mod = require('preact-render-to-string');
renderToString = mod.default || mod.renderToString || mod;
} catch (e) {
throw Error(
'renderToString() error: missing "preact-render-to-string" dependency.'
);
}
import { renderToString } from 'preact-render-to-string';
import { renderToPipeableStream } from 'preact-render-to-string/stream-node';
import { renderToReadableStream } from 'preact-render-to-string/stream';

var renderToReadableStream;
try {
const mod = require('preact-render-to-string/stream');
renderToReadableStream = mod.default || mod.renderToReadableStream || mod;
} catch (e) {
throw Error(
'renderToReadableStream() error: update "preact-render-to-string" dependency to at least 6.5.0.'
);
}
var renderToPipeableStream;
try {
const mod = require('preact-render-to-string/stream-node');
renderToPipeableStream = mod.default || mod.renderToPipeableStream || mod;
} catch (e) {
throw Error(
'renderToPipeableStream() error: update "preact-render-to-string" dependency to at least 6.5.0.'
);
}
export {
renderToString,
renderToString as renderToStaticMarkup
} from 'preact-render-to-string';

module.exports = {
renderToString: renderToString,
export { renderToPipeableStream } from 'preact-render-to-string/stream-node';
export { renderToReadableStream } from 'preact-render-to-string/stream';
export default {
renderToString,
renderToStaticMarkup: renderToString,
renderToPipeableStream: renderToPipeableStream,
renderToReadableStream: renderToReadableStream
renderToPipeableStream,
renderToReadableStream
};
17 changes: 0 additions & 17 deletions compat/server.mjs

This file was deleted.

Empty file added compat/src/index.cjs
Empty file.
2 changes: 1 addition & 1 deletion compat/src/index.d.ts → compat/src/index.d.cts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _preact from '../../src/index';
import * as _preact from '../../src';
import { JSXInternal } from '../../src/jsx';
import * as _hooks from '../../hooks';
import * as _Suspense from './suspense';
Expand Down
8 changes: 4 additions & 4 deletions compat/src/internal.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
import type {
Component as PreactComponent,
VNode as PreactVNode,
FunctionComponent as PreactFunctionComponent,
PreactElement
} from '../../src/internal';
import { SuspenseProps } from './suspense';
} from '../../src/internal.d.ts';
import type { SuspenseProps } from './suspense.d.ts';

export { ComponentChildren } from '../..';
export type { ComponentChildren } from 'preact';

export { PreactElement };

Expand Down
2 changes: 1 addition & 1 deletion compat/src/suspense.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ComponentChild, ComponentChildren } from '../../src/index';
import { Component, ComponentChild, ComponentChildren } from '../../src/index.js';

//
// Suspense/lazy
Expand Down
2 changes: 1 addition & 1 deletion compat/test-utils.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('preact/test-utils');
export * from 'preact/test-utils';
1 change: 0 additions & 1 deletion compat/test-utils.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion compat/test/ts/forward-ref.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from '../../src';
import React from '../../src/index.cjs';

const MyInput: React.ForwardRefRenderFunction<
{ focus(): void },
Expand Down
2 changes: 1 addition & 1 deletion compat/test/ts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from '../../src';
import React from '../../src/index.cjs';

React.render(<div />, document.createElement('div'));
React.render(<div />, document.createDocumentFragment());
Expand Down
2 changes: 1 addition & 1 deletion compat/test/ts/lazy.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from '../../src';
import * as React from '../../src/index.cjs';

export interface LazyProps {
isProp: boolean;
Expand Down
2 changes: 1 addition & 1 deletion compat/test/ts/memo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from '../../src';
import * as React from '../../src/index.cjs';
import { expectType } from './utils';

interface MemoProps {
Expand Down
2 changes: 1 addition & 1 deletion compat/test/ts/react-default.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from '../../src';
import React from '../../src/index.cjs';
class ReactIsh extends React.Component {
render() {
return <div>Text</div>;
Expand Down
2 changes: 1 addition & 1 deletion compat/test/ts/react-star.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import React from '../../src';
import * as React from '../../src';
import * as React from '../../src/index.cjs';
class ReactIsh extends React.Component {
render() {
return <div>Text</div>;
Expand Down
2 changes: 1 addition & 1 deletion compat/test/ts/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
unstable_UserBlockingPriority,
unstable_ImmediatePriority,
unstable_now
} from '../../src';
} from '../../src/index.cjs';

const noop = () => null;
unstable_runWithPriority(unstable_IdlePriority, noop);
Expand Down
2 changes: 1 addition & 1 deletion compat/test/ts/suspense.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from '../../src';
import * as React from '../../src/index.cjs';

interface LazyProps {
isProp: boolean;
Expand Down
12 changes: 7 additions & 5 deletions config/compat-entries.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const path = require('path');
const fs = require('fs');
const kl = require('kolorist');
import path from 'node:path';
import fs from 'node:fs';
import * as kl from 'kolorist';

const pkgFiles = new Set(require('../package.json').files);
const compatDir = path.join(__dirname, '..', 'compat');
import pkg from '../package.json' with { type: 'json' };

const pkgFiles = new Set(pkg.files);
const compatDir = path.resolve('compat');
const files = fs.readdirSync(compatDir);

let missing = 0;
Expand Down
4 changes: 1 addition & 3 deletions debug/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"name": "preact-debug",
"amdName": "preactDebug",
"private": true,
"description": "Preact extensions for development",
"type": "module",
"main": "dist/debug.js",
"module": "dist/debug.mjs",
"umd:main": "dist/debug.umd.js",
"source": "src/index.js",
"types": "src/index.d.ts",
"license": "MIT",
Expand Down
4 changes: 1 addition & 3 deletions devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"name": "preact-devtools",
"amdName": "preactDevtools",
"private": true,
"description": "Preact bridge for Preact devtools",
"type": "module",
"main": "dist/devtools.js",
"module": "dist/devtools.mjs",
"umd:main": "dist/devtools.umd.js",
"source": "src/index.js",
"types": "src/index.d.ts",
"license": "MIT",
Expand Down
4 changes: 1 addition & 3 deletions hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"name": "preact-hooks",
"amdName": "preactHooks",
"private": true,
"description": "Hook addon for Preact",
"type": "module",
"main": "dist/hooks.js",
"module": "dist/hooks.mjs",
"umd:main": "dist/hooks.umd.js",
"source": "src/index.js",
"types": "src/index.d.ts",
"license": "MIT",
Expand Down
Loading
Loading