summaryrefslogtreecommitdiff
path: root/packages/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations')
-rw-r--r--packages/integrations/lit/client-shim.js10
-rw-r--r--packages/integrations/lit/client-shim.min.js16
-rw-r--r--packages/integrations/lit/src/index.ts12
-rw-r--r--packages/integrations/partytown/src/index.ts13
-rw-r--r--packages/integrations/partytown/src/sirv.ts3
-rw-r--r--packages/integrations/preact/client.js6
-rw-r--r--packages/integrations/preact/server.js4
-rw-r--r--packages/integrations/preact/src/index.ts7
-rw-r--r--packages/integrations/react/client-v17.js4
-rw-r--r--packages/integrations/react/client.js4
-rw-r--r--packages/integrations/react/server-v17.js6
-rw-r--r--packages/integrations/react/server.js6
-rw-r--r--packages/integrations/react/src/index.ts28
-rw-r--r--packages/integrations/react/static-html.js5
-rw-r--r--packages/integrations/sitemap/src/index.ts9
-rw-r--r--packages/integrations/solid/server.js4
-rw-r--r--packages/integrations/svelte/Wrapper.svelte.ssr.js7
-rw-r--r--packages/integrations/svelte/server.js6
-rw-r--r--packages/integrations/tailwind/src/index.ts14
-rw-r--r--packages/integrations/turbolinks/src/index.ts5
20 files changed, 136 insertions, 33 deletions
diff --git a/packages/integrations/lit/client-shim.js b/packages/integrations/lit/client-shim.js
index cab3fe4d9..e9cf1aecf 100644
--- a/packages/integrations/lit/client-shim.js
+++ b/packages/integrations/lit/client-shim.js
@@ -1,9 +1,15 @@
async function polyfill() {
- const { hydrateShadowRoots } = await import('@webcomponents/template-shadowroot/template-shadowroot.js');
+ const { hydrateShadowRoots } = await import(
+ '@webcomponents/template-shadowroot/template-shadowroot.js'
+ );
hydrateShadowRoots(document.body);
}
-const polyfillCheckEl = new DOMParser().parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', { includeShadowRoots: true }).querySelector('p');
+const polyfillCheckEl = new DOMParser()
+ .parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
+ includeShadowRoots: true,
+ })
+ .querySelector('p');
if (!polyfillCheckEl || !polyfillCheckEl.shadowRoot) {
polyfill();
diff --git a/packages/integrations/lit/client-shim.min.js b/packages/integrations/lit/client-shim.min.js
index 0c6a452d8..f9fe14fdd 100644
--- a/packages/integrations/lit/client-shim.min.js
+++ b/packages/integrations/lit/client-shim.min.js
@@ -8,7 +8,8 @@ var b = (t, n) => {
function s() {
if (d === void 0) {
let t = document.createElement('div');
- (t.innerHTML = '<div><template shadowroot="open"></template></div>'), (d = !!t.firstElementChild.shadowRoot);
+ (t.innerHTML = '<div><template shadowroot="open"></template></div>'),
+ (d = !!t.firstElementChild.shadowRoot);
}
return d;
}
@@ -18,7 +19,9 @@ var p,
c,
f,
u = i(() => {
- (p = (t) => t.parentElement === null), (c = (t) => t.tagName === 'TEMPLATE'), (f = (t) => t.nodeType === Node.ELEMENT_NODE);
+ (p = (t) => t.parentElement === null),
+ (c = (t) => t.tagName === 'TEMPLATE'),
+ (f = (t) => t.nodeType === Node.ELEMENT_NODE);
});
var h,
E = i(() => {
@@ -52,7 +55,8 @@ var h,
(e = r), o !== void 0 && o.parentElement.removeChild(o);
break;
}
- let l = (n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling;
+ let l =
+ (n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling;
if (l != null) {
(e = l), o !== void 0 && o.parentElement.removeChild(o);
break;
@@ -75,5 +79,9 @@ async function g() {
let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v));
t(document.body);
}
-var x = new DOMParser().parseFromString('<p><template shadowroot="open"></template></p>', 'text/html', { includeShadowRoots: !0 }).querySelector('p');
+var x = new DOMParser()
+ .parseFromString('<p><template shadowroot="open"></template></p>', 'text/html', {
+ includeShadowRoots: !0,
+ })
+ .querySelector('p');
(!x || !x.shadowRoot) && g();
diff --git a/packages/integrations/lit/src/index.ts b/packages/integrations/lit/src/index.ts
index bf256eb84..f945f1ca3 100644
--- a/packages/integrations/lit/src/index.ts
+++ b/packages/integrations/lit/src/index.ts
@@ -13,7 +13,12 @@ function getViteConfiguration() {
exclude: ['@astrojs/lit/server.js'],
},
ssr: {
- external: ['lit-element/lit-element.js', '@lit-labs/ssr/lib/install-global-dom-shim.js', '@lit-labs/ssr/lib/render-lit-html.js', '@lit-labs/ssr/lib/lit-element-renderer.js'],
+ external: [
+ 'lit-element/lit-element.js',
+ '@lit-labs/ssr/lib/install-global-dom-shim.js',
+ '@lit-labs/ssr/lib/render-lit-html.js',
+ '@lit-labs/ssr/lib/lit-element-renderer.js',
+ ],
},
};
}
@@ -24,7 +29,10 @@ export default function (): AstroIntegration {
hooks: {
'astro:config:setup': ({ updateConfig, addRenderer, injectScript }) => {
// Inject the necessary polyfills on every page (inlined for speed).
- injectScript('head-inline', readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' }));
+ injectScript(
+ 'head-inline',
+ readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' })
+ );
// Inject the hydration code, before a component is hydrated.
injectScript('before-hydration', `import '@astrojs/lit/hydration-support.js';`);
// Add the lit renderer so that Astro can understand lit components.
diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts
index bddbeae62..ebd133e33 100644
--- a/packages/integrations/partytown/src/index.ts
+++ b/packages/integrations/partytown/src/index.ts
@@ -23,10 +23,19 @@ export default function createPlugin(): AstroIntegration {
config = _config;
},
'astro:server:setup': ({ server }) => {
- server.middlewares.use(sirv(partytownLibDirectory, { mount: '/~partytown', dev: true, etag: true, extensions: [] }));
+ server.middlewares.use(
+ sirv(partytownLibDirectory, {
+ mount: '/~partytown',
+ dev: true,
+ etag: true,
+ extensions: [],
+ })
+ );
},
'astro:build:done': async () => {
- await copyLibFiles(fileURLToPath(new URL('~partytown', config.outDir)), { debugDir: false });
+ await copyLibFiles(fileURLToPath(new URL('~partytown', config.outDir)), {
+ debugDir: false,
+ });
},
},
};
diff --git a/packages/integrations/partytown/src/sirv.ts b/packages/integrations/partytown/src/sirv.ts
index 860a715bf..aab0c7d96 100644
--- a/packages/integrations/partytown/src/sirv.ts
+++ b/packages/integrations/partytown/src/sirv.ts
@@ -223,7 +223,8 @@ export default function (dir, opts = {}) {
}
}
- let data = lookup(pathname, extns) || (isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns));
+ let data =
+ lookup(pathname, extns) || (isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns));
if (!data) return next ? next() : isNotFound(req, res);
if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
diff --git a/packages/integrations/preact/client.js b/packages/integrations/preact/client.js
index 85c18c76c..5ece5ddb2 100644
--- a/packages/integrations/preact/client.js
+++ b/packages/integrations/preact/client.js
@@ -1,4 +1,8 @@
import { h, render } from 'preact';
import StaticHtml from './static-html.js';
-export default (element) => (Component, props, children) => render(h(Component, props, children != null ? h(StaticHtml, { value: children }) : children), element);
+export default (element) => (Component, props, children) =>
+ render(
+ h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
+ element
+ );
diff --git a/packages/integrations/preact/server.js b/packages/integrations/preact/server.js
index 25b1a1530..0729f42e9 100644
--- a/packages/integrations/preact/server.js
+++ b/packages/integrations/preact/server.js
@@ -25,7 +25,9 @@ function check(Component, props, children) {
}
function renderToStaticMarkup(Component, props, children) {
- const html = render(h(Component, props, children != null ? h(StaticHtml, { value: children }) : children));
+ const html = render(
+ h(Component, props, children != null ? h(StaticHtml, { value: children }) : children)
+ );
return { html };
}
diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts
index c96bf1190..0b0896210 100644
--- a/packages/integrations/preact/src/index.ts
+++ b/packages/integrations/preact/src/index.ts
@@ -21,7 +21,12 @@ function getRenderer() {
function getViteConfiguration() {
return {
optimizeDeps: {
- include: ['@astrojs/preact/client.js', 'preact', 'preact/jsx-runtime', 'preact-render-to-string'],
+ include: [
+ '@astrojs/preact/client.js',
+ 'preact',
+ 'preact/jsx-runtime',
+ 'preact-render-to-string',
+ ],
exclude: ['@astrojs/preact/server.js'],
},
ssr: {
diff --git a/packages/integrations/react/client-v17.js b/packages/integrations/react/client-v17.js
index a6bc7d3bc..64284a0b0 100644
--- a/packages/integrations/react/client-v17.js
+++ b/packages/integrations/react/client-v17.js
@@ -7,7 +7,9 @@ export default (element) => (Component, props, children) =>
createElement(
Component,
{ ...props, suppressHydrationWarning: true },
- children != null ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true }) : children
+ children != null
+ ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true })
+ : children
),
element
);
diff --git a/packages/integrations/react/client.js b/packages/integrations/react/client.js
index 11d63cfcb..7eba8984c 100644
--- a/packages/integrations/react/client.js
+++ b/packages/integrations/react/client.js
@@ -8,6 +8,8 @@ export default (element) => (Component, props, children) =>
createElement(
Component,
{ ...props, suppressHydrationWarning: true },
- children != null ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true }) : children
+ children != null
+ ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true })
+ : children
)
);
diff --git a/packages/integrations/react/server-v17.js b/packages/integrations/react/server-v17.js
index 1c0c41286..b48d7b6f4 100644
--- a/packages/integrations/react/server-v17.js
+++ b/packages/integrations/react/server-v17.js
@@ -5,7 +5,11 @@ import StaticHtml from './static-html.js';
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
- return err.message && (err.message.startsWith("Cannot read property '__H'") || err.message.includes("(reading '__H')"));
+ return (
+ err.message &&
+ (err.message.startsWith("Cannot read property '__H'") ||
+ err.message.includes("(reading '__H')"))
+ );
}
function check(Component, props, children) {
diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js
index e102b57fe..6ae49e7bc 100644
--- a/packages/integrations/react/server.js
+++ b/packages/integrations/react/server.js
@@ -5,7 +5,11 @@ import StaticHtml from './static-html.js';
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
- return err.message && (err.message.startsWith("Cannot read property '__H'") || err.message.includes("(reading '__H')"));
+ return (
+ err.message &&
+ (err.message.startsWith("Cannot read property '__H'") ||
+ err.message.includes("(reading '__H')"))
+ );
}
function check(Component, props, children) {
diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts
index 25899a025..a283938c3 100644
--- a/packages/integrations/react/src/index.ts
+++ b/packages/integrations/react/src/index.ts
@@ -4,8 +4,12 @@ import { version as ReactVersion } from 'react-dom';
function getRenderer() {
return {
name: '@astrojs/react',
- clientEntrypoint: ReactVersion.startsWith('18.') ? '@astrojs/react/client.js' : '@astrojs/react/client-v17.js',
- serverEntrypoint: ReactVersion.startsWith('18.') ? '@astrojs/react/server.js' : '@astrojs/react/server-v17.js',
+ clientEntrypoint: ReactVersion.startsWith('18.')
+ ? '@astrojs/react/client.js'
+ : '@astrojs/react/client-v17.js',
+ serverEntrypoint: ReactVersion.startsWith('18.')
+ ? '@astrojs/react/server.js'
+ : '@astrojs/react/server-v17.js',
jsxImportSource: 'react',
jsxTransformOptions: async () => {
const {
@@ -34,14 +38,28 @@ function getRenderer() {
function getViteConfiguration() {
return {
optimizeDeps: {
- include: [ReactVersion.startsWith('18.') ? '@astrojs/react/client.js' : '@astrojs/react/client-v17.js', 'react', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom'],
- exclude: [ReactVersion.startsWith('18.') ? '@astrojs/react/server.js' : '@astrojs/react/server-v17.js'],
+ include: [
+ ReactVersion.startsWith('18.')
+ ? '@astrojs/react/client.js'
+ : '@astrojs/react/client-v17.js',
+ 'react',
+ 'react/jsx-runtime',
+ 'react/jsx-dev-runtime',
+ 'react-dom',
+ ],
+ exclude: [
+ ReactVersion.startsWith('18.')
+ ? '@astrojs/react/server.js'
+ : '@astrojs/react/server-v17.js',
+ ],
},
resolve: {
dedupe: ['react', 'react-dom'],
},
ssr: {
- external: ReactVersion.startsWith('18.') ? ['react-dom/server', 'react-dom/client'] : ['react-dom/server.js', 'react-dom/client.js'],
+ external: ReactVersion.startsWith('18.')
+ ? ['react-dom/server', 'react-dom/client']
+ : ['react-dom/server.js', 'react-dom/client.js'],
},
};
}
diff --git a/packages/integrations/react/static-html.js b/packages/integrations/react/static-html.js
index 47130d786..ecd76ae9b 100644
--- a/packages/integrations/react/static-html.js
+++ b/packages/integrations/react/static-html.js
@@ -9,7 +9,10 @@ import { createElement as h } from 'react';
*/
const StaticHtml = ({ value }) => {
if (!value) return null;
- return h('astro-fragment', { suppressHydrationWarning: true, dangerouslySetInnerHTML: { __html: value } });
+ return h('astro-fragment', {
+ suppressHydrationWarning: true,
+ dangerouslySetInnerHTML: { __html: value },
+ });
};
/**
diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts
index ef1538ce6..70441cb8e 100644
--- a/packages/integrations/sitemap/src/index.ts
+++ b/packages/integrations/sitemap/src/index.ts
@@ -38,7 +38,10 @@ function generateSitemap(pages: string[]) {
return sitemap;
}
-export default function createPlugin({ filter, canonicalURL }: SitemapOptions = {}): AstroIntegration {
+export default function createPlugin({
+ filter,
+ canonicalURL,
+}: SitemapOptions = {}): AstroIntegration {
let config: AstroConfig;
return {
name: '@astrojs/sitemap',
@@ -49,7 +52,9 @@ export default function createPlugin({ filter, canonicalURL }: SitemapOptions =
'astro:build:done': async ({ pages, dir }) => {
const finalSiteUrl = canonicalURL || config.site;
if (!finalSiteUrl) {
- console.warn('The Sitemap integration requires either the `site` astro.config option or `canonicalURL` integration option. Skipping.');
+ console.warn(
+ 'The Sitemap integration requires either the `site` astro.config option or `canonicalURL` integration option. Skipping.'
+ );
return;
}
let pageUrls = pages.map((p) => new URL(p.pathname, finalSiteUrl).href);
diff --git a/packages/integrations/solid/server.js b/packages/integrations/solid/server.js
index d32d60a64..ccee482ea 100644
--- a/packages/integrations/solid/server.js
+++ b/packages/integrations/solid/server.js
@@ -19,7 +19,9 @@ function renderToStaticMarkup(Component, props, children) {
children: children != null ? ssr(`<astro-fragment>${children}</astro-fragment>`) : children,
})
);
- return { html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>` };
+ return {
+ html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>`,
+ };
}
export default {
diff --git a/packages/integrations/svelte/Wrapper.svelte.ssr.js b/packages/integrations/svelte/Wrapper.svelte.ssr.js
index 9bca437b5..e6a4781a7 100644
--- a/packages/integrations/svelte/Wrapper.svelte.ssr.js
+++ b/packages/integrations/svelte/Wrapper.svelte.ssr.js
@@ -8,7 +8,12 @@ const App = create_ssr_component(($$result, $$props, $$bindings, slots) => {
children.default = () => `<astro-fragment>${__astro_children}</astro-fragment>`;
}
- return `${validate_component(Component || missing_component, 'svelte:component').$$render($$result, Object.assign(props), {}, children)}`;
+ return `${validate_component(Component || missing_component, 'svelte:component').$$render(
+ $$result,
+ Object.assign(props),
+ {},
+ children
+ )}`;
});
export default App;
diff --git a/packages/integrations/svelte/server.js b/packages/integrations/svelte/server.js
index c51b2f4b4..3c989cd5a 100644
--- a/packages/integrations/svelte/server.js
+++ b/packages/integrations/svelte/server.js
@@ -5,7 +5,11 @@ function check(Component) {
}
async function renderToStaticMarkup(Component, props, children) {
- const { html } = SvelteWrapper.render({ __astro_component: Component, __astro_children: children, ...props });
+ const { html } = SvelteWrapper.render({
+ __astro_component: Component,
+ __astro_children: children,
+ ...props,
+ });
return { html };
}
diff --git a/packages/integrations/tailwind/src/index.ts b/packages/integrations/tailwind/src/index.ts
index 2f469b507..3efd8fde8 100644
--- a/packages/integrations/tailwind/src/index.ts
+++ b/packages/integrations/tailwind/src/index.ts
@@ -67,14 +67,22 @@ export default function tailwindIntegration(options: TailwindOptions): AstroInte
const userConfig = await getUserConfig(config.root, customConfigPath);
if (customConfigPath && !userConfig?.value) {
- throw new Error(`Could not find a Tailwind config at ${JSON.stringify(customConfigPath)}. Does the file exist?`);
+ throw new Error(
+ `Could not find a Tailwind config at ${JSON.stringify(
+ customConfigPath
+ )}. Does the file exist?`
+ );
}
- const tailwindConfig: TailwindConfig = (userConfig?.value as TailwindConfig) ?? getDefaultTailwindConfig(config.srcDir);
+ const tailwindConfig: TailwindConfig =
+ (userConfig?.value as TailwindConfig) ?? getDefaultTailwindConfig(config.srcDir);
if (applyAstroConfigPreset && userConfig?.value) {
// apply Astro config as a preset to user config
// this avoids merging or applying nested spread operators ourselves
- tailwindConfig.presets = [getDefaultTailwindConfig(config.srcDir), ...(tailwindConfig.presets || [])];
+ tailwindConfig.presets = [
+ getDefaultTailwindConfig(config.srcDir),
+ ...(tailwindConfig.presets || []),
+ ];
}
config.style.postcss.plugins.push(tailwindPlugin(tailwindConfig));
diff --git a/packages/integrations/turbolinks/src/index.ts b/packages/integrations/turbolinks/src/index.ts
index 3299736ba..fbf893f68 100644
--- a/packages/integrations/turbolinks/src/index.ts
+++ b/packages/integrations/turbolinks/src/index.ts
@@ -8,7 +8,10 @@ export default function createPlugin(): AstroIntegration {
// This gets injected into the user's page, so we need to re-export Turbolinks
// from our own package so that package managers like pnpm don't get mad and
// can follow the import correctly.
- injectScript('page', `import {Turbolinks} from "@astrojs/turbolinks/client.js"; Turbolinks.start();`);
+ injectScript(
+ 'page',
+ `import {Turbolinks} from "@astrojs/turbolinks/client.js"; Turbolinks.start();`
+ );
},
},
};