Skip to content

Commit 6793349

Browse files
committed
Fix build error involving Vite/Rollup imports of Node libraries, remove Preact component from footer
1 parent 7425123 commit 6793349

7 files changed

Lines changed: 61 additions & 188 deletions

File tree

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"jdbc",
4444
"Joomla",
4545
"jscoverage",
46-
"jsdom",
4746
"KHTML",
4847
"koko",
4948
"labelledby",

astro.config.ts

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import mdx from '@astrojs/mdx'
2-
import preact from '@astrojs/preact'
32
import sitemap from '@astrojs/sitemap'
43
import vercelStatic from '@astrojs/vercel'
5-
import sentry from "@sentry/astro"
4+
import sentry from '@sentry/astro'
65
import tailwindcss from '@tailwindcss/vite'
76
import AstroPWA from '@vite-pwa/astro'
87
import vtbot from 'astro-vtbot'
98
import icon from 'astro-icon'
109
import { defineConfig } from 'astro/config'
10+
import { fileURLToPath } from 'node:url'
11+
import type { PluginOption } from 'vite'
1112
/**
1213
* You cannot use path aliases (@lib, @components, etc.) in files that are
1314
* imported by astro.config.ts, because the path alias resolution happens
@@ -32,6 +33,21 @@ import { packageRelease } from './src/integrations/PackageRelease'
3233
import { privacyPolicyVersion } from './src/integrations/PrivacyPolicyVersion'
3334
import { createSerializeFunction, pagesJsonWriter } from './src/integrations/sitemapSerialize'
3435

36+
const disablePwaIntegration = process.env['DISABLE_PWA']?.toLowerCase() === 'true'
37+
const enableRollupLogger = process.env['DEBUG_ROLLUP']?.toLowerCase() === 'true'
38+
39+
const rollupImportLogger = (): PluginOption => ({
40+
enforce: 'pre',
41+
name: 'rollup-import-logger',
42+
resolveId(source, importer) {
43+
if (source.includes('rollup') || source === 'vite' || source.startsWith('vite/') || source.includes('vite/dist')) {
44+
console.info('[rollup-import]', source, importer)
45+
}
46+
47+
return null
48+
},
49+
})
50+
3551
export default defineConfig({
3652
adapter: vercelStatic(vercelConfig),
3753
devToolbar: {
@@ -42,20 +58,19 @@ export default defineConfig({
4258
* Astro sets substantial Vite config internally in the framework. When you use Vitest
4359
* in an Astro project, you use Astro's getViteConfig helper to get the resolved internal
4460
* Vite syntax along with any Vite syntax set in this astro.config.ts file. Since integrations
45-
* can change config, they're ran when the helper's called. This causes problems for
61+
* can change config, they're ran when the helper's called. This causes problems for
4662
* unit testing integrations.
4763
*/
4864
integrations: isUnitTest() ? [] : [
49-
AstroPWA(serviceWorkerConfig),
65+
...(disablePwaIntegration ? [] : [AstroPWA(serviceWorkerConfig)]),
5066
icon(),
5167
mdx(markdownConfig),
52-
preact({ devtools: true }),
5368
/** Generate favicons and PWA icons from source SVG */
5469
faviconGenerator(),
5570
/** Verify number of call to actions included in Markdown files */
5671
callToActionValidator({
5772
/** Enable debug logging to see validation details */
58-
debug: true
73+
debug: true,
5974
}),
6075
/** Inject package release (name@version) for tracking regressions between releases */
6176
packageRelease(),
@@ -87,13 +102,23 @@ export default defineConfig({
87102
/** Source map generation must be turned on for Sentry. */
88103
sourcemap: true,
89104
},
105+
define: {
106+
/**
107+
* LightningCSS exposes a WASM build via require('../pkg'), which Vite cannot
108+
* resolve when bundling for the browser. Setting this flag to false at build
109+
* time lets Rollup tree-shake the problematic branch.
110+
*/
111+
'process.env.CSS_TRANSFORMER_WASM': 'false',
112+
},
90113
/* @ts-expect-error - tailwindcss plugin type compatibility */
91-
plugins: [tailwindcss()],
92-
/**
93-
* Note: The "astro:transitions sourcemap" warning is cosmetic and can be safely
94-
* ignored. It occurs because the transitions plugin transforms code without
95-
* generating sourcemaps. This doesn't affect build functionality, runtime
96-
* performance, or debugging capabilities
97-
*/
114+
plugins: [
115+
tailwindcss(),
116+
...(enableRollupLogger ? [rollupImportLogger()] : []),
117+
] as PluginOption[],
118+
resolve: {
119+
alias: {
120+
fsevents: fileURLToPath(new URL('./src/shims/fsevents.ts', import.meta.url)),
121+
},
122+
},
98123
}
99124
})

0 commit comments

Comments
 (0)