summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar matthewp <matthewp@users.noreply.github.com> 2022-02-02 16:36:23 +0000
committerGravatar GitHub Actions <actions@github.com> 2022-02-02 16:36:23 +0000
commiteecc996d7e578f8fe1bf1f77a943684cfee943e3 (patch)
tree091b22b283a17aea0d64330971e976cafb6a9287
parent3e8844fa871fa477026375db6d921beb4b23b0dc (diff)
downloadastro-eecc996d7e578f8fe1bf1f77a943684cfee943e3.tar.gz
astro-eecc996d7e578f8fe1bf1f77a943684cfee943e3.tar.zst
astro-eecc996d7e578f8fe1bf1f77a943684cfee943e3.zip
[ci] yarn format
-rw-r--r--packages/astro/src/vite-plugin-astro/compile.ts16
-rw-r--r--packages/astro/src/vite-plugin-astro/hmr.ts30
2 files changed, 29 insertions, 17 deletions
diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts
index 616ec7aec..d52a8be17 100644
--- a/packages/astro/src/vite-plugin-astro/compile.ts
+++ b/packages/astro/src/vite-plugin-astro/compile.ts
@@ -94,17 +94,17 @@ async function compile(config: AstroConfig, filename: string, source: string, vi
// throw CSS transform errors here if encountered
if (cssTransformError) throw cssTransformError;
- const compileResult: CompileResult = Object.create(transformResult, {
+ const compileResult: CompileResult = Object.create(transformResult, {
rawCSSDeps: {
- value: rawCSSDeps
- }
+ value: rawCSSDeps,
+ },
});
return compileResult;
}
export function isCached(config: AstroConfig, filename: string) {
- return configCache.has(config) && (configCache.get(config)!).has(filename);
+ return configCache.has(config) && configCache.get(config)!.has(filename);
}
export function invalidateCompilation(config: AstroConfig, filename: string) {
@@ -114,7 +114,13 @@ export function invalidateCompilation(config: AstroConfig, filename: string) {
}
}
-export async function cachedCompilation(config: AstroConfig, filename: string, source: string | null, viteTransform: TransformHook, opts: boolean | undefined): Promise<CompileResult> {
+export async function cachedCompilation(
+ config: AstroConfig,
+ filename: string,
+ source: string | null,
+ viteTransform: TransformHook,
+ opts: boolean | undefined
+): Promise<CompileResult> {
let cache: CompilationCache;
if (!configCache.has(config)) {
cache = new Map();
diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts
index f39d3fecd..84f06cda5 100644
--- a/packages/astro/src/vite-plugin-astro/hmr.ts
+++ b/packages/astro/src/vite-plugin-astro/hmr.ts
@@ -13,25 +13,31 @@ interface TrackCSSDependenciesOptions {
export async function trackCSSDependencies(this: RollupPluginContext, opts: TrackCSSDependenciesOptions): Promise<void> {
const { viteDevServer, filename, deps, id } = opts;
// Dev, register CSS dependencies for HMR.
- if(viteDevServer) {
+ if (viteDevServer) {
const mod = viteDevServer.moduleGraph.getModuleById(id);
- if(mod) {
- const cssDeps = (await Promise.all(Array.from(deps).map((spec) => {
- return this.resolve(spec, id);
- }))).filter(Boolean).map(dep => (dep as ResolvedId).id);
+ if (mod) {
+ const cssDeps = (
+ await Promise.all(
+ Array.from(deps).map((spec) => {
+ return this.resolve(spec, id);
+ })
+ )
+ )
+ .filter(Boolean)
+ .map((dep) => (dep as ResolvedId).id);
const { moduleGraph } = viteDevServer;
// record deps in the module graph so edits to @import css can trigger
// main import to hot update
const depModules = new Set(mod.importedModules);
for (const dep of cssDeps) {
- depModules.add(moduleGraph.createFileOnlyEntry(dep))
+ depModules.add(moduleGraph.createFileOnlyEntry(dep));
}
// Update the module graph, telling it about our CSS deps.
moduleGraph.updateModuleInfo(mod, depModules, new Set(), true);
for (const dep of cssDeps) {
- this.addWatchFile(dep);
+ this.addWatchFile(dep);
}
}
}
@@ -45,13 +51,13 @@ export function handleHotUpdate(ctx: HmrContext, config: AstroConfig) {
// that needs to be rerun.
const filtered = new Set<ModuleNode>();
const files = new Set<string>();
- for(const mod of ctx.modules) {
- if(mod.file && isCached(config, mod.file)) {
+ for (const mod of ctx.modules) {
+ if (mod.file && isCached(config, mod.file)) {
filtered.add(mod);
files.add(mod.file);
}
- for(const imp of mod.importers) {
- if(imp.file && isCached(config, imp.file)) {
+ for (const imp of mod.importers) {
+ if (imp.file && isCached(config, imp.file)) {
filtered.add(imp);
files.add(imp.file);
}
@@ -60,7 +66,7 @@ export function handleHotUpdate(ctx: HmrContext, config: AstroConfig) {
// Invalidate happens as a separate step because a single .astro file
// produces multiple CSS modules and we want to return all of those.
- for(const file of files) {
+ for (const file of files) {
invalidateCompilation(config, file);
}