diff --git a/.changeset/chilled-otters-explode.md b/.changeset/chilled-otters-explode.md new file mode 100644 index 00000000..c4005848 --- /dev/null +++ b/.changeset/chilled-otters-explode.md @@ -0,0 +1,5 @@ +--- +'astro-purgecss': minor +--- + +Disable renaming css files with new hashes in ssr mode diff --git a/apps/example-purgecss-ssr/.npmrc b/apps/example-purgecss-ssr/.npmrc new file mode 100644 index 00000000..ef83021a --- /dev/null +++ b/apps/example-purgecss-ssr/.npmrc @@ -0,0 +1,2 @@ +# Expose Astro dependencies for `pnpm` users +shamefully-hoist=true diff --git a/apps/example-purgecss-ssr/README.md b/apps/example-purgecss-ssr/README.md new file mode 100644 index 00000000..40dabede --- /dev/null +++ b/apps/example-purgecss-ssr/README.md @@ -0,0 +1,3 @@ +# PurgeCSS Example app + +This is an example app to showcase the `astro-purgecss` integration diff --git a/apps/example-purgecss-ssr/astro.config.ts b/apps/example-purgecss-ssr/astro.config.ts new file mode 100644 index 00000000..668967b8 --- /dev/null +++ b/apps/example-purgecss-ssr/astro.config.ts @@ -0,0 +1,28 @@ +import { defineConfig } from 'astro/config'; +import purgecss from '../../packages/astro-purgecss/src'; + +import node from '@astrojs/node'; + +export default defineConfig({ + // Add purgecss support to Astro + integrations: [ + purgecss({ + fontFace: true, + keyframes: true, + safelist: ['random', 'yep', 'button', /^nav-/], + blocklist: ['usedClass', /^nav-/], + content: [process.cwd() + '/src/**/*.astro'] + }) + ], + + output: 'server', + + build: { + format: 'preserve', + inlineStylesheets: 'never' + }, + + adapter: node({ + mode: 'standalone' + }) +}); diff --git a/apps/example-purgecss-ssr/package.json b/apps/example-purgecss-ssr/package.json new file mode 100644 index 00000000..951707a3 --- /dev/null +++ b/apps/example-purgecss-ssr/package.json @@ -0,0 +1,18 @@ +{ + "name": "@orbit/example-purgecss", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview", + "astro": "astro" + }, + "devDependencies": { + "astro": "^4.0.0" + }, + "dependencies": { + "@astrojs/node": "^8.3.4" + } +} diff --git a/apps/example-purgecss-ssr/public/assets/css/plugin.css b/apps/example-purgecss-ssr/public/assets/css/plugin.css new file mode 100644 index 00000000..98ed35cb --- /dev/null +++ b/apps/example-purgecss-ssr/public/assets/css/plugin.css @@ -0,0 +1,11 @@ +.light-theme { + background-color: white; + color: black; +} + +.unused-class-external { + color: red; /* unused */ +} +.unused-class-external-2 { + color: blue; /* unused */ +} diff --git a/apps/example-purgecss-ssr/public/assets/css/theme.css b/apps/example-purgecss-ssr/public/assets/css/theme.css new file mode 100644 index 00000000..98ed35cb --- /dev/null +++ b/apps/example-purgecss-ssr/public/assets/css/theme.css @@ -0,0 +1,11 @@ +.light-theme { + background-color: white; + color: black; +} + +.unused-class-external { + color: red; /* unused */ +} +.unused-class-external-2 { + color: blue; /* unused */ +} diff --git a/apps/example-purgecss-ssr/public/favicon.svg b/apps/example-purgecss-ssr/public/favicon.svg new file mode 100644 index 00000000..0f390629 --- /dev/null +++ b/apps/example-purgecss-ssr/public/favicon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/apps/example-purgecss-ssr/src/env.d.ts b/apps/example-purgecss-ssr/src/env.d.ts new file mode 100644 index 00000000..acef35f1 --- /dev/null +++ b/apps/example-purgecss-ssr/src/env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/apps/example-purgecss-ssr/src/layouts/main.astro b/apps/example-purgecss-ssr/src/layouts/main.astro new file mode 100644 index 00000000..d0b9d0af --- /dev/null +++ b/apps/example-purgecss-ssr/src/layouts/main.astro @@ -0,0 +1,54 @@ + + + + + + + + + Astro + + + + + + diff --git a/apps/example-purgecss-ssr/src/pages/a/b/c/index.astro b/apps/example-purgecss-ssr/src/pages/a/b/c/index.astro new file mode 100644 index 00000000..32144c8f --- /dev/null +++ b/apps/example-purgecss-ssr/src/pages/a/b/c/index.astro @@ -0,0 +1,18 @@ +--- +import Layout from '../../../../layouts/main.astro'; +--- + + +
+

Astro PurgeCSS

+

+ This is a playground to check all the astro-purgecss integration +

+

+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Vero esse + accusantium, dignissimos corporis ipsam, atque facere expedita aliquid + repellat, unde alias voluptatem officia ullam. Perferendis ipsam facilis + officiis beatae nam. +

+
+
diff --git a/apps/example-purgecss-ssr/src/pages/about.astro b/apps/example-purgecss-ssr/src/pages/about.astro new file mode 100644 index 00000000..da616775 --- /dev/null +++ b/apps/example-purgecss-ssr/src/pages/about.astro @@ -0,0 +1,18 @@ +--- +import Layout from '../layouts/main.astro'; +--- + + +
+

