diff --git a/.changeset/chilled-pandas-confess.md b/.changeset/chilled-pandas-confess.md new file mode 100644 index 000000000000..2f77aac40840 --- /dev/null +++ b/.changeset/chilled-pandas-confess.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Ensure the before-hydration scripts are built diff --git a/.changeset/khaki-tables-design.md b/.changeset/khaki-tables-design.md new file mode 100644 index 000000000000..210b97e845bd --- /dev/null +++ b/.changeset/khaki-tables-design.md @@ -0,0 +1,5 @@ +--- +'@astrojs/image': patch +--- + +Removes Node's `fileURLToPath` dependency in the production SSR endpoint diff --git a/.changeset/large-seas-drum.md b/.changeset/large-seas-drum.md new file mode 100644 index 000000000000..81cdc898d65a --- /dev/null +++ b/.changeset/large-seas-drum.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Adds warnings for legacy markdown behavior diff --git a/.changeset/rude-stingrays-fry.md b/.changeset/rude-stingrays-fry.md new file mode 100644 index 000000000000..53eb4047755d --- /dev/null +++ b/.changeset/rude-stingrays-fry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Added missing "loading" attribute to IFrameHTMLAttributes diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts index 59ef899f2b8a..226391a82e12 100644 --- a/packages/astro/astro-jsx.d.ts +++ b/packages/astro/astro-jsx.d.ts @@ -666,6 +666,7 @@ declare namespace astroHTML.JSX { /** @deprecated */ frameborder?: number | string | undefined | null; height?: number | string | undefined | null; + loading?: 'eager' | 'lazy' | undefined | null; /** @deprecated */ marginheight?: number | string | undefined | null; /** @deprecated */ diff --git a/packages/astro/e2e/fixtures/lit-component/src/components/Counter.js b/packages/astro/e2e/fixtures/lit-component/src/components/Counter.js index 3316a7342ccb..72843f8efc55 100644 --- a/packages/astro/e2e/fixtures/lit-component/src/components/Counter.js +++ b/packages/astro/e2e/fixtures/lit-component/src/components/Counter.js @@ -1,8 +1,6 @@ import { LitElement, html } from 'lit'; -export const tagName = 'my-counter'; - -class Counter extends LitElement { +export default class Counter extends LitElement { static get properties() { return { count: { @@ -33,4 +31,4 @@ class Counter extends LitElement { } } -customElements.define(tagName, Counter); +customElements.define('my-counter', Counter); diff --git a/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro b/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro index 48eb7d2f9372..ef86839d6deb 100644 --- a/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro +++ b/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro @@ -1,5 +1,5 @@ --- -import '../components/Counter.js'; +import MyCounter from '../components/Counter.js'; const someProps = { count: 0, @@ -11,16 +11,16 @@ const someProps = { - +

Hello, client:idle!

-
+ - +

Hello, client:load!

-
+ - +

Hello, client:visible!

