Skip to content
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

A9 #95

Merged
merged 4 commits into from
Dec 21, 2023
Merged

A9 #95

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: 7 additions & 0 deletions .changeset/eight-ears-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astrojs/preact': patch
'@astrojs/react': patch
'@astrojs/solid-js': patch
---

Improves compatability with the [Qwik adapter](https://github.com/QwikDev/astro)
5 changes: 5 additions & 0 deletions .changeset/rare-ants-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Improves errors in certain places to also report their causes.
1 change: 0 additions & 1 deletion packages/astro/src/assets/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ export async function generateImagesForPath(
...AstroErrorData.CouldNotTransformImage,
message: AstroErrorData.CouldNotTransformImage.message(originalFilePath),
},
undefined,
{ cause: e }
);

Expand Down
14 changes: 7 additions & 7 deletions packages/astro/src/core/errors/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export class AstroError extends Error {

type: ErrorTypes = 'AstroError';

constructor(props: ErrorProperties, ...params: any) {
super(...params);

constructor(props: ErrorProperties, options?: ErrorOptions) {
const { name, title, message, stack, location, hint, frame } = props;
super(message, options);

this.title = title;
this.name = name;

Expand Down Expand Up @@ -81,8 +81,8 @@ export class AstroError extends Error {
export class CompilerError extends AstroError {
type: ErrorTypes = 'CompilerError';

constructor(props: ErrorProperties, ...params: any) {
super(props, ...params);
constructor(props: ErrorProperties, options?: ErrorOptions) {
super(props, options);
}

static is(err: unknown): err is CompilerError {
Expand Down Expand Up @@ -120,8 +120,8 @@ export class AggregateError extends AstroError {

// Despite being a collection of errors, AggregateError still needs to have a main error attached to it
// This is because Vite expects every thrown errors handled during HMR to be, well, Error and have a message
constructor(props: ErrorProperties & { errors: AstroError[] }, ...params: any) {
super(props, ...params);
constructor(props: ErrorProperties & { errors: AstroError[] }, options?: ErrorOptions) {
super(props, options);

this.errors = props.errors;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/middleware/loadMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function loadMiddleware(moduleLoader: ModuleLoader) {
try {
return await moduleLoader.import(MIDDLEWARE_MODULE_ID);
} catch (error: any) {
const astroError = new AstroError(MiddlewareCantBeLoaded, undefined, { cause: error });
const astroError = new AstroError(MiddlewareCantBeLoaded, { cause: error });
throw astroError;
}
}
1 change: 1 addition & 0 deletions packages/integrations/preact/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let consoleFilterRefs = 0;

function check(this: RendererContext, Component: any, props: Record<string, any>, children: any) {
if (typeof Component !== 'function') return false;
if (Component.name === 'QwikComponent') return false;

if (Component.prototype != null && typeof Component.prototype.render === 'function') {
return BaseComponent.isPrototypeOf(Component);
Expand Down
1 change: 1 addition & 0 deletions packages/integrations/react/server-v17.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function check(Component, props, children) {
return Component['$$typeof']?.toString().slice('Symbol('.length).startsWith('react');
}
if (typeof Component !== 'function') return false;
if (Component.name === 'QwikComponent') return false;

if (Component.prototype != null && typeof Component.prototype.render === 'function') {
return React.Component.isPrototypeOf(Component) || React.PureComponent.isPrototypeOf(Component);
Expand Down
1 change: 1 addition & 0 deletions packages/integrations/react/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async function check(Component, props, children) {
return Component['$$typeof'].toString().slice('Symbol('.length).startsWith('react');
}
if (typeof Component !== 'function') return false;
if (Component.name === 'QwikComponent') return false;

// Preact forwarded-ref components can be functions, which React does not support
if (typeof Component === 'function' && Component['$$typeof'] === Symbol.for('react.forward_ref'))
Expand Down
1 change: 1 addition & 0 deletions packages/integrations/solid/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w

function check(this: RendererContext, Component: any, props: Record<string, any>, children: any) {
if (typeof Component !== 'function') return false;
if (Component.name === 'QwikComponent') return false;
const { html } = renderToStaticMarkup.call(this, Component, props, children);
return typeof html === 'string';
}
Expand Down
Loading