Skip to content

Commit

Permalink
feat(vite-plugin-angular): expose esbuild entry point (#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc authored Feb 27, 2024
1 parent fdd6412 commit f991473
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
30 changes: 30 additions & 0 deletions packages/vite-plugin-angular/esbuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import analog from '@analogjs/vite-plugin-angular';
import type * as esbuild from 'esbuild';

export const analogSFC: () => esbuild.Plugin = () => ({
name: 'analog-sfc-esbuild-plugin',
async setup(build) {
const analogPlugins: any = analog({
experimental: { supportAnalogFormat: true },
});

const analogPlugin = analogPlugins[0];
await analogPlugin.config({ root: '.' }, { command: 'build' });
await analogPlugin.buildStart?.({
plugins: [
{
name: 'vite:css',
transform(code: string) {
return { code };
},
},
],
});

build.onLoad({ filter: /.analog$/ }, async (args) => {
await analogPlugin.handleHotUpdate?.({ file: args.path, modules: [] });
const result = await analogPlugin.transform?.('', args.path);
return { loader: 'js', contents: result?.code };
});
},
});
7 changes: 6 additions & 1 deletion packages/vite-plugin-angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
"packages/vite-plugin-angular/*.md",
"packages/vite-plugin-angular/migrations/migration.json"
],
"updateBuildableProjectDepsInPackageJson": false
"updateBuildableProjectDepsInPackageJson": false,
"additionalEntryPoints": [
"packages/vite-plugin-angular/esbuild.ts",
"packages/vite-plugin-angular/setup-vitest.ts"
],
"generateExportsField": true
}
},
"test": {
Expand Down

0 comments on commit f991473

Please sign in to comment.