-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export client-side APIs from dom-expressions server.js, make them throw an error #345
Changes from 3 commits
ab2d670
523c89b
bb6fb1c
fb88f49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -466,7 +466,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) { | |
if (marker === undefined) return (current = [...parent.childNodes]); | ||
let node = array[0]; | ||
if (node.parentNode !== parent) return current; | ||
const nodes = [node] | ||
const nodes = [node]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prettier did it |
||
while ((node = node.nextSibling) !== marker) nodes.push(node); | ||
return (current = nodes); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
import { Aliases, BooleanAttributes, ChildProperties } from "./constants"; | ||
import { Aliases, BooleanAttributes, ChildProperties, Properties } from "./constants"; | ||
import { sharedConfig, root } from "rxcore"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import was missing, see further below in the file where |
||
import { createSerializer, getLocalHeaderScript } from "./serializer"; | ||
export { createComponent } from "rxcore"; | ||
|
||
export { getOwner, createComponent, effect, memo, untrack } from "rxcore"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this list accurate? I based this off of Goal is to bring server.js exports to closer parity with client.js exports. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, no, not accurate. The code is difficult to follow. I see that the build output has code injected, that I need to avoid clashing with: const isServer = true;
const isDev = false;
function render() {}
function hydrate() {}
function insert() {}
function spread() {}
function addEventListener() {}
function delegateEvents() {}
function Dynamic(props) {
const [p, others] = splitProps(props, ["component"]);
const comp = p.component,
t = typeof comp;
if (comp) {
if (t === "function") return comp(others);else if (t === "string") {
return ssrElement(comp, others, undefined, true);
}
}
}
function Portal(props) {
return "";
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Scratch that. I was confused because of dom-expressions and rxcore indirection. Hard to follow, IDE intellisense has no idea what is happening (therefore me too lol). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is confusing because it looks like the exports from I know what to do now... |
||
export { | ||
Properties, | ||
ChildProperties, | ||
getPropAlias, | ||
Aliases, | ||
DOMElements, | ||
SVGElements, | ||
SVGNamespace, | ||
DelegatedEvents | ||
} from "./constants.js"; | ||
|
||
// Based on https://github.com/WebReflection/domtagger/blob/master/esm/sanitizer.js | ||
const VOID_ELEMENTS = | ||
|
@@ -674,3 +686,33 @@ export function ssrSpread(props, isSVG, skipChildren) { | |
} | ||
return result; | ||
} | ||
|
||
// client-only APIs | ||
|
||
export { | ||
notSup as classList, | ||
notSup as style, | ||
notSup as insert, | ||
notSup as spread, | ||
notSup as delegateEvents, | ||
notSup as dynamicProperty, | ||
notSup as setAttribute, | ||
notSup as setAttributeNS, | ||
notSup as addEventListener, | ||
notSup as render, | ||
notSup as template, | ||
notSup as setProperty, | ||
notSup as className, | ||
notSup as assign, | ||
notSup as hydrate, | ||
notSup as getNextElement, | ||
notSup as getNextMatch, | ||
notSup as getNextMarker, | ||
notSup as runHydrationEvents | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And are these accurate? Wondering if I missed anything. Maybe this is good enough to start with at least. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all new functions never exported before for server, so it is non-breaking to make them errors I believe. However the question is, do you want any of them to be no-ops instead of error-throwing? I think errors are better for DX to inform people what not to do. Also, any of these functions can be overriden to be no-ops over in solid-js, for example like some already are here: https://github.com/solidjs/solid/pull/2269/files#r1740197787 |
||
function notSup() { | ||
throw new Error( | ||
"Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>." | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier did it