Fix import path in test
This commit is contained in:
parent
88cb44250d
commit
5ca34f3c09
4 changed files with 34 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
@ -11,5 +12,13 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Astro</h1>
|
<h1>Astro</h1>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import '../does/not/exist';
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import '../does/not/exist2';
|
||||||
|
</style>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import type {
|
||||||
import { renderSlot } from '../../runtime/server/index.js';
|
import { renderSlot } from '../../runtime/server/index.js';
|
||||||
import { renderJSX } from '../../runtime/server/jsx.js';
|
import { renderJSX } from '../../runtime/server/jsx.js';
|
||||||
import { AstroCookies } from '../cookies/index.js';
|
import { AstroCookies } from '../cookies/index.js';
|
||||||
|
import { AstroError, AstroErrorCodes } from '../errors/index.js';
|
||||||
import { LogOptions, warn } from '../logger/core.js';
|
import { LogOptions, warn } from '../logger/core.js';
|
||||||
import { isScriptRequest } from './script.js';
|
import { isScriptRequest } from './script.js';
|
||||||
import { isCSSRequest } from './util.js';
|
import { isCSSRequest } from './util.js';
|
||||||
|
@ -22,7 +23,11 @@ const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
||||||
function onlyAvailableInSSR(name: string) {
|
function onlyAvailableInSSR(name: string) {
|
||||||
return function _onlyAvailableInSSR() {
|
return function _onlyAvailableInSSR() {
|
||||||
// TODO add more guidance when we have docs and adapters.
|
// TODO add more guidance when we have docs and adapters.
|
||||||
throw new Error(`Oops, you are trying to use ${name}, which is only available with SSR.`);
|
throw new AstroError({
|
||||||
|
errorCode: AstroErrorCodes.UnavailableInSSR,
|
||||||
|
message: `Oops, you are trying to use ${name}, which is only available with SSR.`,
|
||||||
|
hint: 'See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for information on how to enable SSR',
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,9 +302,11 @@ function isRedirect(statusCode: number) {
|
||||||
|
|
||||||
function throwIfRedirectNotAllowed(response: Response, config: AstroConfig) {
|
function throwIfRedirectNotAllowed(response: Response, config: AstroConfig) {
|
||||||
if (config.output !== 'server' && isRedirect(response.status)) {
|
if (config.output !== 'server' && isRedirect(response.status)) {
|
||||||
throw new Error(
|
throw new AstroError({
|
||||||
`Redirects are only available when using output: 'server'. Update your Astro config if you need SSR features.`
|
errorCode: AstroErrorCodes.StaticRedirectNotAllowed,
|
||||||
);
|
message:
|
||||||
|
"Redirects are only available when using output: 'server'. Update your Astro config if you need SSR features.",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,13 +443,22 @@ export default function createPlugin({ settings, logging }: AstroPluginOptions):
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// HACK: hide `.tip` in Vite's ErrorOverlay and replace [vite] messages with [astro]
|
|
||||||
transform(code, id, opts = {}) {
|
transform(code, id, opts = {}) {
|
||||||
if (opts.ssr) return;
|
if (opts.ssr) return;
|
||||||
if (!id.includes('vite/dist/client/client.mjs')) return;
|
if (!id.includes('vite/dist/client/client.mjs')) return;
|
||||||
return code
|
return (
|
||||||
.replace(/\.tip \{[^}]*\}/gm, '.tip {\n display: none;\n}')
|
code
|
||||||
.replace(/\[vite\]/g, '[astro]');
|
// Transform links in the message to clickable links
|
||||||
|
.replace(
|
||||||
|
"this.text('.message-body', message.trim());",
|
||||||
|
`const urlPattern = /(\\b(https?|ftp):\\/\\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|])/gim;
|
||||||
|
this.root.querySelector(".message-body").innerHTML = message.trim().replace(urlPattern, '<a href="$1" target="_blank">$1</a>');`
|
||||||
|
)
|
||||||
|
// Remove Vite's ErrorOverlay tip as it refers to some Viteism
|
||||||
|
.replace(/\.tip \{[^}]*\}/gm, '.tip {\n display: none;\n}')
|
||||||
|
// Replace all mentions of [vite] with [astro]
|
||||||
|
.replace(/\[vite\]/g, '[astro]')
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { cachedCompilation } from '../../../dist/core/compile/index.js';
|
import { cachedCompilation } from '../../../dist/core/compile/index.js';
|
||||||
import { AggregateError } from '../../../dist/core/util.js';
|
import { AggregateError } from '../../../dist/core/errors/index.js';
|
||||||
|
|
||||||
describe('astro/src/core/compile', () => {
|
describe('astro/src/core/compile', () => {
|
||||||
describe('Invalid CSS', () => {
|
describe('Invalid CSS', () => {
|
||||||
|
|
Loading…
Reference in a new issue