Vue, React and no framework are in line with expectations, but preact(v10.1.0) is not.
https://github.com/Tencent/omi/tree/master/components/o-checkbox/demos/preact-demo
import './style';
import { Component } from 'preact';
import '@omiu/checkbox';
export default class App extends Component {
onChange = (evt) => {
console.log(evt.detail)
}
render() {
return (
<div>
<o-checkbox label="Label"></o-checkbox>
<br />
<o-checkbox checked={true} label="checked"></o-checkbox>
<br />
<o-checkbox onChange={this.onChange} indeterminate label="indeterminate"></o-checkbox>
<br />
<o-checkbox disabled label="disabled"></o-checkbox>
<br />
<o-checkbox disabled checked label="disabled checked"></o-checkbox>
</div>
);
}
}
Hey @dntzhang
I've made an attempt at fixing this since the problem isn't entirely clear to met yet, when this build finishes would you mind trying it out on your example?
Thanks in advance
# NPM
npm install https://github.pika.dev/preactjs/preact/pr/2465
# Yarn
yarn add https://github.pika.dev/preactjs/preact/pr/2465
Now it's ok. https://tencent.github.io/omi/components/o-checkbox/demos/preact-demo/dist/index.html
But when i build the demo, i met a new problem, so I removed the pre rendered code of preact-cli.
> [email protected] build /Users/dnt/project/omi/components/o-checkbox/demos/preact-demo
> preact build
Build [=================== ] 93% (5.6s) after chunk asset optimization
ssr-bundle.c3928.css ⏤ 167 B (+167 B)
ssr-bundle.js ⏤ 11.8 kB (+11.8 kB)
ℹ INFO ⚛️ No custom sw.js detected: compiling default Service Worker.
Build [================== ] 92% (9.0s) additional asset processingRe-using existing @babel/preset-modules configuration.
Build [=================== ] 93% (12.1s) after chunk asset optimization
ssr-bundle.c3928.css ⏤ 0 B (-167 B)
ssr-bundle.js ⏤ 0 B (-11.8 kB)
sw-esm.js ⏤ 741 B (+741 B)
sw.js ⏤ 738 B (+738 B)
bundle.c3928.css ⏤ 108 B (+108 B)
bundle.516a0.esm.js ⏤ 14.8 kB (+14.8 kB)
polyfills.d9a55.esm.js ⏤ 2 kB (+2 kB)
bundle.4394d.js ⏤ 14.8 kB (+14.8 kB)
polyfills.8fa65.js ⏤ 2.01 kB (+2.01 kB)
✖ ERROR TypeError: Cannot read property 'replace' of null
at handlePrerenderError (/Users/dnt/project/omi/components/o-checkbox/demos/preact-demo/node_modules/[email protected]@preact-cli/lib/lib/webpack/prerender.js:66:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `preact build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Let's leave this open for now, I think it's worth opening that prerender issue in the preact-cli repo.
Most helpful comment
Let's leave this open for now, I think it's worth opening that prerender issue in the preact-cli repo.