Astro PurgeCSS

+

+ This is a playground to check all the astro-purgecss integration +

+

+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Vero esse + accusantium, dignissimos corporis ipsam, atque facere expedita aliquid + repellat, unde alias voluptatem officia ullam. Perferendis ipsam facilis + officiis beatae nam. +

+
+
diff --git a/apps/example-purgecss-ssr/src/pages/d/index.astro b/apps/example-purgecss-ssr/src/pages/d/index.astro new file mode 100644 index 00000000..57a3c6e3 --- /dev/null +++ b/apps/example-purgecss-ssr/src/pages/d/index.astro @@ -0,0 +1,18 @@ +--- +import Layout from '../../layouts/main.astro'; +--- + + +
+

Astro PurgeCSS

+

+ This is a playground to check all the astro-purgecss integration +

+

+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Vero esse + accusantium, dignissimos corporis ipsam, atque facere expedita aliquid + repellat, unde alias voluptatem officia ullam. Perferendis ipsam facilis + officiis beatae nam. +

+
+
diff --git a/apps/example-purgecss-ssr/src/pages/index.astro b/apps/example-purgecss-ssr/src/pages/index.astro new file mode 100644 index 00000000..da616775 --- /dev/null +++ b/apps/example-purgecss-ssr/src/pages/index.astro @@ -0,0 +1,18 @@ +--- +import Layout from '../layouts/main.astro'; +--- + + +
+

Astro PurgeCSS

+

+ This is a playground to check all the astro-purgecss integration +

+

+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Vero esse + accusantium, dignissimos corporis ipsam, atque facere expedita aliquid + repellat, unde alias voluptatem officia ullam. Perferendis ipsam facilis + officiis beatae nam. +

