@analogjs/platform 3.0.0-alpha.7 → 3.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -13
- package/src/index.d.ts +1 -1
- package/src/index.js +7 -3
- package/src/index.js.map +1 -0
- package/src/lib/clear-client-page-endpoint.d.ts +1 -1
- package/src/lib/clear-client-page-endpoint.js +22 -32
- package/src/lib/clear-client-page-endpoint.js.map +1 -0
- package/src/lib/content/marked/index.js +10 -6
- package/src/lib/content/marked/index.js.map +1 -0
- package/src/lib/content/marked/marked-content-highlighter.js +6 -3
- package/src/lib/content/marked/marked-content-highlighter.js.map +1 -0
- package/src/lib/content/marked/marked-setup.service.js +44 -54
- package/src/lib/content/marked/marked-setup.service.js.map +1 -0
- package/src/lib/content/prism/angular.js +18 -19
- package/src/lib/content/prism/angular.js.map +1 -0
- package/src/lib/content/prism/index.js +10 -7
- package/src/lib/content/prism/index.js.map +1 -0
- package/src/lib/content/prism/prism-highlighter.js +33 -33
- package/src/lib/content/prism/prism-highlighter.js.map +1 -0
- package/src/lib/content/shiki/index.js +19 -28
- package/src/lib/content/shiki/index.js.map +1 -0
- package/src/lib/content/shiki/shiki-highlighter.js +45 -44
- package/src/lib/content/shiki/shiki-highlighter.js.map +1 -0
- package/src/lib/content-plugin.d.ts +2 -2
- package/src/lib/content-plugin.js +156 -196
- package/src/lib/content-plugin.js.map +1 -0
- package/src/lib/deps-plugin.js +71 -82
- package/src/lib/deps-plugin.js.map +1 -0
- package/src/lib/nx-plugin/package.json +2 -4
- package/src/lib/nx-plugin/src/executors/vite/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vite/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vitest/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/compat.js +7 -7
- package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/vite.config.ts__template__ +0 -8
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/vite.config.ts__template__ +0 -17
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/vite.config.ts__template__ +0 -17
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/vite.config.ts__template__ +0 -8
- package/src/lib/nx-plugin/src/generators/app/generator.js +78 -92
- package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js +11 -12
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js +72 -81
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js +23 -58
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js +12 -55
- package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js +15 -16
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js +14 -13
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js +17 -29
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +59 -95
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js +8 -44
- package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js +17 -20
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js +59 -105
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js +14 -18
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js +35 -54
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js +41 -68
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.d.ts +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +9 -11
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js +24 -43
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.d.ts +0 -5
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js +29 -36
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +5 -10
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js +30 -37
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js +11 -16
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions.d.ts +0 -10
- package/src/lib/nx-plugin/src/generators/app/versions.js +28 -42
- package/src/lib/nx-plugin/src/generators/app/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/compat.js +7 -7
- package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/generator.js +54 -65
- package/src/lib/nx-plugin/src/generators/init/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js +19 -20
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js +20 -21
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js +56 -66
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js +12 -11
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js +17 -21
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js +12 -15
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js +19 -31
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js +43 -51
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js +27 -34
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js +19 -20
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/page/generator.js +34 -44
- package/src/lib/nx-plugin/src/generators/page/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/preset/generator.js +11 -43
- package/src/lib/nx-plugin/src/generators/preset/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js +7 -7
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js +35 -42
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js +7 -7
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js +20 -27
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js +19 -22
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/index.js +0 -2
- package/src/lib/nx-plugin/src/utils/version-utils.js +20 -27
- package/src/lib/nx-plugin/src/utils/version-utils.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js +42 -62
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js +49 -83
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js +19 -20
- package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js +19 -20
- package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.d.ts +5 -5
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +22 -23
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
- package/src/lib/options.d.ts +4 -0
- package/src/lib/platform-plugin.js +59 -62
- package/src/lib/platform-plugin.js.map +1 -0
- package/src/lib/router-plugin.js +140 -176
- package/src/lib/router-plugin.js.map +1 -0
- package/src/lib/ssr/inject-html-plugin.js +25 -25
- package/src/lib/ssr/inject-html-plugin.js.map +1 -0
- package/src/lib/ssr/ssr-build-plugin.d.ts +18 -2
- package/src/lib/ssr/ssr-build-plugin.js +54 -30
- package/src/lib/ssr/ssr-build-plugin.js.map +1 -0
- package/src/lib/utils/rolldown.d.ts +3 -0
- package/src/lib/utils/rolldown.js +15 -0
- package/src/lib/utils/rolldown.js.map +1 -0
- package/src/server-mode-plugin.d.ts +1 -1
- package/src/server-mode-plugin.js +16 -18
- package/src/server-mode-plugin.js.map +1 -0
- package/README.md +0 -5
- package/src/lib/content/prism/options.js +0 -1
- package/src/lib/content/shiki/options.js +0 -1
- package/src/lib/nx-plugin/README.md +0 -23
- package/src/lib/nx-plugin/src/index.js.map +0 -1
- package/src/lib/options.js +0 -1
- package/src/lib/ssr/ssr-xhr-plugin.d.ts +0 -2
- package/src/lib/ssr/ssr-xhr-plugin.js +0 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shiki-highlighter.js","names":[],"sources":["../../../../../../../packages/platform/src/lib/content/shiki/shiki-highlighter.ts"],"sourcesContent":["import markedShiki from 'marked-shiki';\nimport {\n type BundledLanguage,\n type BundledTheme,\n type CodeOptionsMeta,\n type CodeOptionsMultipleThemes,\n type CodeOptionsSingleTheme,\n type CodeToHastOptionsCommon,\n getHighlighter,\n} from 'shiki';\n\nimport { MarkedContentHighlighter } from '../marked/marked-content-highlighter.js';\n\nexport type ShikiHighlighterOptions = Parameters<typeof getHighlighter>[0];\nexport type ShikiHighlightOptions = Partial<\n Omit<CodeToHastOptionsCommon<BundledLanguage>, 'lang'>\n> &\n CodeOptionsMeta &\n Partial<CodeOptionsSingleTheme<BundledTheme>> &\n Partial<CodeOptionsMultipleThemes<BundledTheme>>;\n\nexport const defaultHighlighterOptions: {\n langs: string[];\n themes: string[];\n} = {\n langs: [\n 'json',\n 'ts',\n 'tsx',\n 'js',\n 'jsx',\n 'html',\n 'css',\n 'angular-html',\n 'angular-ts',\n ],\n themes: ['github-dark', 'github-light'],\n};\n\nexport class ShikiHighlighter extends MarkedContentHighlighter {\n private readonly highlighter = getHighlighter(this.highlighterOptions);\n\n constructor(\n private highlighterOptions: ShikiHighlighterOptions,\n private highlightOptions: ShikiHighlightOptions,\n private container: string,\n private hasLoadMermaid = false,\n ) {\n super();\n }\n getHighlightExtension(): import('marked').MarkedExtension {\n return markedShiki({\n container: this.container,\n highlight: async (code, lang, props) => {\n if (this.hasLoadMermaid && lang === 'mermaid') {\n return `<pre class=\"mermaid\">${code}</pre>`;\n }\n\n const { codeToHtml } = await this.highlighter;\n return codeToHtml(\n code,\n Object.assign(\n {\n lang,\n // required by `transformerMeta*`\n meta: { __raw: props.join(' ') },\n theme: 'github-dark',\n },\n this.highlightOptions,\n ),\n );\n },\n });\n }\n}\n"],"mappings":";;;;AAqBA,IAAa,4BAGT;CACF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACD,QAAQ,CAAC,eAAe,eAAe;CACxC;AAED,IAAa,mBAAb,cAAsC,yBAAyB;CAG7D,YACE,oBACA,kBACA,WACA,iBAAyB,OACzB;AACA,SAAO;AALC,OAAA,qBAAA;AACA,OAAA,mBAAA;AACA,OAAA,YAAA;AACA,OAAA,iBAAA;qBANqB,eAAe,KAAK,mBAAmB;;CAUtE,wBAA0D;AACxD,SAAO,YAAY;GACjB,WAAW,KAAK;GAChB,WAAW,OAAO,MAAM,MAAM,UAAU;AACtC,QAAI,KAAK,kBAAkB,SAAS,UAClC,QAAO,wBAAwB,KAAK;IAGtC,MAAM,EAAE,eAAe,MAAM,KAAK;AAClC,WAAO,WACL,MACA,OAAO,OACL;KACE;KAEA,MAAM,EAAE,OAAO,MAAM,KAAK,IAAI,EAAE;KAChC,OAAO;KACR,EACD,KAAK,iBACN,CACF;;GAEJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as vite from 'vite';
|
|
2
2
|
import type { WithShikiHighlighterOptions } from './content/shiki/options.js';
|
|
3
3
|
import type { WithPrismHighlighterOptions } from './content/prism/options.js';
|
|
4
4
|
import type { WithMarkedOptions } from './content/marked/index.js';
|
|
@@ -19,4 +19,4 @@ export type ContentPluginOptions = {
|
|
|
19
19
|
* - Relative paths without ./ or ../ are treated as package names
|
|
20
20
|
* - Must convert to absolute paths for imports to work correctly
|
|
21
21
|
*/
|
|
22
|
-
export declare function contentPlugin({ highlighter, markedOptions, shikiOptions, prismOptions, }?: ContentPluginOptions, options?: Options): Plugin[];
|
|
22
|
+
export declare function contentPlugin({ highlighter, markedOptions, shikiOptions, prismOptions, }?: ContentPluginOptions, options?: Options): vite.Plugin[];
|
|
@@ -1,198 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { getBundleOptionsKey } from "./utils/rolldown.js";
|
|
2
|
+
import * as vite from "vite";
|
|
3
|
+
import { globSync } from "tinyglobby";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
//#region packages/platform/src/lib/content-plugin.ts
|
|
5
7
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (!id.includes('analog-content-file=true')) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (!markedHighlighter) {
|
|
156
|
-
if (highlighter === 'shiki') {
|
|
157
|
-
const { getShikiHighlighter } = await import('./content/shiki/index.js');
|
|
158
|
-
markedHighlighter = getShikiHighlighter(shikiOptions);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
const { getPrismHighlighter } = await import('./content/prism/index.js');
|
|
162
|
-
markedHighlighter = getPrismHighlighter();
|
|
163
|
-
const langs = [
|
|
164
|
-
'bash',
|
|
165
|
-
'css',
|
|
166
|
-
'javascript',
|
|
167
|
-
'json',
|
|
168
|
-
'markup',
|
|
169
|
-
'typescript',
|
|
170
|
-
];
|
|
171
|
-
if (Array.isArray(prismOptions?.additionalLangs) &&
|
|
172
|
-
prismOptions?.additionalLangs?.length > 0) {
|
|
173
|
-
langs.push(...prismOptions.additionalLangs);
|
|
174
|
-
}
|
|
175
|
-
const loadLanguages = await import('prismjs/components/index.js');
|
|
176
|
-
loadLanguages.default(langs);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
const fm = await import('front-matter');
|
|
180
|
-
// The `default` property will be available in CommonJS environment, for instance,
|
|
181
|
-
// when running unit tests. It's safe to retrieve `default` first, since we still
|
|
182
|
-
// fallback to the original implementation.
|
|
183
|
-
const frontmatterFn = fm.default || fm;
|
|
184
|
-
const fileContents = readFileSync(id.split('?')[0], 'utf8');
|
|
185
|
-
const { body, frontmatter } = frontmatterFn(fileContents);
|
|
186
|
-
// parse markdown and highlight
|
|
187
|
-
const { getMarkedSetup } = await import('./content/marked/index.js');
|
|
188
|
-
const markedSetupService = getMarkedSetup({ mangle: true, ...(markedOptions || {}) }, markedHighlighter);
|
|
189
|
-
const mdContent = (await markedSetupService
|
|
190
|
-
.getMarkedInstance()
|
|
191
|
-
.parse(body));
|
|
192
|
-
return `export default ${JSON.stringify(`---\n${frontmatter}\n---\n\n${mdContent}`)}`;
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
...contentDiscoveryPlugins,
|
|
196
|
-
];
|
|
8
|
+
* Content plugin that provides markdown and content file processing for Analog.
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT: This plugin uses tinyglobby for file discovery.
|
|
11
|
+
* Key pitfall with { dot: true }:
|
|
12
|
+
* - Returns relative paths from cwd (e.g., "apps/blog-app/src/content/...")
|
|
13
|
+
* - These paths CANNOT be used directly in ES module imports
|
|
14
|
+
* - Relative paths without ./ or ../ are treated as package names
|
|
15
|
+
* - Must convert to absolute paths for imports to work correctly
|
|
16
|
+
*/
|
|
17
|
+
function contentPlugin({ highlighter, markedOptions, shikiOptions, prismOptions } = {}, options) {
|
|
18
|
+
const cache = /* @__PURE__ */ new Map();
|
|
19
|
+
let markedHighlighter;
|
|
20
|
+
const workspaceRoot = vite.normalizePath(options?.workspaceRoot ?? process.cwd());
|
|
21
|
+
let config;
|
|
22
|
+
let root;
|
|
23
|
+
const contentDiscoveryPlugins = [{
|
|
24
|
+
name: "analog-content-glob-routes",
|
|
25
|
+
config(_config) {
|
|
26
|
+
config = _config;
|
|
27
|
+
root = vite.normalizePath(resolve(workspaceRoot, config.root || ".") || ".");
|
|
28
|
+
},
|
|
29
|
+
transform: {
|
|
30
|
+
filter: { code: "ANALOG_CONTENT_FILE_LIST" },
|
|
31
|
+
handler(code) {
|
|
32
|
+
if (code.includes("ANALOG_CONTENT_FILE_LIST")) {
|
|
33
|
+
const contentFilesList = globSync([`${root}/src/content/**/*.md`, ...(options?.additionalContentDirs || []).map((glob) => `${workspaceRoot}${glob}/**/*.md`)], { dot: true });
|
|
34
|
+
const eagerImports = [];
|
|
35
|
+
contentFilesList.forEach((module, index) => {
|
|
36
|
+
const absolutePath = module.startsWith("/") ? module : `${workspaceRoot}/${module}`;
|
|
37
|
+
eagerImports.push(`import { default as analog_module_${index} } from "${absolutePath}?analog-content-list=true";`);
|
|
38
|
+
});
|
|
39
|
+
let result = code.replace("const ANALOG_CONTENT_FILE_LIST = {};", `
|
|
40
|
+
let ANALOG_CONTENT_FILE_LIST = {${contentFilesList.map((module, index) => `"${module.replace(root, "")}": analog_module_${index}`)}};
|
|
41
|
+
`);
|
|
42
|
+
if (!code.includes("analog_module_")) result = `${eagerImports.join("\n")}\n${result}`;
|
|
43
|
+
return {
|
|
44
|
+
code: result,
|
|
45
|
+
map: { mappings: "" }
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
name: "analogjs-invalidate-content-dirs",
|
|
52
|
+
configureServer(server) {
|
|
53
|
+
function invalidateContent(path) {
|
|
54
|
+
if (path.includes(vite.normalizePath(`/content/`))) {
|
|
55
|
+
server.moduleGraph.fileToModulesMap.forEach((mods) => {
|
|
56
|
+
mods.forEach((mod) => {
|
|
57
|
+
if (mod.id?.includes("analogjs") && mod.id?.includes("content")) {
|
|
58
|
+
server.moduleGraph.invalidateModule(mod);
|
|
59
|
+
mod.importers.forEach((imp) => {
|
|
60
|
+
server.moduleGraph.invalidateModule(imp);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
server.ws.send({ type: "full-reload" });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
server.watcher.on("add", invalidateContent);
|
|
69
|
+
server.watcher.on("unlink", invalidateContent);
|
|
70
|
+
}
|
|
71
|
+
}];
|
|
72
|
+
if (!highlighter) return [
|
|
73
|
+
{
|
|
74
|
+
name: "analogjs-external-content",
|
|
75
|
+
config() {
|
|
76
|
+
return { build: { [getBundleOptionsKey()]: { external: ["@analogjs/content"] } } };
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "analogjs-exclude-content-import",
|
|
81
|
+
transform: {
|
|
82
|
+
filter: { code: "@analogjs/content" },
|
|
83
|
+
handler(code) {
|
|
84
|
+
/**
|
|
85
|
+
* Remove the package so it doesn't get
|
|
86
|
+
* referenced when building for serverless
|
|
87
|
+
* functions.
|
|
88
|
+
*/
|
|
89
|
+
if (code.includes(`import('@analogjs/content')`)) return { code: code.replace(`import('@analogjs/content')`, "Promise.resolve({})") };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
...contentDiscoveryPlugins
|
|
94
|
+
];
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
name: "analogjs-content-frontmatter",
|
|
98
|
+
transform: {
|
|
99
|
+
filter: { id: /analog-content-list=true/ },
|
|
100
|
+
async handler(code, id) {
|
|
101
|
+
const cachedContent = cache.get(id);
|
|
102
|
+
if (cachedContent?.code === code) return {
|
|
103
|
+
code: `export default ${cachedContent.attributes}`,
|
|
104
|
+
moduleSideEffects: false
|
|
105
|
+
};
|
|
106
|
+
const fm = await import("front-matter");
|
|
107
|
+
const { attributes } = (fm.default || fm)(readFileSync(id.split("?")[0], "utf8"));
|
|
108
|
+
const content = {
|
|
109
|
+
code,
|
|
110
|
+
attributes: JSON.stringify(attributes)
|
|
111
|
+
};
|
|
112
|
+
cache.set(id, content);
|
|
113
|
+
return {
|
|
114
|
+
code: `export default ${content.attributes}`,
|
|
115
|
+
moduleSideEffects: false
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "analogjs-content-file",
|
|
122
|
+
enforce: "post",
|
|
123
|
+
async load(id) {
|
|
124
|
+
if (!id.includes("analog-content-file=true")) return;
|
|
125
|
+
if (!markedHighlighter) if (highlighter === "shiki") {
|
|
126
|
+
const { getShikiHighlighter } = await import("./content/shiki/index.js");
|
|
127
|
+
markedHighlighter = getShikiHighlighter(shikiOptions);
|
|
128
|
+
} else {
|
|
129
|
+
const { getPrismHighlighter } = await import("./content/prism/index.js");
|
|
130
|
+
markedHighlighter = getPrismHighlighter();
|
|
131
|
+
const langs = [
|
|
132
|
+
"bash",
|
|
133
|
+
"css",
|
|
134
|
+
"javascript",
|
|
135
|
+
"json",
|
|
136
|
+
"markup",
|
|
137
|
+
"typescript"
|
|
138
|
+
];
|
|
139
|
+
if (Array.isArray(prismOptions?.additionalLangs) && prismOptions?.additionalLangs?.length > 0) langs.push(...prismOptions.additionalLangs);
|
|
140
|
+
(await import("prismjs/components/index.js")).default(langs);
|
|
141
|
+
}
|
|
142
|
+
const fm = await import("front-matter");
|
|
143
|
+
const { body, frontmatter } = (fm.default || fm)(readFileSync(id.split("?")[0], "utf8"));
|
|
144
|
+
const { getMarkedSetup } = await import("./content/marked/index.js");
|
|
145
|
+
const mdContent = await getMarkedSetup({
|
|
146
|
+
mangle: true,
|
|
147
|
+
...markedOptions || {}
|
|
148
|
+
}, markedHighlighter).getMarkedInstance().parse(body);
|
|
149
|
+
return `export default ${JSON.stringify(`---\n${frontmatter}\n---\n\n${mdContent}`)}`;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
...contentDiscoveryPlugins
|
|
153
|
+
];
|
|
197
154
|
}
|
|
198
|
-
//#
|
|
155
|
+
//#endregion
|
|
156
|
+
export { contentPlugin };
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=content-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-plugin.js","names":[],"sources":["../../../../../packages/platform/src/lib/content-plugin.ts"],"sourcesContent":["import * as vite from 'vite';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { globSync } from 'tinyglobby';\n\nimport type { WithShikiHighlighterOptions } from './content/shiki/options.js';\nimport type { MarkedContentHighlighter } from './content/marked/marked-content-highlighter.js';\nimport type { WithPrismHighlighterOptions } from './content/prism/options.js';\nimport type { WithMarkedOptions } from './content/marked/index.js';\nimport type { Options } from './options.js';\nimport { getBundleOptionsKey } from './utils/rolldown.js';\n\ninterface Content {\n code: string;\n attributes: string;\n}\n\nexport type ContentPluginOptions = {\n highlighter?: 'shiki' | 'prism';\n markedOptions?: WithMarkedOptions;\n shikiOptions?: WithShikiHighlighterOptions;\n prismOptions?: WithPrismHighlighterOptions;\n};\n\n/**\n * Content plugin that provides markdown and content file processing for Analog.\n *\n * IMPORTANT: This plugin uses tinyglobby for file discovery.\n * Key pitfall with { dot: true }:\n * - Returns relative paths from cwd (e.g., \"apps/blog-app/src/content/...\")\n * - These paths CANNOT be used directly in ES module imports\n * - Relative paths without ./ or ../ are treated as package names\n * - Must convert to absolute paths for imports to work correctly\n */\nexport function contentPlugin(\n {\n highlighter,\n markedOptions,\n shikiOptions,\n prismOptions,\n }: ContentPluginOptions = {},\n options?: Options,\n): vite.Plugin[] {\n const cache = new Map<string, Content>();\n\n let markedHighlighter: MarkedContentHighlighter;\n const workspaceRoot = vite.normalizePath(\n options?.workspaceRoot ?? process.cwd(),\n );\n let config: vite.UserConfig;\n let root: string;\n\n const contentDiscoveryPlugins: vite.Plugin[] = [\n {\n name: 'analog-content-glob-routes',\n config(_config) {\n config = _config;\n root = vite.normalizePath(\n resolve(workspaceRoot, config.root || '.') || '.',\n );\n },\n // Vite 8 / Rolldown \"filtered transform\" — the `filter.code` string\n // tells the bundler to skip this handler entirely for modules whose\n // source does not contain the substring, avoiding unnecessary JS→Rust\n // round-trips. The inner `code.includes()` guard is kept for Vite 7\n // compat where filters are not evaluated by the bundler.\n transform: {\n filter: {\n code: 'ANALOG_CONTENT_FILE_LIST',\n },\n handler(code) {\n if (code.includes('ANALOG_CONTENT_FILE_LIST')) {\n const contentFilesList: string[] = globSync(\n [\n `${root}/src/content/**/*.md`,\n ...(options?.additionalContentDirs || []).map(\n (glob) => `${workspaceRoot}${glob}/**/*.md`,\n ),\n ],\n { dot: true },\n );\n\n const eagerImports: string[] = [];\n\n contentFilesList.forEach((module, index) => {\n // CRITICAL: tinyglobby returns relative paths like \"apps/blog-app/src/content/file.md\"\n // These MUST be converted to absolute paths for ES module imports\n // Otherwise Node.js treats \"apps\" as a package name and throws \"Cannot find package 'apps'\"\n const absolutePath = module.startsWith('/')\n ? module\n : `${workspaceRoot}/${module}`;\n eagerImports.push(\n `import { default as analog_module_${index} } from \"${absolutePath}?analog-content-list=true\";`,\n );\n });\n\n let result = code.replace(\n 'const ANALOG_CONTENT_FILE_LIST = {};',\n `\n let ANALOG_CONTENT_FILE_LIST = {${contentFilesList.map(\n (module, index) =>\n `\"${module.replace(root, '')}\": analog_module_${index}`,\n )}};\n `,\n );\n\n if (!code.includes('analog_module_')) {\n result = `${eagerImports.join('\\n')}\\n${result}`;\n }\n\n return {\n code: result,\n map: { mappings: '' },\n };\n }\n\n return;\n },\n },\n },\n {\n name: 'analogjs-invalidate-content-dirs',\n configureServer(server) {\n function invalidateContent(path: string) {\n if (path.includes(vite.normalizePath(`/content/`))) {\n server.moduleGraph.fileToModulesMap.forEach((mods) => {\n mods.forEach((mod) => {\n if (\n mod.id?.includes('analogjs') &&\n mod.id?.includes('content')\n ) {\n server.moduleGraph.invalidateModule(mod);\n\n mod.importers.forEach((imp) => {\n server.moduleGraph.invalidateModule(imp);\n });\n }\n });\n });\n\n server.ws.send({\n type: 'full-reload',\n });\n }\n }\n\n server.watcher.on('add', invalidateContent);\n server.watcher.on('unlink', invalidateContent);\n },\n },\n ];\n\n if (!highlighter) {\n return [\n {\n name: 'analogjs-external-content',\n config() {\n const bundleOptionsKey = getBundleOptionsKey();\n return {\n build: {\n [bundleOptionsKey]: {\n external: ['@analogjs/content'],\n },\n },\n };\n },\n },\n {\n name: 'analogjs-exclude-content-import',\n transform: {\n filter: {\n code: '@analogjs/content',\n },\n handler(code) {\n /**\n * Remove the package so it doesn't get\n * referenced when building for serverless\n * functions.\n */\n if (code.includes(`import('@analogjs/content')`)) {\n return {\n code: code.replace(\n `import('@analogjs/content')`,\n 'Promise.resolve({})',\n ),\n };\n }\n\n return;\n },\n },\n },\n ...contentDiscoveryPlugins,\n ];\n }\n\n return [\n {\n name: 'analogjs-content-frontmatter',\n // Filter by module ID so only `?analog-content-list=true` virtual\n // imports enter the handler. Returns `moduleSideEffects: false` so\n // Rolldown can tree-shake unused content list entries.\n transform: {\n filter: {\n id: /analog-content-list=true/,\n },\n async handler(code, id) {\n const cachedContent = cache.get(id);\n // There's no reason to run `readFileSync` and frontmatter parsing if the\n // `transform` hook is called with the same code. In such cases, we can simply\n // return the cached attributes, which is faster than repeatedly reading files\n // synchronously during the build process.\n if (cachedContent?.code === code) {\n return {\n code: `export default ${cachedContent.attributes}`,\n moduleSideEffects: false,\n };\n }\n\n const fm: any = await import('front-matter');\n // The `default` property will be available in CommonJS environment, for instance,\n // when running unit tests. It's safe to retrieve `default` first, since we still\n // fallback to the original implementation.\n const frontmatter = fm.default || fm;\n const fileContents = readFileSync(id.split('?')[0], 'utf8');\n const { attributes } = frontmatter(fileContents);\n const content = {\n code,\n attributes: JSON.stringify(attributes),\n };\n cache.set(id, content);\n\n return {\n code: `export default ${content.attributes}`,\n moduleSideEffects: false,\n };\n },\n },\n },\n {\n name: 'analogjs-content-file',\n enforce: 'post',\n async load(id) {\n if (!id.includes('analog-content-file=true')) {\n return;\n }\n\n if (!markedHighlighter) {\n if (highlighter === 'shiki') {\n const { getShikiHighlighter } =\n await import('./content/shiki/index.js');\n markedHighlighter = getShikiHighlighter(shikiOptions);\n } else {\n const { getPrismHighlighter } =\n await import('./content/prism/index.js');\n markedHighlighter = getPrismHighlighter();\n\n const langs = [\n 'bash',\n 'css',\n 'javascript',\n 'json',\n 'markup',\n 'typescript',\n ];\n\n if (\n Array.isArray(prismOptions?.additionalLangs) &&\n prismOptions?.additionalLangs?.length > 0\n ) {\n langs.push(...prismOptions.additionalLangs);\n }\n\n const loadLanguages = await import('prismjs/components/index.js');\n\n (\n loadLanguages as unknown as { default: (...args: any[]) => any }\n ).default(langs);\n }\n }\n\n const fm: any = await import('front-matter');\n // The `default` property will be available in CommonJS environment, for instance,\n // when running unit tests. It's safe to retrieve `default` first, since we still\n // fallback to the original implementation.\n const frontmatterFn = fm.default || fm;\n const fileContents = readFileSync(id.split('?')[0], 'utf8');\n const { body, frontmatter } = frontmatterFn(fileContents);\n\n // parse markdown and highlight\n const { getMarkedSetup } = await import('./content/marked/index.js');\n const markedSetupService = getMarkedSetup(\n { mangle: true, ...(markedOptions || {}) },\n markedHighlighter,\n );\n const mdContent = (await markedSetupService\n .getMarkedInstance()\n .parse(body)) as unknown as string;\n\n return `export default ${JSON.stringify(\n `---\\n${frontmatter}\\n---\\n\\n${mdContent}`,\n )}`;\n },\n },\n ...contentDiscoveryPlugins,\n ];\n}\n"],"mappings":";;;;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|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
name: 'analogjs-auto-discover-deps',
|
|
69
|
-
async config(config, { command }) {
|
|
70
|
-
const pkgConfig = await crawlFrameworkPkgs({
|
|
71
|
-
root: workspaceRoot,
|
|
72
|
-
isBuild: command === 'build',
|
|
73
|
-
viteUserConfig: config,
|
|
74
|
-
isSemiFrameworkPkgByJson(pkgJson) {
|
|
75
|
-
return pkgJson['module'] && pkgJson['module'].includes('fesm');
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
return pkgConfig;
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
];
|
|
1
|
+
import { getJsTransformConfigKey } from "./utils/rolldown.js";
|
|
2
|
+
import { VERSION } from "@angular/compiler-cli";
|
|
3
|
+
import { crawlFrameworkPkgs } from "vitefu";
|
|
4
|
+
//#region packages/platform/src/lib/deps-plugin.ts
|
|
5
|
+
function depsPlugin(options) {
|
|
6
|
+
const workspaceRoot = options?.workspaceRoot ?? process.cwd();
|
|
7
|
+
return [{
|
|
8
|
+
name: "analogjs-deps-plugin",
|
|
9
|
+
config() {
|
|
10
|
+
const transformConfig = options?.vite === false || options?.vite?.experimental?.useAngularCompilationAPI ? {} : { exclude: ["**/*.ts", "**/*.js"] };
|
|
11
|
+
return {
|
|
12
|
+
[getJsTransformConfigKey()]: transformConfig,
|
|
13
|
+
ssr: { noExternal: [
|
|
14
|
+
"@analogjs/**",
|
|
15
|
+
"firebase/**",
|
|
16
|
+
"firebase-admin/**",
|
|
17
|
+
"rxfire",
|
|
18
|
+
"@ng-web-apis/**",
|
|
19
|
+
"@taiga-ui/**",
|
|
20
|
+
"@tanstack/angular-query-experimental"
|
|
21
|
+
] },
|
|
22
|
+
optimizeDeps: {
|
|
23
|
+
include: [
|
|
24
|
+
"@angular/common",
|
|
25
|
+
"@angular/common/http",
|
|
26
|
+
...Number(VERSION.major) > 15 ? ["@angular/core/rxjs-interop"] : [],
|
|
27
|
+
"front-matter"
|
|
28
|
+
],
|
|
29
|
+
exclude: [
|
|
30
|
+
"@angular/platform-server",
|
|
31
|
+
"@analogjs/content",
|
|
32
|
+
"@analogjs/router",
|
|
33
|
+
"@nx/angular",
|
|
34
|
+
"@nx/vite",
|
|
35
|
+
"@nx/devkit",
|
|
36
|
+
"@nx/js",
|
|
37
|
+
"@nx/devkit",
|
|
38
|
+
"@nx/cypress",
|
|
39
|
+
"@nx/jest",
|
|
40
|
+
"@nx/js",
|
|
41
|
+
"@nx/eslint",
|
|
42
|
+
"@nx/webpack",
|
|
43
|
+
"@nx/web",
|
|
44
|
+
"@nx/workspace",
|
|
45
|
+
"@nx/eslint",
|
|
46
|
+
"@nx/module-federation",
|
|
47
|
+
"@nx/rspack",
|
|
48
|
+
"webpack",
|
|
49
|
+
"fsevents",
|
|
50
|
+
"nx"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
name: "analogjs-auto-discover-deps",
|
|
57
|
+
async config(config, { command }) {
|
|
58
|
+
return await crawlFrameworkPkgs({
|
|
59
|
+
root: workspaceRoot,
|
|
60
|
+
isBuild: command === "build",
|
|
61
|
+
viteUserConfig: config,
|
|
62
|
+
isSemiFrameworkPkgByJson(pkgJson) {
|
|
63
|
+
return pkgJson["module"] && pkgJson["module"].includes("fesm");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}];
|
|
82
68
|
}
|
|
83
|
-
//#
|
|
69
|
+
//#endregion
|
|
70
|
+
export { depsPlugin };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=deps-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deps-plugin.js","names":[],"sources":["../../../../../packages/platform/src/lib/deps-plugin.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport type { Plugin } from 'vite';\nimport * as vite from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nimport { Options } from './options.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function depsPlugin(options?: Options): Plugin[] {\n const workspaceRoot = options?.workspaceRoot ?? process.cwd();\n\n return [\n {\n name: 'analogjs-deps-plugin',\n config() {\n const transformConfig =\n options?.vite === false ||\n options?.vite?.experimental?.useAngularCompilationAPI\n ? {}\n : { exclude: ['**/*.ts', '**/*.js'] };\n\n return {\n [getJsTransformConfigKey()]: transformConfig,\n ssr: {\n noExternal: [\n '@analogjs/**',\n 'firebase/**',\n 'firebase-admin/**',\n 'rxfire',\n '@ng-web-apis/**',\n '@taiga-ui/**',\n '@tanstack/angular-query-experimental',\n ],\n },\n optimizeDeps: {\n include: [\n '@angular/common',\n '@angular/common/http',\n ...(Number(VERSION.major) > 15\n ? ['@angular/core/rxjs-interop']\n : []),\n 'front-matter',\n ],\n exclude: [\n '@angular/platform-server',\n '@analogjs/content',\n '@analogjs/router',\n '@nx/angular',\n '@nx/vite',\n '@nx/devkit',\n '@nx/js',\n '@nx/devkit',\n '@nx/cypress',\n '@nx/jest',\n '@nx/js',\n '@nx/eslint',\n '@nx/webpack',\n '@nx/web',\n '@nx/workspace',\n '@nx/eslint',\n '@nx/module-federation',\n '@nx/rspack',\n 'webpack',\n 'fsevents',\n 'nx',\n ],\n },\n };\n },\n },\n {\n name: 'analogjs-auto-discover-deps',\n async config(config, { command }) {\n const pkgConfig = await crawlFrameworkPkgs({\n root: workspaceRoot,\n isBuild: command === 'build',\n viteUserConfig: config,\n isSemiFrameworkPkgByJson(pkgJson) {\n return pkgJson['module'] && pkgJson['module'].includes('fesm');\n },\n });\n return pkgConfig;\n },\n },\n ];\n}\n"],"mappings":";;;;AAQA,SAAgB,WAAW,SAA6B;CACtD,MAAM,gBAAgB,SAAS,iBAAiB,QAAQ,KAAK;AAE7D,QAAO,CACL;EACE,MAAM;EACN,SAAS;GACP,MAAM,kBACJ,SAAS,SAAS,SAClB,SAAS,MAAM,cAAc,2BACzB,EAAE,GACF,EAAE,SAAS,CAAC,WAAW,UAAU,EAAE;AAEzC,UAAO;KACJ,yBAAyB,GAAG;IAC7B,KAAK,EACH,YAAY;KACV;KACA;KACA;KACA;KACA;KACA;KACA;KACD,EACF;IACD,cAAc;KACZ,SAAS;MACP;MACA;MACA,GAAI,OAAO,QAAQ,MAAM,GAAG,KACxB,CAAC,6BAA6B,GAC9B,EAAE;MACN;MACD;KACD,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD;KACF;IACF;;EAEJ,EACD;EACE,MAAM;EACN,MAAM,OAAO,QAAQ,EAAE,WAAW;AAShC,UARkB,MAAM,mBAAmB;IACzC,MAAM;IACN,SAAS,YAAY;IACrB,gBAAgB;IAChB,yBAAyB,SAAS;AAChC,YAAO,QAAQ,aAAa,QAAQ,UAAU,SAAS,OAAO;;IAEjE,CAAC;;EAGL,CACF"}
|