Skip to content

Commit

Permalink
Remove unused mode param
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Dec 27, 2023
1 parent 79aa10a commit f157c45
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 24 deletions.
6 changes: 1 addition & 5 deletions packages/astro/src/content/vite-plugin-content-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ export function astroContentAssetPropagationPlugin({
if (!devModuleLoader.getModuleById(basePath)?.ssrModule) {
await devModuleLoader.import(basePath);
}
const { styles, urls } = await getStylesForURL(
pathToFileURL(basePath),
devModuleLoader,
'development'
);
const { styles, urls } = await getStylesForURL(pathToFileURL(basePath), devModuleLoader);

const hoistedScripts = await getScriptsForURL(
pathToFileURL(basePath),
Expand Down
10 changes: 1 addition & 9 deletions packages/astro/src/vite-plugin-astro-server/css.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { RuntimeMode } from '../@types/astro.js';
import type { ModuleLoader } from '../core/module-loader/index.js';
import { viteID } from '../core/util.js';
import { isBuildableCSSRequest } from './util.js';
Expand All @@ -13,21 +12,14 @@ interface ImportedStyle {
/** Given a filePath URL, crawl Vite’s module graph to find all style imports. */
export async function getStylesForURL(
filePath: URL,
loader: ModuleLoader,
mode: RuntimeMode
loader: ModuleLoader
): Promise<{ urls: Set<string>; styles: ImportedStyle[] }> {
const importedCssUrls = new Set<string>();
// Map of url to injected style object. Use a `url` key to deduplicate styles
const importedStylesMap = new Map<string, ImportedStyle>();

for await (const importedModule of crawlGraph(loader, viteID(filePath), true)) {
if (isBuildableCSSRequest(importedModule.url)) {
// In production, we can simply assign the styles as URLs
if (mode !== 'development') {
importedCssUrls.add(importedModule.url);
continue;
}

// In dev, we inline all styles if possible
let css = '';
// If this is a plain CSS module, the default export should be a string
Expand Down
6 changes: 1 addition & 5 deletions packages/astro/src/vite-plugin-astro-server/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,7 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa
}

// Pass framework CSS in as style tags to be appended to the page.
const { urls: styleUrls, styles: importedStyles } = await getStylesForURL(
filePath,
moduleLoader,
mode
);
const { urls: styleUrls, styles: importedStyles } = await getStylesForURL(filePath, moduleLoader);
let links = new Set<SSRElement>();
[...styleUrls].forEach((href) => {
links.add({
Expand Down
6 changes: 1 addition & 5 deletions packages/astro/test/units/dev/styles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ describe('Crawling graph for CSS', () => {
it("importedModules is checked against the child's importers", async () => {
// In dev mode, HMR modules tracked are added to importedModules. We use `importers`
// to verify that they are true importers.
const res = await getStylesForURL(
new URL('./src/pages/index.astro', root),
loader,
'development'
);
const res = await getStylesForURL(new URL('./src/pages/index.astro', root), loader);
expect(res.styles.length).to.equal(1);
});
});

0 comments on commit f157c45

Please sign in to comment.