+
+
diff --git a/apps/example-purgecss-ssr/tsconfig.json b/apps/example-purgecss-ssr/tsconfig.json new file mode 100644 index 00000000..bcbf8b50 --- /dev/null +++ b/apps/example-purgecss-ssr/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "astro/tsconfigs/strict" +} diff --git a/apps/example-purgecss/package.json b/apps/example-purgecss/package.json index 67ede2f7..a0a2f9bf 100644 --- a/apps/example-purgecss/package.json +++ b/apps/example-purgecss/package.json @@ -1,5 +1,5 @@ { - "name": "@orbit/example-purgecss", + "name": "@orbit/example-purgecss-ssr", "version": "0.0.1", "private": true, "scripts": { diff --git a/apps/playground/tsconfig.json b/apps/playground/tsconfig.json index 77da9dd0..bcbf8b50 100644 --- a/apps/playground/tsconfig.json +++ b/apps/playground/tsconfig.json @@ -1,3 +1,3 @@ { "extends": "astro/tsconfigs/strict" -} \ No newline at end of file +} diff --git a/package.json b/package.json index e95f72b4..e7fce17e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build": "turbo run build && turbo run typecheck", "build:no-cache": "turbo run build --no-cache && turbo run typecheck", "dev": "turbo run dev --no-cache --parallel --continue", - "format": "prettier --write \"**/*.{ts,tsx,md,astro,mjs,mts,d.ts}\"", + "format": "prettier --write \"**/*.{ts,tsx,md,astro,mjs,mts,d.ts,json}\"", "clean": "turbo run clean && rm -rf node_modules", "changeset": "changeset", "changeset:version": "changeset version", @@ -22,7 +22,7 @@ "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.9", "@types/node": "^22.9.0", - "astro": "^4.16.10", + "astro": "^4.16.13", "commander": "^12.1.0", "esbuild": "^0.24.0", "esbuild-plugin-clean": "^1.0.1", @@ -33,9 +33,9 @@ "prettier-plugin-astro": "^0.14.1", "tiny-glob": "^0.2.9", "tsup": "^8.3.5", - "turbo": "^2.2.3", + "turbo": "^2.3.0", "typescript": "^5.6.3", "vite-tsconfig-paths": "^5.1.2", - "vitest": "^2.1.4" + "vitest": "^2.1.5" } } diff --git a/packages/astro-purgecss/README.md b/packages/astro-purgecss/README.md index 1395355a..92a1a2b7 100644 --- a/packages/astro-purgecss/README.md +++ b/packages/astro-purgecss/README.md @@ -10,7 +10,7 @@ ## ๐Ÿ“ฆ Installation -### Quick Install +### โšก Quick Install the `astro add` command-line tool automates the installation for you. Run one of the following commands in a new terminal window. (If you arenโ€™t sure which package manager youโ€™re using, run the first command.) Then, follow the prompts, and type โ€œyโ€ in the terminal (meaning โ€œyesโ€) for each one. @@ -23,7 +23,7 @@ npx astro add astro-purgecss yarn astro add astro-purgecss ``` -### Manual Install +### ๐Ÿ”ง Manual Install First, install the `purgecss` & `astro-purgecss` packages using your package manager. (If you arenโ€™t sure which package manager youโ€™re using, run the first command.) @@ -75,7 +75,7 @@ export default defineConfig({ }); ``` -## ๐Ÿ“– Configuration +## โš™๏ธ Configuration [PurgeCSS][purgecss] has a list of options that allow you to customize its behavior. And this Astro integration allow you to pass those options easily in your `astro.config.mjs` file: @@ -88,7 +88,7 @@ export default defineConfig({ safelist: ['random', 'yep', 'button', /^nav-/], blocklist: ['usedClass', /^nav-/], content: [ - process.cwd() + '/src/**/*.{astro,vue}' // Watching astro and vue sources (for SSR, read the note below) + process.cwd() + '/src/**/*.{astro,vue}' // Watching astro and vue sources (read SSR docs below) ], extractors: [ { @@ -103,15 +103,11 @@ export default defineConfig({ }); ``` -> **Note** -> -> If you are using **Astro SSR** in your project, you must add your astro and framework sources files into the `content` option (see in the example). Otherwise, as the package only look at the final build sent to the client, with SSR, some pages may not be included and may break your CSS. - -### Available Options +### ๐Ÿ“– Available Options Here is a list of options, that are allowed to be passed in the config: -```ts +```typescript export type PurgeCSSOptions = { fontFace?: boolean; // removes any unused @font-face if set to true keyframes?: boolean; // removes unused keyframes by setting if set to true @@ -121,11 +117,11 @@ export type PurgeCSSOptions = { safelist?: UserDefinedSafelist; // indicates which selectors are safe to leave in the final CSS blocklist?: StringRegExpArray; // blocks the CSS selectors from appearing in the final output CSS content?: Array; - extractors?: // provides custom functions to extract CSS classes in specific ways (eg. when using tailwind.css) - Array<{ + // provides custom functions to extract CSS classes in specific ways (eg. when using tailwind.css) + extractors?: { extractor: (content: string) => string[]; // matched css classes extensions: string[]; // file extensions for which this extractor is to be used - }>; + }[]; }; ``` @@ -133,22 +129,51 @@ To learn more about the available options, please refer to [PurgeCSS][purgecss-o We have also setup an example repository available here: [example-purgecss](../../apps/example-purgecss) -### Caveats +## ๐ŸŒ SSR Mode + +If you are using **Astro SSR** in your project, you must add your Astro and framework source files into the `content` option (see example below). Since the integration analyzes the final client-side build, some SSR-rendered pages might not be included in the initial scan, which could result in necessary CSS being incorrectly purged. + +Example configuration for SSR: + +```js +export default defineConfig({ + integrations: [ + purgecss({ + content: [ + './src/**/*.{astro,js,jsx,ts,tsx,vue,svelte}' + // Add any other template files that contain styles + ] + }) + ] +}); +``` + +### Important Notes + +1. **CSS Retention**: Due to the integration's file scanning approach, some unused CSS might be retained. This is a deliberate trade-off to prevent accidentally removing dynamically used styles. + +2. **Inline Styles vs External Stylesheets**: The integration can more accurately analyze and purge external stylesheets compared to inline styles embedded within components: + - โœ… **Recommended**: Use external stylesheet files (`.css`) + - โš ๏ธ **Less Effective**: Inline styles in component files + +## โš ๏ธ Caveats - Some options are not allowed to be passed in your `astro.config.mjs` config file, to not interfere with the internals of this integration. - If you are using Astro view transitions, use the following options so that purgecss keeps the corresponding animations: -```diff +```js export default defineConfig({ integrations: [ purgecss({ -+ keyframes: false, -+ safelist: { -+ greedy: [/*astro*/] -+ } - }), - ], + keyframes: false, + safelist: { + greedy: [ + /*astro*/ + ] + } + }) + ] }); ``` @@ -170,11 +195,11 @@ export default defineConfig({ }); ``` -## Changelog +## ๐Ÿ“ Changelog Please see the [Changelog](CHANGELOG.md) for more information on what has changed recently. -## Acknowledgements +## ๐Ÿ’ Acknowledgements - [Purgecss][purgecss] diff --git a/packages/astro-purgecss/src/index.ts b/packages/astro-purgecss/src/index.ts index 888e3491..db9e986f 100644 --- a/packages/astro-purgecss/src/index.ts +++ b/packages/astro-purgecss/src/index.ts @@ -12,32 +12,57 @@ import { writeFileContent } from './utils'; +/** + * Extended PurgeCSS options interface that allows partial configuration + * of the standard PurgeCSS options + */ export interface PurgeCSSOptions extends Partial {} -const PKG_NAME = 'astro-purgecss' as const; +const INTEGRATION_NAME = 'astro-purgecss' as const; +/** + * default extractor to handle various CSS selector patterns + * @param content string + */ +const defaultExtractor = (content: string) => + content.match(/[\w-/:]+(? { config = cfg; }, 'astro:build:done': async ({ dir, pages, logger }) => { + const buildMode = config.output; + logger.info(`๐Ÿ“ฆ Running in '${buildMode}' mode`); + + // Convert the URL to a filesystem path const outDir = fileURLToPath(dir); + // Used to skip file rehashing for SSR/Hybrid modes + const isSSR = buildMode !== 'static'; + + // Validate required Astro configuration if (!outDir || !config.build.format || !config.build.assets) { logger.warn( - `${PKG_NAME} requires the 'outDir', 'build.format', 'build.assets' astro.config options.` + `${INTEGRATION_NAME} requires the following astro.config options: 'outDir', 'build.format', 'build.assets'` ); return; } - logger.info('Generating purged css files...'); - const purged = await new PurgeCSS().purge({ + // Run PurgeCSS on all CSS files + const purgeResults = await new PurgeCSS().purge({ css: [join(outDir, '/**/*.css')], - defaultExtractor: (content) => content.match(/[\w-/:]+(? file?.endsWith('.css')) - .map(async ({ css, file }) => { - const oldFile = file as string; - - // skip rehashing file if not generated by astro ex: assets/styles/light.css - if (!oldFile.includes(config.build.assets)) { - await writeCssFile(oldFile, css, oldFile); - success(oldFile.replace(outDir, '')); - return { - oldFilename: oldFile.replace(outDir, ''), - newFilename: oldFile.replace(outDir, '') - }; - } + // Filter out non-CSS files from purge results + const purgedCssFiles = purgeResults.filter(({ file }) => + file?.endsWith('.css') + ) as Array<{ + css: string; + file: string; + }>; + + if (purgedCssFiles.length === 0) { + logger.info('โ„น๏ธ No CSS files found to process'); + return; + } - // Generate new hash based on content - const newFile = generateFileHash(oldFile, css); + logger.info( + `Found ${purgedCssFiles.length} CSS ${purgedCssFiles.length === 1 ? 'file' : 'files'} to process` + ); - // Write new file - await writeCssFile(newFile, css, oldFile); - success(newFile.replace(outDir, '')); + // Handle SSR/Hybrid mode + if (isSSR) { + await Promise.all( + purgedCssFiles.map(async ({ css, file }) => { + await writeCssFile(file, css, file); + success(file.replace(outDir, '')); + }) + ); + logger.info('๐ŸŽ‰ Purging completed successfully!'); + return; + } + // Process files for static mode with content hashing + let processedFiles = await Promise.all( + purgedCssFiles.map(async ({ css, file }) => { + const isAssetFile = file.includes(config.build.assets); + + // Skip rehashing for non-asset files (not generated by astro) + // ex: assets/styles/light.css + if (!isAssetFile) { + await writeCssFile(file, css, file); + const relativePath = file.replace(outDir, ''); + success(relativePath); return { - oldFilename: oldFile.replace(outDir, ''), - newFilename: newFile.replace(outDir, '') + oldFilename: relativePath, + newFilename: relativePath }; - }) + } + + // Generate new filename with content hash + const hashedFilename = generateFileHash(file, css); + await writeCssFile(hashedFilename, css, file); + + const relativeOldPath = file.replace(outDir, ''); + const relativeNewPath = hashedFilename.replace(outDir, ''); + success(relativeNewPath); + + return { + oldFilename: relativeOldPath, + newFilename: relativeNewPath + }; + }) ); - // Filter out unchanged files: keep only files where content was modified and rehashed - // This ensures we only process files that actually changed during purging - purgedCssFiles = purgedCssFiles.filter( + // Filter to only get files that actually changed + const changedFiles = processedFiles.filter( ({ oldFilename, newFilename }) => oldFilename !== newFilename ); - if (purgedCssFiles.length > 0) { - logger.info('Updating css references in html files...'); - const htmlPages = pages - .filter((e: any) => typeof e.pathname == 'string') - // see: https://docs.astro.build/en/reference/configuration-reference/#buildformat + if (changedFiles.length > 0) { + logger.info( + `Updating ${changedFiles.length} CSS ${changedFiles.length === 1 ? 'reference' : 'references'} in HTML files...` + ); + // Get all HTML pages based on build format + const htmlFiles = pages + .filter((page) => typeof page.pathname === 'string') .map((page) => { - // Special case: Handle root/index page - if (page.pathname === '') return join(outDir, `index.html`); - - // Build format: - // 'file' - Astro will generate an HTML file named for each page route - if (config.build.format === 'file') { - return join(outDir, `${page.pathname}.html`); - } + const pathname = page.pathname as string; - // Build format: - // 'directory' - Astro will generate a directory with a nested index.html file for each page - if (config.build.format === 'directory') { - return join(outDir, page.pathname, 'index.html'); + // Handle root/index page + if (pathname === '') { + return join(outDir, 'index.html'); } - // Build format: - // 'preserve' - Maintains existing structure or falls back to directory format - - // Check if an HTML file already exists at the target location - if (existsSync(join(outDir, `${page.pathname}.html`))) { - return join(outDir, `${page.pathname}.html`); + switch (config.build.format) { + case 'file': + // Format: /blog -> /blog.html + return join(outDir, `${pathname}.html`); + + case 'directory': + // Format: /blog -> /blog/index.html + return join(outDir, pathname, 'index.html'); + + case 'preserve': + // Check if direct HTML file exists, otherwise use directory format + const directFile = join(outDir, `${pathname}.html`); + return existsSync(directFile) + ? directFile + : join(outDir, pathname, 'index.html'); } - - // Default: Use directory format - return join(outDir, page.pathname, 'index.html'); }); + // Update CSS references in HTML files await Promise.all( - htmlPages.map(async (page) => { - let content = await readFileContent(page); + htmlFiles.map(async (htmlFile) => { + let content = await readFileContent(htmlFile); - for (const cssFile of purgedCssFiles) { - if (content.includes(cssFile.oldFilename)) { + for (const { oldFilename, newFilename } of changedFiles) { + if (content.includes(oldFilename)) { content = content.replace( - new RegExp(cssFile.oldFilename, 'g'), - cssFile.newFilename + new RegExp(oldFilename, 'g'), + newFilename ); } } - await writeFileContent(page, content); - success(page.replace(outDir, '')); + + await writeFileContent(htmlFile, content); + success(htmlFile.replace(outDir, '')); }) ); - } else { - logger.info('No CSS files were modified during purging.'); } - logger.info('completed successfully!'); + logger.info('๐ŸŽ‰ Purging completed successfully!'); } } }; diff --git a/packages/astro-seo-meta/package.json b/packages/astro-seo-meta/package.json index ecb8c37c..770881c3 100644 --- a/packages/astro-seo-meta/package.json +++ b/packages/astro-seo-meta/package.json @@ -2,19 +2,10 @@ "name": "astro-seo-meta", "description": "Astro seo provides a component to update meta tags", "version": "4.1.1", - "scripts": { - "build": "astro-build --src src/index.ts src/**/*.astro", - "typecheck": "tsc --declaration --emitDeclarationOnly" - }, - "type": "module", - "types": "dist/index.d.ts", + "homepage": "https://github.com/codiume/orbit", + "bugs": "https://github.com/codiume/orbit/issues", "author": "codiume", "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/codiume/orbit.git", - "directory": "packages/astro-seo-meta" - }, "keywords": [ "astro", "astro-integration", @@ -23,8 +14,17 @@ "meta", "seo" ], - "bugs": "https://github.com/codiume/orbit/issues", - "homepage": "https://github.com/codiume/orbit", + "repository": { + "type": "git", + "url": "https://github.com/codiume/orbit.git", + "directory": "packages/astro-seo-meta" + }, + "scripts": { + "build": "astro-build --src src/index.ts src/**/*.astro", + "typecheck": "tsc --declaration --emitDeclarationOnly" + }, + "type": "module", + "types": "dist/index.d.ts", "files": [ "dist" ], diff --git a/packages/astro-seo-meta/src/components/Seo.astro b/packages/astro-seo-meta/src/components/Seo.astro index 75b91492..279b2c77 100644 --- a/packages/astro-seo-meta/src/components/Seo.astro +++ b/packages/astro-seo-meta/src/components/Seo.astro @@ -1,7 +1,7 @@ --- -import Meta, { ColorScheme } from './Meta.astro'; -import Facebook, { Props as FacebookProps } from './Facebook.astro'; -import Twitter, { Props as TwitterProps } from './Twitter.astro'; +import Facebook, { type Props as FacebookProps } from './Facebook.astro'; +import Meta, { type ColorScheme } from './Meta.astro'; +import Twitter, { type Props as TwitterProps } from './Twitter.astro'; export type Props = { title?: string; diff --git a/packages/astro-seo-meta/src/index.ts b/packages/astro-seo-meta/src/index.ts index 56c01425..b768eba6 100644 --- a/packages/astro-seo-meta/src/index.ts +++ b/packages/astro-seo-meta/src/index.ts @@ -1,2 +1 @@ -export { default as Seo } from './components/Seo.astro'; -export { type Props as SeoProps } from './components/Seo.astro'; +export { default as Seo, type Props as SeoProps } from './components/Seo.astro'; diff --git a/packages/astro-seo-schema/package.json b/packages/astro-seo-schema/package.json index cf0ad641..2cc6f2bf 100644 --- a/packages/astro-seo-schema/package.json +++ b/packages/astro-seo-schema/package.json @@ -2,19 +2,10 @@ "name": "astro-seo-schema", "description": "Easily insert valid Schema.org JSON-LD in your Astro apps.", "version": "4.0.3", - "scripts": { - "build": "astro-build --src src/index.ts src/jsonld.ts src/Schema.astro", - "typecheck": "tsc --declaration --emitDeclarationOnly" - }, - "type": "module", - "types": "dist/index.d.ts", + "homepage": "https://github.com/codiume/orbit", + "bugs": "https://github.com/codiume/orbit/issues", "author": "codiume", "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/codiume/orbit.git", - "directory": "packages/astro-seo-schema" - }, "keywords": [ "astro", "astro-component", @@ -23,8 +14,17 @@ "semantic-web", "seo" ], - "bugs": "https://github.com/codiume/orbit/issues", - "homepage": "https://github.com/codiume/orbit", + "repository": { + "type": "git", + "url": "https://github.com/codiume/orbit.git", + "directory": "packages/astro-seo-schema" + }, + "scripts": { + "build": "astro-build --src src/index.ts src/jsonld.ts src/Schema.astro", + "typecheck": "tsc --declaration --emitDeclarationOnly" + }, + "type": "module", + "types": "dist/index.d.ts", "files": [ "dist" ], diff --git a/packages/astro-svg-loaders/package.json b/packages/astro-svg-loaders/package.json index 48032cad..a24ce6db 100644 --- a/packages/astro-svg-loaders/package.json +++ b/packages/astro-svg-loaders/package.json @@ -2,19 +2,10 @@ "name": "astro-svg-loaders", "description": "Astro loading icons and small animations built with pure SVG.", "version": "4.0.1", - "scripts": { - "build": "astro-build --src src/index.ts src/loaders/*.astro", - "typecheck": "tsc --declaration --emitDeclarationOnly" - }, - "type": "module", - "types": "dist/index.d.ts", + "homepage": "https://github.com/codiume/orbit", + "bugs": "https://github.com/codiume/orbit/issues", "author": "codiume", "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/codiume/orbit.git", - "directory": "packages/astro-svg-loaders" - }, "keywords": [ "astro", "astro-component", @@ -23,8 +14,16 @@ "loaders", "svg" ], - "bugs": "https://github.com/codiume/orbit/issues", - "homepage": "https://github.com/codiume/orbit", + "repository": { + "type": "git", + "url": "https://github.com/codiume/orbit.git", + "directory": "packages/astro-svg-loaders" + }, + "scripts": { + "build": "astro-build --src src/index.ts src/loaders/*.astro" + }, + "type": "module", + "types": "dist/index.d.ts", "files": [ "dist" ], diff --git a/packages/astro-useragent/package.json b/packages/astro-useragent/package.json index ce62ccb1..81104beb 100644 --- a/packages/astro-useragent/package.json +++ b/packages/astro-useragent/package.json @@ -2,27 +2,31 @@ "name": "astro-useragent", "description": "Parses browser user-agent strings for Astro", "version": "4.0.2", - "scripts": { - "build": "astro-build --src src/index.ts src/parse.ts src/useUserAgent.ts", - "typecheck": "tsc --declaration --emitDeclarationOnly" - }, - "type": "module", - "types": "dist/index.d.ts", + "homepage": "https://github.com/codiume/orbit", + "bugs": "https://github.com/codiume/orbit/issues", "author": "codiume", "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/codiume/orbit.git", - "directory": "packages/astro-useragent" - }, "keywords": [ "astro", "astro-component", "astro-integration", - "accessibility" + "astro-useragent", + "accessibility", + "useragent", + "user-agent-parser", + "browser-detection" ], - "bugs": "https://github.com/codiume/orbit/issues", - "homepage": "https://github.com/codiume/orbit", + "repository": { + "type": "git", + "url": "https://github.com/codiume/orbit.git", + "directory": "packages/astro-useragent" + }, + "scripts": { + "build": "astro-build --src src/index.ts src/parse.ts src/useUserAgent.ts", + "typecheck": "tsc --declaration --emitDeclarationOnly" + }, + "type": "module", + "types": "dist/index.d.ts", "files": [ "dist" ], diff --git a/packages/astro-vanilla-extract/package.json b/packages/astro-vanilla-extract/package.json index 3ede606f..c7a05805 100644 --- a/packages/astro-vanilla-extract/package.json +++ b/packages/astro-vanilla-extract/package.json @@ -2,45 +2,51 @@ "name": "astro-vanilla-extract", "description": "Adds vanilla-extract support to Astro", "version": "5.0.1", - "scripts": { - "build": "astro-build --src src/**/*.ts", - "typecheck": "tsc --declaration --emitDeclarationOnly" - }, - "type": "module", - "types": "dist/index.d.ts", + "homepage": "https://github.com/codiume/orbit", + "bugs": "https://github.com/codiume/orbit/issues", "author": "codiume", "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/codiume/orbit.git", - "directory": "packages/astro-vanilla-extract" - }, "keywords": [ "astro", "astro-component", "astro-integration", - "css" + "astro-vanilla-extract", + "css", + "vanilla-extract" ], - "bugs": "https://github.com/codiume/orbit/issues", - "homepage": "https://github.com/codiume/orbit", + "repository": { + "type": "git", + "url": "https://github.com/codiume/orbit.git", + "directory": "packages/astro-vanilla-extract" + }, + "scripts": { + "build": "tsup", + "check-types": "tsc", + "check-exports": "attw --pack . --ignore-rules false-export-default", + "typecheck": "pnpm check-types && pnpm check-exports" + }, + "type": "module", + "main": "./dist/index.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist" ], - "main": "./dist/index.mjs", "exports": { ".": { "import": { "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" } } }, "peerDependencies": { "astro": "^4.0.0" }, - "devDependencies": { - "astro-build": "workspace:*" - }, "dependencies": { "@vanilla-extract/css": "^1.14.1", "@vanilla-extract/vite-plugin": "^4.0.4" diff --git a/packages/astro-vanilla-extract/tsconfig.json b/packages/astro-vanilla-extract/tsconfig.json index ef8f9f5b..03bc7996 100644 --- a/packages/astro-vanilla-extract/tsconfig.json +++ b/packages/astro-vanilla-extract/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "noEmit": false, + "noEmit": true, "outDir": "./dist", "allowImportingTsExtensions": false } diff --git a/packages/astro-vanilla-extract/tsup.config.ts b/packages/astro-vanilla-extract/tsup.config.ts new file mode 100644 index 00000000..8d1c1a24 --- /dev/null +++ b/packages/astro-vanilla-extract/tsup.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/index.ts'], + format: ['esm', 'cjs'], + outDir: 'dist', + clean: true, + dts: true, + minify: true, + sourcemap: true, + splitting: false, + treeshake: true, + platform: 'node' +}); diff --git a/packages/astro-webhooks/package.json b/packages/astro-webhooks/package.json index c83bf08b..86e2940a 100644 --- a/packages/astro-webhooks/package.json +++ b/packages/astro-webhooks/package.json @@ -1,48 +1,48 @@ { - "name": "astro-webhooks", - "description": "Receive webhooks in Astro apps", - "version": "0.0.1", - "homepage": "https://github.com/codiume/orbit", - "bugs": "https://github.com/codiume/orbit/issues", - "author": "codiume", - "license": "MIT", - "keywords": [ - "astro", - "astro-integration", - "astro-webhooks", - "webhooks" - ], - "repository": { - "type": "git", - "url": "https://github.com/codiume/orbit.git", - "directory": "packages/astro-webhooks" - }, - "scripts": { - "build": "tsup", - "check-types": "tsc", - "check-exports": "attw --pack . --ignore-rules false-export-default", - "typecheck": "pnpm check-types && pnpm check-exports" - }, - "type": "module", - "main": "./dist/index.js", - "module": "./dist/index.js", - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "exports": { - ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - }, - "require": { - "types": "./dist/index.d.cts", - "default": "./dist/index.cjs" - } - } - }, - "peerDependencies": { - "astro": "^4.0.0" - } + "name": "astro-webhooks", + "description": "Receive webhooks in Astro apps", + "version": "0.0.1", + "homepage": "https://github.com/codiume/orbit", + "bugs": "https://github.com/codiume/orbit/issues", + "author": "codiume", + "license": "MIT", + "keywords": [ + "astro", + "astro-integration", + "astro-webhooks", + "webhooks" + ], + "repository": { + "type": "git", + "url": "https://github.com/codiume/orbit.git", + "directory": "packages/astro-webhooks" + }, + "scripts": { + "build": "tsup", + "check-types": "tsc", + "check-exports": "attw --pack . --ignore-rules false-export-default", + "typecheck": "pnpm check-types && pnpm check-exports" + }, + "type": "module", + "main": "./dist/index.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "files": [ + "dist" + ], + "exports": { + ".": { + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } + } + }, + "peerDependencies": { + "astro": "^4.0.0" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 772ac70b..73bd758a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,7 +21,7 @@ importers: specifier: ^22.9.0 version: 22.9.0 astro: - specifier: ^4.16.10 + specifier: ^4.16.13 version: 4.16.13(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) commander: specifier: ^12.1.0 @@ -54,7 +54,7 @@ importers: specifier: ^8.3.5 version: 8.3.5(postcss@8.4.49)(typescript@5.6.3) turbo: - specifier: ^2.2.3 + specifier: ^2.3.0 version: 2.3.0 typescript: specifier: ^5.6.3 @@ -63,7 +63,7 @@ importers: specifier: ^5.1.2 version: 5.1.2(typescript@5.6.3)(vite@5.4.11(@types/node@22.9.0)) vitest: - specifier: ^2.1.4 + specifier: ^2.1.5 version: 2.1.5(@types/node@22.9.0) apps/example-purgecss: @@ -79,6 +79,19 @@ importers: specifier: ^4.0.0 version: 4.16.13(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) + apps/example-purgecss-ssr: + dependencies: + '@astrojs/node': + specifier: ^8.3.4 + version: 8.3.4(astro@4.16.13(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3)) + astro-purgecss: + specifier: workspace:* + version: link:../../packages/astro-purgecss + devDependencies: + astro: + specifier: ^4.0.0 + version: 4.16.13(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) + apps/example-useragent: dependencies: '@astrojs/node': @@ -114,7 +127,7 @@ importers: dependencies: astro: specifier: ^4.0.0 - version: 4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3) + version: 4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) purgecss: specifier: ^6.0.0 version: 6.0.0 @@ -123,7 +136,7 @@ importers: dependencies: astro: specifier: ^4.0.0 - version: 4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3) + version: 4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) devDependencies: astro-build: specifier: workspace:* @@ -133,7 +146,7 @@ importers: dependencies: astro: specifier: ^4.0.0 - version: 4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3) + version: 4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) schema-dts: specifier: ^1.1.0 version: 1.1.2(typescript@5.6.3) @@ -146,7 +159,7 @@ importers: dependencies: astro: specifier: ^4.0.0 - version: 4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3) + version: 4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) devDependencies: astro-build: specifier: workspace:* @@ -156,7 +169,7 @@ importers: dependencies: astro: specifier: ^4.0.0 - version: 4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3) + version: 4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) ua-parser-js: specifier: ^1.0.2 version: 1.0.39 @@ -178,17 +191,13 @@ importers: version: 4.0.17(@types/node@22.9.0)(vite@5.4.11(@types/node@22.9.0)) astro: specifier: ^4.0.0 - version: 4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3) - devDependencies: - astro-build: - specifier: workspace:* - version: link:../astro-build + version: 4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) packages/astro-webhooks: dependencies: astro: specifier: ^4.0.0 - version: 4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3) + version: 4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3) packages: @@ -2517,8 +2526,8 @@ packages: package-manager-detector@0.1.2: resolution: {integrity: sha512-iePyefLTOm2gEzbaZKSW+eBMjg+UYsQvUKxmvGXAQ987K16efBg10MxIjZs08iyX+DY2/owKY9DIdu193kX33w==} - package-manager-detector@0.2.2: - resolution: {integrity: sha512-VgXbyrSNsml4eHWIvxxG/nTL4wgybMTXCV2Un/+yEc3aDKKU6nQBZjbeP3Pl3qm9Qg92X/1ng4ffvCeD/zwHgg==} + package-manager-detector@0.2.4: + resolution: {integrity: sha512-H/OUu9/zUfP89z1APcBf2X8Us0tt8dUK4lUmKqz12QNXif3DxAs1/YqjGtcutZi1zQqeNQRWr9C+EbQnnvSSFA==} parse-latin@7.0.0: resolution: {integrity: sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ==} @@ -2975,8 +2984,8 @@ packages: resolution: {integrity: sha512-Zc+8eJlFMvgatPZTl6A9L/yht8QqdmUNtURHaKZLmKBE12hNPSrqNkUp2cs3M/UKmNVVAMFQYSjYIVHDjW5zew==} engines: {node: '>=12.0.0'} - tinypool@1.0.1: - resolution: {integrity: sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==} + tinypool@1.0.2: + resolution: {integrity: sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==} engines: {node: ^18.0.0 || >=20.0.0} tinyrainbow@1.2.0: @@ -3112,8 +3121,8 @@ packages: undici-types@6.19.8: resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} - undici@6.20.1: - resolution: {integrity: sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA==} + undici@6.21.0: + resolution: {integrity: sha512-BUgJXc752Kou3oOIuU1i+yZZypyZRqNPW0vqoMPl8VaoalSfeR0D8/t4iAS3yirs79SSMTxTag+ZC86uswv+Cw==} engines: {node: '>=18.17'} unicode-emoji-modifier-base@1.0.0: @@ -3676,7 +3685,7 @@ snapshots: fs-extra: 7.0.1 mri: 1.2.0 p-limit: 2.3.0 - package-manager-detector: 0.2.2 + package-manager-detector: 0.2.4 picocolors: 1.1.1 resolve-from: 5.0.0 semver: 7.6.3 @@ -4138,7 +4147,7 @@ snapshots: '@octokit/plugin-paginate-rest': 9.2.1(@octokit/core@5.2.0) '@octokit/plugin-rest-endpoint-methods': 10.4.1(@octokit/core@5.2.0) '@octokit/types': 12.6.0 - undici: 6.20.1 + undici: 6.21.0 '@octokit/auth-action@4.1.0': dependencies: @@ -4208,14 +4217,6 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true - '@rollup/pluginutils@5.1.3(rollup@4.25.0)': - dependencies: - '@types/estree': 1.0.6 - estree-walker: 2.0.2 - picomatch: 4.0.2 - optionalDependencies: - rollup: 4.25.0 - '@rollup/pluginutils@5.1.3(rollup@4.27.2)': dependencies: '@types/estree': 1.0.6 @@ -4591,7 +4592,7 @@ snapshots: assertion-error@2.0.1: {} - astro@4.16.10(@types/node@22.9.0)(rollup@4.25.0)(typescript@5.6.3): + astro@4.16.10(@types/node@22.9.0)(rollup@4.27.2)(typescript@5.6.3): dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/internal-helpers': 0.4.1 @@ -4601,7 +4602,7 @@ snapshots: '@babel/plugin-transform-react-jsx': 7.25.9(@babel/core@7.26.0) '@babel/types': 7.26.0 '@oslojs/encoding': 1.1.0 - '@rollup/pluginutils': 5.1.3(rollup@4.25.0) + '@rollup/pluginutils': 5.1.3(rollup@4.27.2) '@types/babel__core': 7.20.5 '@types/cookie': 0.6.0 acorn: 8.14.0 @@ -6028,7 +6029,7 @@ snapshots: package-manager-detector@0.1.2: {} - package-manager-detector@0.2.2: {} + package-manager-detector@0.2.4: {} parse-latin@7.0.0: dependencies: @@ -6586,7 +6587,7 @@ snapshots: fdir: 6.4.2(picomatch@4.0.2) picomatch: 4.0.2 - tinypool@1.0.1: {} + tinypool@1.0.2: {} tinyrainbow@1.2.0: {} @@ -6635,7 +6636,7 @@ snapshots: picocolors: 1.1.1 postcss-load-config: 6.0.1(postcss@8.4.49) resolve-from: 5.0.0 - rollup: 4.25.0 + rollup: 4.27.2 source-map: 0.8.0-beta.0 sucrase: 3.35.0 tinyexec: 0.3.1 @@ -6691,7 +6692,7 @@ snapshots: undici-types@6.19.8: {} - undici@6.20.1: {} + undici@6.21.0: {} unicode-emoji-modifier-base@1.0.0: {} @@ -6868,7 +6869,7 @@ snapshots: std-env: 3.8.0 tinybench: 2.9.0 tinyexec: 0.3.1 - tinypool: 1.0.1 + tinypool: 1.0.2 tinyrainbow: 1.2.0 vite: 5.4.11(@types/node@22.9.0) vite-node: 2.1.5(@types/node@22.9.0) diff --git a/renovate.json b/renovate.json index e837fac9..7adfc05d 100644 --- a/renovate.json +++ b/renovate.json @@ -1,15 +1,11 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" - ], + "extends": ["config:base"], "dependencyDashboard": false, "rangeStrategy": "update-lockfile", "packageRules": [ { - "matchUpdateTypes": [ - "patch" - ], + "matchUpdateTypes": ["patch"], "matchCurrentVersion": "!/^0/", "automerge": true } diff --git a/turbo.json b/turbo.json index efa2b642..594f169f 100644 --- a/turbo.json +++ b/turbo.json @@ -7,20 +7,12 @@ "cache": false }, "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - "dist/**" - ] + "dependsOn": ["^build"], + "outputs": ["dist/**"] }, "typecheck": { - "dependsOn": [ - "^typecheck" - ], - "outputs": [ - "dist/**" - ] + "dependsOn": ["^typecheck"], + "outputs": ["dist/**"] }, "dev": { "cache": false