-
+ diff --git a/packages/astro/e2e/fixtures/lit-component/src/pages/media.astro b/packages/astro/e2e/fixtures/lit-component/src/pages/media.astro index e54cec071e8b..a05d52863168 100644 --- a/packages/astro/e2e/fixtures/lit-component/src/pages/media.astro +++ b/packages/astro/e2e/fixtures/lit-component/src/pages/media.astro @@ -1,5 +1,5 @@ --- -import '../components/Counter.js'; +import MyCounter from '../components/Counter.js'; const someProps = { count: 0, @@ -11,8 +11,8 @@ const someProps = { - +

Hello, client:media!

-
+ diff --git a/packages/astro/e2e/fixtures/lit-component/src/pages/solo.astro b/packages/astro/e2e/fixtures/lit-component/src/pages/solo.astro new file mode 100644 index 000000000000..1d2745e472a3 --- /dev/null +++ b/packages/astro/e2e/fixtures/lit-component/src/pages/solo.astro @@ -0,0 +1,18 @@ +--- +import MyCounter from '../components/Counter.js'; + +const someProps = { + count: 0, +}; +--- + + + + + + + +

Hello, client:idle!

+
+ + diff --git a/packages/astro/e2e/lit-component.test.js b/packages/astro/e2e/lit-component.test.js index acf07f9d9d97..c7e4d8c80e2b 100644 --- a/packages/astro/e2e/lit-component.test.js +++ b/packages/astro/e2e/lit-component.test.js @@ -1,100 +1,138 @@ import { expect } from '@playwright/test'; import { testFactory } from './test-utils.js'; -const test = testFactory({ root: './fixtures/lit-component/' }); - -let devServer; - -test.beforeEach(async ({ astro }) => { - devServer = await astro.startDevServer(); -}); - -test.afterEach(async () => { - await devServer.stop(); +const test = testFactory({ + root: './fixtures/lit-component/', }); // TODO: configure playwright to handle web component APIs // https://github.com/microsoft/playwright/issues/14241 -test.describe.skip('Lit components', () => { - test('client:idle', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); +test.describe('Lit components', () => { + test.beforeEach(() => { + delete globalThis.window; + }); - const counter = page.locator('#client-idle'); - await expect(counter, 'component is visible').toBeVisible(); + test.describe('Development', () => { + let devServer; + const t = test.extend({}); - const count = counter.locator('p'); - await expect(count, 'initial count is 0').toHaveText('Count: 0'); + t.beforeEach(async ({ astro }) => { + devServer = await astro.startDevServer(); + }); - const inc = counter.locator('button'); - await inc.click(); + t.afterEach(async () => { + await devServer.stop(); + }); - await expect(count, 'count incremented by 1').toHaveText('Count: 1'); - }); + t('client:idle', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); - test('client:load', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); + const counter = page.locator('#client-idle'); + await expect(counter, 'component is visible').toBeVisible(); + await expect(counter).toHaveCount(1); - const counter = page.locator('#client-load'); - await expect(counter, 'component is visible').toBeVisible(); + const count = counter.locator('p'); + await expect(count, 'initial count is 0').toHaveText('Count: 0'); - const count = counter.locator('p'); - await expect(count, 'initial count is 0').toHaveText('Count: 0'); + const inc = counter.locator('button'); + await inc.click(); - const inc = counter.locator('button'); - await inc.click(); + await expect(count, 'count incremented by 1').toHaveText('Count: 1'); + }); - await expect(count, 'count incremented by 1').toHaveText('Count: 1'); - }); + t('client:load', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); - test('client:visible', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); + const counter = page.locator('#client-load'); + await expect(counter, 'component is visible').toBeVisible(); - // Make sure the component is on screen to trigger hydration - const counter = page.locator('#client-visible'); - await counter.scrollIntoViewIfNeeded(); - await expect(counter, 'component is visible').toBeVisible(); + const count = counter.locator('p'); + await expect(count, 'initial count is 0').toHaveText('Count: 0'); - const count = counter.locator('p'); - await expect(count, 'initial count is 0').toHaveText('Count: 0'); + const inc = counter.locator('button'); + await inc.click(); - const inc = counter.locator('button'); - await inc.click(); + await expect(count, 'count incremented by 1').toHaveText('Count: 1'); + }); - await expect(count, 'count incremented by 1').toHaveText('Count: 1'); - }); + t('client:visible', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + + // Make sure the component is on screen to trigger hydration + const counter = page.locator('#client-visible'); + await counter.scrollIntoViewIfNeeded(); + await expect(counter, 'component is visible').toBeVisible(); - test('client:media', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/media')); + const count = counter.locator('p'); + await expect(count, 'initial count is 0').toHaveText('Count: 0'); - const counter = page.locator('#client-media'); - await expect(counter, 'component is visible').toBeVisible(); + const inc = counter.locator('button'); + await inc.click(); - const count = counter.locator('p'); - await expect(count, 'initial count is 0').toHaveText('Count: 0'); + await expect(count, 'count incremented by 1').toHaveText('Count: 1'); + }); - const inc = counter.locator('button'); - await inc.click(); + t('client:media', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/media')); - await expect(count, 'component not hydrated yet').toHaveText('Count: 0'); + const counter = page.locator('#client-media'); + await expect(counter, 'component is visible').toBeVisible(); - // Reset the viewport to hydrate the component (max-width: 50rem) - await page.setViewportSize({ width: 414, height: 1124 }); + const count = counter.locator('p'); + await expect(count, 'initial count is 0').toHaveText('Count: 0'); - await inc.click(); - await expect(count, 'count incremented by 1').toHaveText('Count: 1'); + const inc = counter.locator('button'); + await inc.click(); + + await expect(count, 'component not hydrated yet').toHaveText('Count: 0'); + + // Reset the viewport to hydrate the component (max-width: 50rem) + await page.setViewportSize({ width: 414, height: 1124 }); + + await inc.click(); + await expect(count, 'count incremented by 1').toHaveText('Count: 1'); + }); + + t.skip('HMR', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + + const counter = page.locator('#client-idle'); + const label = counter.locator('h1'); + + await astro.editFile('./src/pages/index.astro', (original) => + original.replace('Hello, client:idle!', 'Hello, updated client:idle!') + ); + + await expect(label, 'slot text updated').toHaveText('Hello, updated client:idle!'); + await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid'); + }); }); - test('HMR', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); + test.describe('Production', () => { + let previewServer; + const t = test.extend({}); + + t.beforeAll(async ({ astro }) => { + // Playwright's Node version doesn't have these functions, so stub them. + process.stdout.clearLine = () => {}; + process.stdout.cursorTo = () => {}; + await astro.build(); + }); + + t.beforeEach(async ({ astro }) => { + previewServer = await astro.preview(); + }); - const counter = page.locator('#client-idle'); - const label = counter.locator('h1'); + t.afterEach(async () => { + await previewServer.stop(); + }); - await astro.editFile('./src/pages/index.astro', (original) => - original.replace('Hello, client:idle!', 'Hello, updated client:idle!') - ); + t('Only one component in prod', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/solo')); - await expect(label, 'slot text updated').toHaveText('Hello, updated client:idle!'); - await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid'); + const counter = page.locator('my-counter'); + await expect(counter, 'component is visible').toBeVisible(); + await expect(counter, 'there is only one counter').toHaveCount(1); + }); }); }); diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index d4ee10dd4ad3..5003f42ab9c8 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -710,7 +710,7 @@ export interface AstroUserConfig { * @name Legacy Flags * @description * To help some users migrate between versions of Astro, we occasionally introduce `legacy` flags. - * These flags let you to opt-in to some deprecated or otherwise outdated behavior of Astro + * These flags allow you to opt in to some deprecated or otherwise outdated behavior of Astro * in the latest version, so that you can continue to upgrade and take advantage of new Astro releases. */ legacy?: { @@ -719,7 +719,7 @@ export interface AstroUserConfig { * @name legacy.astroFlavoredMarkdown * @type {boolean} * @default `false` - * @since 1.0.0-rc + * @version 1.0.0-rc.1 * @description * Enable Astro's pre-v1.0 support for components and JSX expressions in `.md` Markdown files. * In Astro `1.0.0-rc`, this original behavior was removed as the default, in favor of our new [MDX integration](/en/guides/integrations-guide/mdx/). diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 64430da6ed68..110a85d677b4 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -154,7 +154,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp // SSR needs to be last opts.astroConfig.output === 'server' && vitePluginSSR(internals, opts.astroConfig._ctx.adapter!), - vitePluginAnalyzer(opts.astroConfig, internals), + vitePluginAnalyzer(internals), ], publicDir: ssr ? false : viteConfig.publicDir, root: viteConfig.root, diff --git a/packages/astro/src/core/build/vite-plugin-analyzer.ts b/packages/astro/src/core/build/vite-plugin-analyzer.ts index 8b9950ff182e..ed92dfe5fa4e 100644 --- a/packages/astro/src/core/build/vite-plugin-analyzer.ts +++ b/packages/astro/src/core/build/vite-plugin-analyzer.ts @@ -1,6 +1,5 @@ import type { PluginContext } from 'rollup'; import type { Plugin as VitePlugin } from 'vite'; -import type { AstroConfig } from '../../@types/astro'; import type { BuildInternals } from '../../core/build/internal.js'; import type { PluginMetadata as AstroPluginMetadata } from '../../vite-plugin-astro/types'; @@ -9,10 +8,7 @@ import { resolveClientDevPath } from '../../core/render/dev/resolve.js'; import { getTopLevelPages } from './graph.js'; import { getPageDataByViteID, trackClientOnlyPageDatas } from './internal.js'; -export function vitePluginAnalyzer( - astroConfig: AstroConfig, - internals: BuildInternals -): VitePlugin { +export function vitePluginAnalyzer(internals: BuildInternals): VitePlugin { function hoistedScriptScanner() { const uniqueHoistedIds = new Map(); const pageScripts = new Map>(); diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts index d8e6ff728866..5ce5640a2787 100644 --- a/packages/astro/src/core/build/vite-plugin-ssr.ts +++ b/packages/astro/src/core/build/vite-plugin-ssr.ts @@ -145,8 +145,10 @@ function buildManifest( // HACK! Patch this special one. const entryModules = Object.fromEntries(internals.entrySpecifierToBundleMap.entries()); - entryModules[BEFORE_HYDRATION_SCRIPT_ID] = - 'data:text/javascript;charset=utf-8,//[no before-hydration script]'; + if (!(BEFORE_HYDRATION_SCRIPT_ID in entryModules)) { + entryModules[BEFORE_HYDRATION_SCRIPT_ID] = + 'data:text/javascript;charset=utf-8,//[no before-hydration script]'; + } const ssrManifest: SerializedSSRManifest = { adapterName: opts.astroConfig._ctx.adapter!.name, diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 35029b7fccb7..0855112ea600 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -73,7 +73,7 @@ export async function createVite( // the build to run very slow as the filewatcher is triggered often. mode === 'dev' && astroViteServerPlugin({ config: astroConfig, logging }), envVitePlugin({ config: astroConfig }), - markdownVitePlugin({ config: astroConfig }), + markdownVitePlugin({ config: astroConfig, logging }), htmlVitePlugin(), jsxVitePlugin({ config: astroConfig, logging }), astroPostprocessVitePlugin({ config: astroConfig }), diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts index 8b5c58425091..72821b3580e8 100644 --- a/packages/astro/src/vite-plugin-markdown/index.ts +++ b/packages/astro/src/vite-plugin-markdown/index.ts @@ -8,6 +8,8 @@ import type { Plugin } from 'vite'; import type { AstroConfig } from '../@types/astro'; import { pagesVirtualModuleId } from '../core/app/index.js'; import { collectErrorMetadata } from '../core/errors.js'; +import type { LogOptions } from '../core/logger/core.js'; +import { warn } from '../core/logger/core.js'; import { resolvePages } from '../core/util.js'; import { cachedCompilation, CompileProps } from '../vite-plugin-astro/compile.js'; import { getViteTransform, TransformHook } from '../vite-plugin-astro/styles.js'; @@ -17,6 +19,7 @@ import { getFileInfo } from '../vite-plugin-utils/index.js'; interface AstroPluginOptions { config: AstroConfig; + logging: LogOptions; } const MARKDOWN_IMPORT_FLAG = '?mdImport'; @@ -34,7 +37,7 @@ function safeMatter(source: string, id: string) { // TODO: Clean up some of the shared logic between this Markdown plugin and the Astro plugin. // Both end up connecting a `load()` hook to the Astro compiler, and share some copy-paste // logic in how that is done. -export default function markdown({ config }: AstroPluginOptions): Plugin { +export default function markdown({ config, logging }: AstroPluginOptions): Plugin { function normalizeFilename(filename: string) { if (filename.startsWith('/@fs')) { filename = filename.slice('/@fs'.length); @@ -170,6 +173,16 @@ export default function markdown({ config }: AstroPluginOptions): Plugin { content.astro = metadata; content.url = getFileInfo(id, config).fileUrl; content.file = filename; + + // Warn when attempting to use setup without the legacy flag + if (setup && !isAstroFlavoredMd) { + warn( + logging, + 'markdown', + `The setup: property in frontmatter only works with the legacy.astroFlavoredMarkdown flag enabled.` + ); + } + const prelude = `--- import Slugger from 'github-slugger'; ${layout ? `import Layout from '${layout}';` : ''} @@ -188,8 +201,16 @@ const $$content = ${JSON.stringify( : // Avoid stripping "setup" and "components" // in plain MD mode { ...content, setup, components } - )} + )}; + +Object.defineProperty($$content.astro, 'headers', { + get() { + console.warn('content.astro.headers has been removed and replaced with content.astro.headings.'); + return undefined; + } +}); ---`; + const imports = `${layout ? `import Layout from '${layout}';` : ''} ${isAstroFlavoredMd ? setup : ''}`.trim(); diff --git a/packages/astro/src/vite-plugin-scripts/index.ts b/packages/astro/src/vite-plugin-scripts/index.ts index 20f4fdafec46..d055cf59d918 100644 --- a/packages/astro/src/vite-plugin-scripts/index.ts +++ b/packages/astro/src/vite-plugin-scripts/index.ts @@ -1,4 +1,4 @@ -import { Plugin as VitePlugin } from 'vite'; +import { ConfigEnv, Plugin as VitePlugin } from 'vite'; import { AstroConfig, InjectedScriptStage } from '../@types/astro.js'; // NOTE: We can't use the virtual "\0" ID convention because we need to @@ -12,8 +12,14 @@ export const PAGE_SCRIPT_ID = `${SCRIPT_ID_PREFIX}${'page' as InjectedScriptStag export const PAGE_SSR_SCRIPT_ID = `${SCRIPT_ID_PREFIX}${'page-ssr' as InjectedScriptStage}.js`; export default function astroScriptsPlugin({ config }: { config: AstroConfig }): VitePlugin { + let env: ConfigEnv | undefined = undefined; return { name: 'astro:scripts', + + config(_config, _env) { + env = _env; + }, + async resolveId(id) { if (id.startsWith(SCRIPT_ID_PREFIX)) { return id; @@ -43,15 +49,8 @@ export default function astroScriptsPlugin({ config }: { config: AstroConfig }): return null; }, buildStart(options) { - // We only want to inject this script if we are building - // for the frontend AND some hydrated components exist in - // the final build. We can detect this by looking for a - // `astro/client/*` input, which signifies both conditions are met. - const hasHydratedComponents = - Array.isArray(options.input) && - options.input.some((input) => input.startsWith('astro/client')); const hasHydrationScripts = config._ctx.scripts.some((s) => s.stage === 'before-hydration'); - if (hasHydratedComponents && hasHydrationScripts) { + if (hasHydrationScripts && env?.command === 'build' && !env?.ssrBuild) { this.emitFile({ type: 'chunk', id: BEFORE_HYDRATION_SCRIPT_ID, diff --git a/packages/integrations/image/package.json b/packages/integrations/image/package.json index 816f08141754..324273799afe 100644 --- a/packages/integrations/image/package.json +++ b/packages/integrations/image/package.json @@ -48,13 +48,13 @@ "image-type": "^4.1.0", "mrmime": "^1.0.0", "sharp": "^0.30.6", - "slash": "^4.0.0" + "slash": "^4.0.0", + "tiny-glob": "^0.2.9" }, "devDependencies": { "@types/etag": "^1.8.1", "@types/sharp": "^0.30.4", "astro": "workspace:*", - "astro-scripts": "workspace:*", - "tiny-glob": "^0.2.9" + "astro-scripts": "workspace:*" } } diff --git a/packages/integrations/image/src/build/ssg.ts b/packages/integrations/image/src/build/ssg.ts index 951f62331f11..78510889c3d4 100644 --- a/packages/integrations/image/src/build/ssg.ts +++ b/packages/integrations/image/src/build/ssg.ts @@ -1,6 +1,6 @@ -import fs from 'fs/promises'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import fs from 'node:fs/promises'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { OUTPUT_DIR } from '../constants.js'; import type { SSRImageService, TransformOptions } from '../types.js'; import { isRemoteImage, loadLocalImage, loadRemoteImage } from '../utils/images.js'; diff --git a/packages/integrations/image/src/build/ssr.ts b/packages/integrations/image/src/build/ssr.ts index 2585868b9c8a..e8de6ae3c710 100644 --- a/packages/integrations/image/src/build/ssr.ts +++ b/packages/integrations/image/src/build/ssr.ts @@ -1,7 +1,7 @@ -import fs from 'fs/promises'; -import path from 'path'; +import fs from 'node:fs/promises'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import glob from 'tiny-glob'; -import { fileURLToPath } from 'url'; import { ensureDir } from '../utils/paths.js'; async function globImages(dir: URL) { diff --git a/packages/integrations/image/src/endpoints/prod.ts b/packages/integrations/image/src/endpoints/prod.ts index 8a15c2e888bd..657f3856dac5 100644 --- a/packages/integrations/image/src/endpoints/prod.ts +++ b/packages/integrations/image/src/endpoints/prod.ts @@ -1,7 +1,6 @@ import type { APIRoute } from 'astro'; import etag from 'etag'; import { lookup } from 'mrmime'; -import { fileURLToPath } from 'url'; // @ts-ignore import loader from 'virtual:image-loader'; import { isRemoteImage, loadLocalImage, loadRemoteImage } from '../utils/images.js'; @@ -20,8 +19,9 @@ export const get: APIRoute = async ({ request }) => { if (isRemoteImage(transform.src)) { inputBuffer = await loadRemoteImage(transform.src); } else { - const pathname = fileURLToPath(new URL(`../client${transform.src}`, import.meta.url)); - inputBuffer = await loadLocalImage(pathname); + const clientRoot = new URL('../client/', import.meta.url); + const localPath = new URL('.' + transform.src, clientRoot); + inputBuffer = await loadLocalImage(localPath.pathname); } if (!inputBuffer) { diff --git a/packages/integrations/image/src/lib/get-picture.ts b/packages/integrations/image/src/lib/get-picture.ts index 7b72736166fd..82bf9f7c565b 100644 --- a/packages/integrations/image/src/lib/get-picture.ts +++ b/packages/integrations/image/src/lib/get-picture.ts @@ -1,5 +1,5 @@ import { lookup } from 'mrmime'; -import { extname } from 'path'; +import { extname } from 'node:path'; import { ImageAttributes, ImageMetadata, OutputFormat, TransformOptions } from '../types.js'; import { parseAspectRatio } from '../utils/images.js'; import { getImage } from './get-image.js'; diff --git a/packages/integrations/image/src/utils/images.ts b/packages/integrations/image/src/utils/images.ts index 55a45d1ce94d..d36c64fc0027 100644 --- a/packages/integrations/image/src/utils/images.ts +++ b/packages/integrations/image/src/utils/images.ts @@ -1,4 +1,4 @@ -import fs from 'fs/promises'; +import fs from 'node:fs/promises'; import type { OutputFormat, TransformOptions } from '../types.js'; export function isOutputFormat(value: string): value is OutputFormat { diff --git a/packages/integrations/image/src/utils/metadata.ts b/packages/integrations/image/src/utils/metadata.ts index 38859b817463..fa60281b6892 100644 --- a/packages/integrations/image/src/utils/metadata.ts +++ b/packages/integrations/image/src/utils/metadata.ts @@ -1,5 +1,5 @@ -import fs from 'fs/promises'; import sizeOf from 'image-size'; +import fs from 'node:fs/promises'; import { ImageMetadata, InputFormat } from '../types.js'; export async function metadata(src: string): Promise { diff --git a/packages/integrations/image/src/utils/paths.ts b/packages/integrations/image/src/utils/paths.ts index 1ba299526e99..a958d49117ff 100644 --- a/packages/integrations/image/src/utils/paths.ts +++ b/packages/integrations/image/src/utils/paths.ts @@ -1,5 +1,5 @@ -import fs from 'fs'; -import path from 'path'; +import fs from 'node:fs'; +import path from 'node:path'; import { OUTPUT_DIR } from '../constants.js'; import type { TransformOptions } from '../types.js'; import { isRemoteImage } from './images.js'; diff --git a/packages/integrations/image/src/vite-plugin-astro-image.ts b/packages/integrations/image/src/vite-plugin-astro-image.ts index 7a494e98900a..81593c142aed 100644 --- a/packages/integrations/image/src/vite-plugin-astro-image.ts +++ b/packages/integrations/image/src/vite-plugin-astro-image.ts @@ -1,7 +1,7 @@ import type { AstroConfig } from 'astro'; +import { pathToFileURL } from 'node:url'; import type { PluginContext } from 'rollup'; import slash from 'slash'; -import { pathToFileURL } from 'url'; import type { Plugin, ResolvedConfig } from 'vite'; import type { IntegrationOptions } from './types.js'; import { metadata } from './utils/metadata.js'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f40158dae08d..e6d4be3c6f47 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2090,12 +2090,12 @@ importers: mrmime: 1.0.1 sharp: 0.30.7 slash: 4.0.0 + tiny-glob: 0.2.9 devDependencies: '@types/etag': 1.8.1 '@types/sharp': 0.30.4 astro: link:../../astro astro-scripts: link:../../../scripts - tiny-glob: 0.2.9 packages/integrations/image/test/fixtures/basic-image: specifiers: @@ -11046,7 +11046,6 @@ packages: /globalyzer/0.1.0: resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} - dev: true /globby/11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} @@ -11074,7 +11073,6 @@ packages: /globrex/0.1.2: resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} - dev: true /graceful-fs/4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} @@ -15340,7 +15338,6 @@ packages: dependencies: globalyzer: 0.1.0 globrex: 0.1.2 - dev: true /tmp/0.0.33: resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}