@analogjs/astro-angular 2.7.0-beta.1 → 2.7.0-beta.3
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 +2 -2
- package/src/index.d.ts.map +1 -1
- package/src/index.js +32 -5
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/astro-angular",
|
|
3
|
-
"version": "2.7.0-beta.
|
|
3
|
+
"version": "2.7.0-beta.3",
|
|
4
4
|
"description": "Use Angular components within Astro",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Brandon Roberts <robertsbt@gmail.com>",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"url": "https://github.com/sponsors/brandonroberts"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@analogjs/vite-plugin-angular": "^2.7.0-beta.
|
|
37
|
+
"@analogjs/vite-plugin-angular": "^2.7.0-beta.3",
|
|
38
38
|
"rehype": "^13.0.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/astro-angular/src/index.ts"],"names":[],"mappings":"AACA,OAAoB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,KAAK,EAAE,gBAAgB,EAAiC,MAAM,OAAO,CAAC;AAE7E,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/astro-angular/src/index.ts"],"names":[],"mappings":"AACA,OAAoB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,KAAK,EAAE,gBAAgB,EAAiC,MAAM,OAAO,CAAC;AAE7E,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAwGD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAyBnE"}
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,19 @@ function getRenderer(ngHydration) {
|
|
|
12
12
|
: '@analogjs/astro-angular/server.js',
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
const SERVER_ENTRYPOINTS = [
|
|
16
|
+
'@angular/platform-server',
|
|
17
|
+
'@analogjs/astro-angular/server.js',
|
|
18
|
+
'@analogjs/astro-angular/server-ngh.js',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Modules the dependency optimizer must leave alone on the server.
|
|
22
|
+
* `@angular/core` is excluded on top of the server entrypoints because
|
|
23
|
+
* pre-bundling it produces a second copy of the Angular runtime, so components
|
|
24
|
+
* render against a different runtime than the one they were registered in —
|
|
25
|
+
* surfacing as empty SSR output plus `NG0912` component ID collisions.
|
|
26
|
+
*/
|
|
27
|
+
const SERVER_OPTIMIZE_DEPS_EXCLUDE = [...SERVER_ENTRYPOINTS, '@angular/core'];
|
|
15
28
|
function getViteConfiguration(options) {
|
|
16
29
|
return {
|
|
17
30
|
esbuild: {
|
|
@@ -25,11 +38,7 @@ function getViteConfiguration(options) {
|
|
|
25
38
|
? '@analogjs/astro-angular/client-ngh.js'
|
|
26
39
|
: '@analogjs/astro-angular/client.js',
|
|
27
40
|
],
|
|
28
|
-
exclude:
|
|
29
|
-
'@angular/platform-server',
|
|
30
|
-
'@analogjs/astro-angular/server.js',
|
|
31
|
-
'@analogjs/astro-angular/server-ngh.js',
|
|
32
|
-
],
|
|
41
|
+
exclude: SERVER_ENTRYPOINTS,
|
|
33
42
|
},
|
|
34
43
|
plugins: [
|
|
35
44
|
viteAngular(options?.vite),
|
|
@@ -58,6 +67,24 @@ function getViteConfiguration(options) {
|
|
|
58
67
|
return undefined;
|
|
59
68
|
},
|
|
60
69
|
},
|
|
70
|
+
{
|
|
71
|
+
// Top-level `optimizeDeps` only seeds the client environment. Adapters
|
|
72
|
+
// that run SSR in their own environment — `@astrojs/cloudflare`, which
|
|
73
|
+
// serves the `ssr` environment on `workerd` — get none of the excludes
|
|
74
|
+
// above, so Angular's server entrypoints are pre-bundled there and the
|
|
75
|
+
// renderer breaks. Re-declare them per server environment.
|
|
76
|
+
name: 'analogjs-astro-server-optimize-deps',
|
|
77
|
+
configEnvironment(name) {
|
|
78
|
+
if (name === 'client') {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
optimizeDeps: {
|
|
83
|
+
exclude: SERVER_OPTIMIZE_DEPS_EXCLUDE,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
},
|
|
61
88
|
],
|
|
62
89
|
ssr: {
|
|
63
90
|
noExternal: ['@angular/**', '@analogjs/**'],
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/astro-angular/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,WAA8B,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkB/C,SAAS,WAAW,CAAC,WAAgC;IACnD,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,gBAAgB,EAAE,WAAW;YAC3B,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,mCAAmC;QACvC,gBAAgB,EAAE,WAAW;YAC3B,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,mCAAmC;KACxC,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAwB;IACpD,OAAO;QACL,OAAO,EAAE;YACP,MAAM,EAAE,IAAI;SACb;QACD,YAAY,EAAE;YACZ,OAAO,EAAE;gBACP,2BAA2B;gBAC3B,eAAe;gBACf,OAAO,EAAE,mBAAmB;oBAC1B,CAAC,CAAC,uCAAuC;oBACzC,CAAC,CAAC,mCAAmC;aACxC;YACD,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/astro-angular/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,WAA8B,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkB/C,SAAS,WAAW,CAAC,WAAgC;IACnD,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,gBAAgB,EAAE,WAAW;YAC3B,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,mCAAmC;QACvC,gBAAgB,EAAE,WAAW;YAC3B,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,mCAAmC;KACxC,CAAC;AACJ,CAAC;AAED,MAAM,kBAAkB,GAAG;IACzB,0BAA0B;IAC1B,mCAAmC;IACnC,uCAAuC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,4BAA4B,GAAG,CAAC,GAAG,kBAAkB,EAAE,eAAe,CAAC,CAAC;AAE9E,SAAS,oBAAoB,CAAC,OAAwB;IACpD,OAAO;QACL,OAAO,EAAE;YACP,MAAM,EAAE,IAAI;SACb;QACD,YAAY,EAAE;YACZ,OAAO,EAAE;gBACP,2BAA2B;gBAC3B,eAAe;gBACf,OAAO,EAAE,mBAAmB;oBAC1B,CAAC,CAAC,uCAAuC;oBACzC,CAAC,CAAC,mCAAmC;aACxC;YACD,OAAO,EAAE,kBAAkB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AoB,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE,EAAE;gBACrE,WAAW,CAAC,WAAW,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;gBACvD,YAAY,CAAC;oBACX,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC;iBACpC,CAAC,CAAC;gBACH,IAAI,OAAO,EAAE,oBAAoB,EAAE,CAAC;oBAClC,aAAa,CAAC;wBACZ,KAAK,EAAE,KAAK;wBACZ,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;qBAClE,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,mBAAmB,EAAE,GAAG,EAAE;gBACxB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY,EAAE,CAAC;oBAC7C,cAAc,EAAE,CAAC;gBACnB,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { fileURLToPath } from 'node:url';\nimport viteAngular, { PluginOptions } from '@analogjs/vite-plugin-angular';\nimport { enableProdMode } from '@angular/core';\nimport type { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro';\n\ninterface AngularOptions {\n vite?: PluginOptions;\n /**\n * Enable stricter rendering, which ensures Angular style tags are added to the document head instead of next to the\n * component in the body.\n *\n * Enabling this option disables astro's streaming under SSR.\n */\n strictStylePlacement?: boolean;\n /**\n * Use Angular's `provideClientHydration` to hydrate components.\n */\n useAngularHydration?: boolean;\n}\n\nfunction getRenderer(ngHydration: boolean | undefined): AstroRenderer {\n return {\n name: '@analogjs/astro-angular',\n clientEntrypoint: ngHydration\n ? '@analogjs/astro-angular/client-ngh.js'\n : '@analogjs/astro-angular/client.js',\n serverEntrypoint: ngHydration\n ? '@analogjs/astro-angular/server-ngh.js'\n : '@analogjs/astro-angular/server.js',\n };\n}\n\nconst SERVER_ENTRYPOINTS = [\n '@angular/platform-server',\n '@analogjs/astro-angular/server.js',\n '@analogjs/astro-angular/server-ngh.js',\n];\n\n/**\n * Modules the dependency optimizer must leave alone on the server.\n * `@angular/core` is excluded on top of the server entrypoints because\n * pre-bundling it produces a second copy of the Angular runtime, so components\n * render against a different runtime than the one they were registered in —\n * surfacing as empty SSR output plus `NG0912` component ID collisions.\n */\nconst SERVER_OPTIMIZE_DEPS_EXCLUDE = [...SERVER_ENTRYPOINTS, '@angular/core'];\n\nfunction getViteConfiguration(options?: AngularOptions): ViteUserConfig {\n return {\n esbuild: {\n jsxDev: true,\n },\n optimizeDeps: {\n include: [\n '@angular/platform-browser',\n '@angular/core',\n options?.useAngularHydration\n ? '@analogjs/astro-angular/client-ngh.js'\n : '@analogjs/astro-angular/client.js',\n ],\n exclude: SERVER_ENTRYPOINTS,\n },\n\n plugins: [\n viteAngular(options?.vite),\n {\n name: '@analogjs/astro-angular-platform-server',\n transform(code: string, id: string) {\n if (id.includes('platform-server')) {\n code = code.replace(/global\\./g, 'globalThis.');\n\n return {\n code: code.replace(\n 'new xhr2.XMLHttpRequest',\n 'new (xhr2.default.XMLHttpRequest || xhr2.default)',\n ),\n };\n }\n\n return;\n },\n },\n {\n name: 'analogjs-astro-client-ngservermode',\n configEnvironment(name: string) {\n if (name === 'client') {\n return {\n define: {\n ngServerMode: 'false',\n },\n };\n }\n\n return undefined;\n },\n },\n {\n // Top-level `optimizeDeps` only seeds the client environment. Adapters\n // that run SSR in their own environment — `@astrojs/cloudflare`, which\n // serves the `ssr` environment on `workerd` — get none of the excludes\n // above, so Angular's server entrypoints are pre-bundled there and the\n // renderer breaks. Re-declare them per server environment.\n name: 'analogjs-astro-server-optimize-deps',\n configEnvironment(name: string) {\n if (name === 'client') {\n return undefined;\n }\n\n return {\n optimizeDeps: {\n exclude: SERVER_OPTIMIZE_DEPS_EXCLUDE,\n },\n };\n },\n },\n ],\n ssr: {\n noExternal: ['@angular/**', '@analogjs/**'],\n },\n };\n}\n\nexport default function (options?: AngularOptions): AstroIntegration {\n process.env['ANALOG_ASTRO'] = 'true';\n\n return {\n name: '@analogjs/astro-angular',\n hooks: {\n 'astro:config:setup': ({ addRenderer, updateConfig, addMiddleware }) => {\n addRenderer(getRenderer(options?.useAngularHydration));\n updateConfig({\n vite: getViteConfiguration(options),\n });\n if (options?.strictStylePlacement) {\n addMiddleware({\n order: 'pre',\n entrypoint: fileURLToPath(import.meta.resolve('./middleware.js')),\n });\n }\n },\n 'astro:config:done': () => {\n if (process.env['NODE_ENV'] === 'production') {\n enableProdMode();\n }\n },\n },\n };\n}\n"]}
|