summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/e2e/vue-component.test.js2
-rw-r--r--packages/astro/src/core/render/dev/css.ts10
-rw-r--r--packages/astro/src/core/render/dev/index.ts8
-rw-r--r--packages/astro/src/runtime/client/hmr.ts4
-rw-r--r--packages/astro/test/0-css.test.js16
-rw-r--r--packages/astro/test/astro-markdown-css.test.js2
-rw-r--r--packages/astro/test/astro-partial-html.test.js2
-rw-r--r--packages/astro/test/component-library.test.js4
8 files changed, 24 insertions, 24 deletions
diff --git a/packages/astro/e2e/vue-component.test.js b/packages/astro/e2e/vue-component.test.js
index ea2a76b2d..5a75e9512 100644
--- a/packages/astro/e2e/vue-component.test.js
+++ b/packages/astro/e2e/vue-component.test.js
@@ -142,6 +142,6 @@ test.describe('Vue components', () => {
const label = counter.locator('h1');
await expect(label, 'slotted text updated').toHaveText('Hello, updated client:visible!');
- await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid')
+ await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid');
});
});
diff --git a/packages/astro/src/core/render/dev/css.ts b/packages/astro/src/core/render/dev/css.ts
index 7751eb1f7..657289d36 100644
--- a/packages/astro/src/core/render/dev/css.ts
+++ b/packages/astro/src/core/render/dev/css.ts
@@ -1,9 +1,9 @@
import type * as vite from 'vite';
import path from 'path';
+import { RuntimeMode } from '../../../@types/astro.js';
import { unwrapId, viteID } from '../../util.js';
import { STYLE_EXTENSIONS } from '../util.js';
-import { RuntimeMode } from '../../../@types/astro.js';
/**
* List of file extensions signalling we can (and should) SSR ahead-of-time
@@ -16,7 +16,7 @@ export async function getStylesForURL(
filePath: URL,
viteServer: vite.ViteDevServer,
mode: RuntimeMode
-): Promise<{urls: Set<string>, stylesMap: Map<string, string>}> {
+): Promise<{ urls: Set<string>; stylesMap: Map<string, string> }> {
const importedCssUrls = new Set<string>();
const importedStylesMap = new Map<string, string>();
@@ -68,8 +68,8 @@ export async function getStylesForURL(
const ext = path.extname(importedModule.url).toLowerCase();
if (STYLE_EXTENSIONS.has(ext)) {
if (
- mode === 'development' // only inline in development
- && typeof importedModule.ssrModule?.default === 'string' // ignore JS module styles
+ mode === 'development' && // only inline in development
+ typeof importedModule.ssrModule?.default === 'string' // ignore JS module styles
) {
importedStylesMap.set(importedModule.url, importedModule.ssrModule.default);
} else {
@@ -85,6 +85,6 @@ export async function getStylesForURL(
await crawlCSS(viteID(filePath), true);
return {
urls: importedCssUrls,
- stylesMap: importedStylesMap
+ stylesMap: importedStylesMap,
};
}
diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts
index ba6e3eceb..4921fb9d6 100644
--- a/packages/astro/src/core/render/dev/index.ts
+++ b/packages/astro/src/core/render/dev/index.ts
@@ -48,7 +48,7 @@ export type RenderResponse =
| { type: 'html'; html: string; response: ResponseInit }
| { type: 'response'; response: Response };
-const svelteStylesRE = /svelte\?svelte&type=style/;
+const svelteStylesRE = /svelte\?svelte&type=style/;
async function loadRenderer(
viteServer: ViteDevServer,
@@ -155,14 +155,14 @@ export async function render(
});
let styles = new Set<SSRElement>();
- [...(stylesMap)].forEach(([url, content]) => {
+ [...stylesMap].forEach(([url, content]) => {
// The URL is only used by HMR for Svelte components
// See src/runtime/client/hmr.ts for more details
styles.add({
props: {
- 'data-astro-injected': svelteStylesRE.test(url) ? url : true
+ 'data-astro-injected': svelteStylesRE.test(url) ? url : true,
},
- children: content
+ children: content,
});
});
diff --git a/packages/astro/src/runtime/client/hmr.ts b/packages/astro/src/runtime/client/hmr.ts
index f74597225..e9cf5bd82 100644
--- a/packages/astro/src/runtime/client/hmr.ts
+++ b/packages/astro/src/runtime/client/hmr.ts
@@ -46,7 +46,9 @@ if (import.meta.hot) {
// This will only be called after the svelte component has hydrated in the browser.
// At this point Vite is tracking component style updates, we need to remove
// styles injected by Astro for the component in favor of Vite's internal HMR.
- const injectedStyle = document.querySelector(`style[data-astro-injected="${file.acceptedPath}"]`);
+ const injectedStyle = document.querySelector(
+ `style[data-astro-injected="${file.acceptedPath}"]`
+ );
if (injectedStyle) {
injectedStyle.parentElement?.removeChild(injectedStyle);
}
diff --git a/packages/astro/test/0-css.test.js b/packages/astro/test/0-css.test.js
index 573bec842..acfa01b38 100644
--- a/packages/astro/test/0-css.test.js
+++ b/packages/astro/test/0-css.test.js
@@ -298,8 +298,8 @@ describe('CSS', function () {
});
it('resolves ESM style imports', async () => {
- const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,"");
-
+ const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, '');
+
expect(allInjectedStyles, 'styles/imported-url.css').to.contain('.imported{');
expect(allInjectedStyles, 'styles/imported-url.sass').to.contain('.imported-sass{');
expect(allInjectedStyles, 'styles/imported-url.scss').to.contain('.imported-scss{');
@@ -307,7 +307,7 @@ describe('CSS', function () {
it('resolves Astro styles', async () => {
const allInjectedStyles = $('style[data-astro-injected]').text();
-
+
expect(allInjectedStyles).to.contain('.linked-css.astro-');
expect(allInjectedStyles).to.contain('.linked-sass.astro-');
expect(allInjectedStyles).to.contain('.linked-scss.astro-');
@@ -318,14 +318,14 @@ describe('CSS', function () {
const styles = [
'ReactModules.module.css',
'ReactModules.module.scss',
- 'ReactModules.module.sass'
+ 'ReactModules.module.sass',
];
for (const style of styles) {
const href = $(`link[href$="${style}"]`).attr('href');
expect((await fixture.fetch(href)).status, style).to.equal(200);
}
- const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,"");
+ const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, '');
expect(allInjectedStyles).to.contain('.react-title{');
expect(allInjectedStyles).to.contain('.react-sass-title{');
@@ -341,15 +341,13 @@ describe('CSS', function () {
});
it('resolves CSS from Vue', async () => {
- const styles = [
- 'VueModules.vue?vue&type=style&index=0&lang.module.scss'
- ];
+ const styles = ['VueModules.vue?vue&type=style&index=0&lang.module.scss'];
for (const style of styles) {
const href = $(`link[href$="${style}"]`).attr('href');
expect((await fixture.fetch(href)).status, style).to.equal(200);
}
- const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,"");
+ const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, '');
expect(allInjectedStyles).to.contain('.vue-css{');
expect(allInjectedStyles).to.contain('.vue-sass{');
diff --git a/packages/astro/test/astro-markdown-css.test.js b/packages/astro/test/astro-markdown-css.test.js
index 2798f544c..8852622f4 100644
--- a/packages/astro/test/astro-markdown-css.test.js
+++ b/packages/astro/test/astro-markdown-css.test.js
@@ -52,7 +52,7 @@ describe('Imported markdown CSS', function () {
expect(importedAstroComponent?.name).to.equal('h2');
const cssClass = $(importedAstroComponent).attr('class')?.split(/\s+/)?.[0];
- const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,"");
+ const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, '');
expect(allInjectedStyles).to.match(new RegExp(`h2.${cssClass}{color:#00f}`));
});
});
diff --git a/packages/astro/test/astro-partial-html.test.js b/packages/astro/test/astro-partial-html.test.js
index 7756d58aa..d7828a596 100644
--- a/packages/astro/test/astro-partial-html.test.js
+++ b/packages/astro/test/astro-partial-html.test.js
@@ -37,7 +37,7 @@ describe('Partial HTML', async () => {
expect(html).to.match(/^<!DOCTYPE html/);
// test 2: link tag present
- const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,"");
+ const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, '');
expect(allInjectedStyles).to.match(/h1{color:red;}/);
});
});
diff --git a/packages/astro/test/component-library.test.js b/packages/astro/test/component-library.test.js
index 146202575..63a8dd46f 100644
--- a/packages/astro/test/component-library.test.js
+++ b/packages/astro/test/component-library.test.js
@@ -108,11 +108,11 @@ describe('Component Libraries', () => {
const $ = cheerioLoad(html);
// Most styles are inlined in a <style> block in the dev server
- const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,"");
+ const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, '');
if (expected.test(allInjectedStyles)) {
return true;
}
-
+
// Also check for <link> stylesheets
const links = $('link[rel=stylesheet]');
for (const link of links) {