Skip to content

Commit

Permalink
fix(platform): exclude @analogjs/content from being eagerly bundled
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts committed Jan 11, 2023
1 parent 33d729f commit c8202ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/platform/src/lib/content-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Plugin } from 'vite';

/**
* This excludes the build from including the
* @analogjs/content package because it is
* dynamically imported at runtime.
*
* This prevents a dependency on @analogjs/router
* to @analogjs/content
*
* @returns
*/
export function contentPlugin(): Plugin[] {
return [
{
name: 'analogjs-content-plugin',
config() {
return {
build: {
rollupOptions: {
external: ['@analogjs/content'],
},
},
};
},
},
];
}
2 changes: 2 additions & 0 deletions packages/platform/src/lib/platform-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { viteNitroPlugin } from './vite-nitro-plugin';
import { routerPlugin } from './router-plugin';
import { devServerPlugin } from './ssr/dev-server-plugin';
import { ssrBuildPlugin } from './ssr/ssr-build-plugin';
import { contentPlugin } from './content-plugin';

export function platformPlugin(opts: Options = {}): Plugin[] {
return [
viteNitroPlugin(opts, opts?.nitro),
(opts.ssr ? ssrBuildPlugin() : false) as Plugin,
...routerPlugin(),
...contentPlugin(),
(opts.ssr
? devServerPlugin({ entryServer: opts.entryServer })
: false) as Plugin,
Expand Down

0 comments on commit c8202ab

Please sign in to comment.