Skip to content

Commit

Permalink
[ci] lint
Browse files Browse the repository at this point in the history
  • Loading branch information
studiocms-no-reply committed Dec 19, 2024
1 parent 6b0b58f commit b79b554
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
8 changes: 6 additions & 2 deletions packages/studiocms_ui/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import type { AstroIntegration } from 'astro';
import { createResolver } from './utils/create-resolver';
import { viteVirtualModulePluginBuilder } from './utils/virtual-module-plugin-builder'
import { viteVirtualModulePluginBuilder } from './utils/virtual-module-plugin-builder';

// biome-ignore lint/complexity/noBannedTypes: Will be implemented in v0.3.0
type Options = {};

export default function integration(options: Options = {}): AstroIntegration {
const { resolve } = createResolver(import.meta.url);

const globalCss = viteVirtualModulePluginBuilder('studiocms:ui/global-css', 'sui-global-css', `import '${resolve('./css/global.css')}'`);
const globalCss = viteVirtualModulePluginBuilder(
'studiocms:ui/global-css',
'sui-global-css',
`import '${resolve('./css/global.css')}'`
);

return {
name: '@studiocms/ui',
Expand Down
42 changes: 21 additions & 21 deletions packages/studiocms_ui/src/utils/virtual-module-plugin-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ type VitePlugin = Required<AstroConfig['vite']>['plugins'][number];
* @returns A Vite plugin that resolves and loads the virtual module.
*/
export function viteVirtualModulePluginBuilder(
moduleId: string,
name: string,
moduleContent: string
moduleId: string,
name: string,
moduleContent: string
) {
return function modulePlugin(): VitePlugin {
const resolvedVirtualModuleId = `\0${moduleId}`; // Prefix with \0 to avoid conflicts
return function modulePlugin(): VitePlugin {
const resolvedVirtualModuleId = `\0${moduleId}`; // Prefix with \0 to avoid conflicts

return {
name,
resolveId(id) {
if (id === moduleId) {
return resolvedVirtualModuleId;
}
return;
},
load(id) {
if (id === resolvedVirtualModuleId) {
return moduleContent;
}
return;
},
};
};
return {
name,
resolveId(id) {
if (id === moduleId) {
return resolvedVirtualModuleId;
}
return;
},
load(id) {
if (id === resolvedVirtualModuleId) {
return moduleContent;
}
return;
},
};
};
}

0 comments on commit b79b554

Please sign in to comment.