weg-shared-layout 0.0.27 → 0.0.29
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/LICENSE +21 -21
- package/dist/cjs/weg-footer_2.cjs.entry.js +7 -7
- package/dist/collection/components/weg-footer/icons/instagram.svg +5 -5
- package/dist/collection/components/weg-footer/icons/linkedin.svg +3 -3
- package/dist/collection/components/weg-footer/icons/tiktok.svg +3 -3
- package/dist/collection/components/weg-footer/icons/youtube.svg +4 -4
- package/dist/collection/components/weg-footer/weg-footer.css +263 -270
- package/dist/collection/components/weg-footer/weg-footer.js +2 -2
- package/dist/collection/components/weg-header/weg-header.css +491 -474
- package/dist/collection/components/weg-header/weg-header.js +4 -4
- package/dist/collection/styles/shared.css +96 -72
- package/dist/components/weg-footer.js +1 -1
- package/dist/components/weg-header.js +1 -1
- package/dist/esm/weg-footer_2.entry.js +7 -7
- package/dist/weg-shared-layout/p-ded6ae1c.entry.js +1 -0
- package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
- package/docs/README.md +51 -51
- package/docs/angular-16-compatibility.md +250 -250
- package/docs/angular-integration-guide.md +1035 -1035
- package/docs/angular.md +258 -258
- package/docs/nextjs.md +314 -314
- package/docs/publishing.md +65 -65
- package/docs/react.md +272 -272
- package/docs/vanilla.md +139 -139
- package/package.json +81 -79
- package/readme.md +97 -96
- package/src/constants/breakpoints.ts +7 -7
- package/src/styles/container.css +53 -0
- package/dist/weg-shared-layout/p-e6eadfa1.entry.js +0 -1
- /package/dist/types/Users/{tan/Documents/code → rakin/Documents/WEG/repos}/weg-shared-layout/.stencil/test-utils/axe.d.ts +0 -0
- /package/dist/types/Users/{tan/Documents/code → rakin/Documents/WEG/repos}/weg-shared-layout/.stencil/test-utils/viewport.d.ts +0 -0
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
# Angular 16 compatibility
|
|
2
|
-
|
|
3
|
-
Guide for teams on **Angular 16** who see TypeScript errors from `weg-shared-layout` in `node_modules`, or who cannot resolve subpath imports like `weg-shared-layout/weg-header`.
|
|
4
|
-
|
|
5
|
-
| Doc | Use when |
|
|
6
|
-
| --- | --- |
|
|
7
|
-
| **[angular-integration-guide.md](./angular-integration-guide.md)** | Full integration steps |
|
|
8
|
-
| **[angular.md](./angular.md)** | Quick start |
|
|
9
|
-
| **[demo/angular16/README.md](../demo/angular16/README.md)** | Copy-paste Angular 16 app (npm-style imports) |
|
|
10
|
-
| **This doc** | `stencil-public-runtime.d.ts` / `Mixin<const …>` errors, subpath import resolution, layout typing on TS 4.9 |
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Short answers
|
|
15
|
-
|
|
16
|
-
### Is `src/types/layout-data.ts` using `type` the problem?
|
|
17
|
-
|
|
18
|
-
**No.** Those definitions compile to plain `.d.ts` shapes. They do not use TypeScript 5-only syntax.
|
|
19
|
-
|
|
20
|
-
The errors you see point at **`node_modules/weg-shared-layout/dist/types/stencil-public-runtime.d.ts`**. That file is **generated by Stencil** when the package is built, not authored from `layout-data.ts`.
|
|
21
|
-
|
|
22
|
-
### Can we switch to `interface` or `class` instead?
|
|
23
|
-
|
|
24
|
-
You can use **`interface`** in your **Angular app** for the same fields (see [Layout types in your app](#layout-types-in-your-app)). Changing the library from `type` to `interface` **does not fix** the Stencil `Mixin<const …>` errors, because Angular still type-checks (or parses) Stencil’s runtime declarations when you import from the package entry or component subpaths that pull in `components.d.ts`.
|
|
25
|
-
|
|
26
|
-
**`class`** is not a good fit here: layout payloads are JSON-shaped data, not class instances.
|
|
27
|
-
|
|
28
|
-
String unions (e.g. `'sign-in' | 'sign-out'`) must stay as **`type` aliases** in TypeScript; they cannot be expressed as interfaces.
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## Error 1: `Mixin<const TMixins …>` / TS1139 in `stencil-public-runtime.d.ts`
|
|
33
|
-
|
|
34
|
-
### What it means
|
|
35
|
-
|
|
36
|
-
Stencil 4.x ships declaration files that use **TypeScript 5.0+** features, including **`const` type parameters** on generics:
|
|
37
|
-
|
|
38
|
-
```ts
|
|
39
|
-
export declare function Mixin<const TMixins extends readonly MixinFactory[]>(...): …;
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
If your app uses **TypeScript 4.9.x** (common on Angular 16.0–16.1 without a manual upgrade), the compiler **cannot parse** that line and reports many follow-on errors (TS1139, TS1005, etc.).
|
|
43
|
-
|
|
44
|
-
This is unrelated to whether layout shapes are declared with `type`, `interface`, or `class`.
|
|
45
|
-
|
|
46
|
-
### Fix A (recommended): Enable `skipLibCheck`
|
|
47
|
-
|
|
48
|
-
In the Angular app’s root **`tsconfig.json`** (or `tsconfig.app.json` if that is where `compilerOptions` live):
|
|
49
|
-
|
|
50
|
-
```json
|
|
51
|
-
{
|
|
52
|
-
"compilerOptions": {
|
|
53
|
-
"skipLibCheck": true
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
This tells TypeScript to **skip type-checking of all `.d.ts` files**, including Stencil’s. Your app source is still checked; only third-party declarations are skipped.
|
|
59
|
-
|
|
60
|
-
Angular CLI **newer workspaces** often set this already. Older HeroJobs-style projects may have it **missing** — add it and rebuild.
|
|
61
|
-
|
|
62
|
-
### Fix B: Use TypeScript 5.0+ (within Angular 16’s range)
|
|
63
|
-
|
|
64
|
-
Angular **16.1+** supports TypeScript **`>=4.9.3` and `<5.2.0`**. Upgrade the app’s `typescript` devDependency to **5.0.x or 5.1.x** (match your exact `@angular/core` patch — see [Angular version compatibility](https://angular.dev/reference/versions)).
|
|
65
|
-
|
|
66
|
-
Example:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
npm i -D typescript@~5.1.6
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Then confirm:
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
npx tsc --version
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
You should see **5.0+**. The `const` type parameter syntax will parse correctly even without relying only on `skipLibCheck`.
|
|
79
|
-
|
|
80
|
-
### Fix C: Import layout types without the Stencil graph
|
|
81
|
-
|
|
82
|
-
If you only need **`LayoutData`** (and related names) and want to avoid pulling `components.d.ts` → `stencil-public-runtime.d.ts`, import from the **types-only** subpath (package **0.0.24+**, or current main after publish):
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
import type { LayoutData, LayoutHeaderAuthAction } from 'weg-shared-layout/layout-data';
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Requires **`moduleResolution`**: `"bundler"`, `"node16"`, or `"nodenext"` (see [Error 2](#error-2-cannot-find-module-weg-shared-layoutweg-header)). The `./layout-data` export is defined in this repo’s `package.json`; use a published version that includes it, or link the package locally while testing.
|
|
89
|
-
|
|
90
|
-
Alternatively, keep the existing pattern from the integration guide — no import from the package at all:
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
94
|
-
export type LayoutData = typeof layoutFixture;
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
That ties your app type to the fixture shape and never touches Stencil’s runtime `.d.ts` files.
|
|
98
|
-
|
|
99
|
-
### What we are not changing in the library (for now)
|
|
100
|
-
|
|
101
|
-
Replacing `type` with `interface` in `layout-data.ts` would be a **cosmetic** API change for consumers and **would not remove** `stencil-public-runtime.d.ts` from the published tarball. The durable fixes are **consumer `tsconfig`** (Fix A/B) or **types-only imports** (Fix C).
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
## Error 2: Cannot find module `weg-shared-layout/weg-header`
|
|
106
|
-
|
|
107
|
-
Typical message:
|
|
108
|
-
|
|
109
|
-
```text
|
|
110
|
-
Cannot find module or type declarations for side-effect import of 'weg-shared-layout/weg-header'.
|
|
111
|
-
There are types at '.../node_modules/weg-shared-layout/dist/components/weg-header.d.ts',
|
|
112
|
-
but this result could not be resolved under your current 'moduleResolution' setting.
|
|
113
|
-
Consider updating to 'node16', 'nodenext', or 'bundler'.
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### What it means
|
|
117
|
-
|
|
118
|
-
`weg-shared-layout` exposes components via the **`exports`** field in `package.json` (subpaths like `./weg-header`). **Classic** `"moduleResolution": "node"` (still common in Angular 16 apps) does **not** resolve those subpaths the same way, even when the `.d.ts` files exist on disk.
|
|
119
|
-
|
|
120
|
-
### Fix A (recommended): Use the Stencil loader
|
|
121
|
-
|
|
122
|
-
In **`src/main.ts`**, register all components **once before** `bootstrapApplication`:
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
126
|
-
|
|
127
|
-
defineCustomElements();
|
|
128
|
-
|
|
129
|
-
// then bootstrapApplication(...)
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
The loader path is documented in the main integration guide and avoids per-tag side-effect imports.
|
|
133
|
-
|
|
134
|
-
### Fix B: Modernize `moduleResolution`
|
|
135
|
-
|
|
136
|
-
In **`tsconfig.json`** (app root), set:
|
|
137
|
-
|
|
138
|
-
```json
|
|
139
|
-
{
|
|
140
|
-
"compilerOptions": {
|
|
141
|
-
"moduleResolution": "bundler"
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Angular **17+** schematics often use `bundler`. On **Angular 16**, `bundler` is supported by TypeScript 5.0+; with TS 4.9, prefer **`"node16"`** or **`"nodenext"`** if `bundler` is not available.
|
|
147
|
-
|
|
148
|
-
Then side-effect imports can work:
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
import 'weg-shared-layout/weg-header';
|
|
152
|
-
import 'weg-shared-layout/weg-footer';
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Use **one** registration strategy: loader **or** side-effect imports, not both.
|
|
156
|
-
|
|
157
|
-
### Fix C: Stay on loader only
|
|
158
|
-
|
|
159
|
-
If you cannot change `moduleResolution` (team policy, older tooling), **do not** use `import 'weg-shared-layout/weg-header'`. Use **`defineCustomElements()`** from `weg-shared-layout/loader` only.
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
## Layout types in your app
|
|
164
|
-
|
|
165
|
-
Three supported patterns (pick one):
|
|
166
|
-
|
|
167
|
-
| Pattern | Example | Stencil `.d.ts` pulled? |
|
|
168
|
-
| --- | --- | --- |
|
|
169
|
-
| **Fixture-derived type** (default in guides) | `export type LayoutData = typeof layoutFixture` | No (only JSON + your file) |
|
|
170
|
-
| **Package types subpath** | `import type { LayoutData } from 'weg-shared-layout/layout-data'` | No |
|
|
171
|
-
| **Local interfaces** | Copy shapes into `layout.types.ts` | No |
|
|
172
|
-
|
|
173
|
-
Example local interfaces (equivalent to package shapes; adjust if your API differs):
|
|
174
|
-
|
|
175
|
-
```ts
|
|
176
|
-
export interface LayoutLink {
|
|
177
|
-
label: string;
|
|
178
|
-
href?: string;
|
|
179
|
-
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
180
|
-
items?: LayoutLink[];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface LayoutHeaderData {
|
|
184
|
-
logoSrc?: string;
|
|
185
|
-
menu?: LayoutLink[];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export type LayoutHeaderAuthAction = 'sign-in' | 'sign-out';
|
|
189
|
-
|
|
190
|
-
export interface LayoutFooterSocialLink {
|
|
191
|
-
platform: 'LinkedIn' | 'Instagram' | 'TikTok' | 'YouTube';
|
|
192
|
-
href: string;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export interface LayoutFooterData {
|
|
196
|
-
menu?: LayoutLink[][];
|
|
197
|
-
social?: LayoutFooterSocialLink[];
|
|
198
|
-
credits?: string;
|
|
199
|
-
copyright?: string;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface LayoutData {
|
|
203
|
-
header?: Partial<LayoutHeaderData>;
|
|
204
|
-
footer?: Partial<LayoutFooterData>;
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## Recommended `tsconfig` snippet (Angular 16 + this package)
|
|
211
|
-
|
|
212
|
-
```json
|
|
213
|
-
{
|
|
214
|
-
"compilerOptions": {
|
|
215
|
-
"skipLibCheck": true,
|
|
216
|
-
"resolveJsonModule": true,
|
|
217
|
-
"moduleResolution": "bundler"
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
Use **`node16`** instead of **`bundler`** if you must stay on TypeScript 4.9.
|
|
223
|
-
|
|
224
|
-
Pair with **`defineCustomElements()`** in `main.ts` and **`CUSTOM_ELEMENTS_SCHEMA`** on the shell component — unchanged from the main integration guide.
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
## Checklist for HeroJobs / similar Angular 16 apps
|
|
229
|
-
|
|
230
|
-
1. Confirm TypeScript version: `npx tsc --version` (4.9 vs 5.x).
|
|
231
|
-
2. Add or verify **`skipLibCheck": true`**.
|
|
232
|
-
3. Set **`moduleResolution`** to `bundler` or `node16`, **or** switch to **`weg-shared-layout/loader`** only.
|
|
233
|
-
4. Prefer **`export type LayoutData = typeof layoutFixture`** or **`weg-shared-layout/layout-data`** for typing — avoid `import type { LayoutData } from 'weg-shared-layout'` if you still see Stencil errors and cannot use `skipLibCheck`.
|
|
234
|
-
5. Rebuild: `ng build` / CI pipeline.
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## In-repo Angular 16 demo
|
|
239
|
-
|
|
240
|
-
Runnable app: **[demo/angular16/README.md](../demo/angular16/README.md)** — same imports as a published npm install (`weg-shared-layout/dummy-data.json`, `weg-shared-layout/loader`); only the `package.json` dependency line differs (`file:../..` vs `^0.0.x`). Run with `npm run demo:angular16` from repo root.
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
## Related
|
|
245
|
-
|
|
246
|
-
- [Documentation index](./README.md)
|
|
247
|
-
- [Angular integration guide](./angular-integration-guide.md)
|
|
248
|
-
- [Angular quick start](./angular.md)
|
|
249
|
-
- [In-repo Angular 16 demo](../demo/angular16/README.md)
|
|
250
|
-
- [Publishing](./publishing.md)
|
|
1
|
+
# Angular 16 compatibility
|
|
2
|
+
|
|
3
|
+
Guide for teams on **Angular 16** who see TypeScript errors from `weg-shared-layout` in `node_modules`, or who cannot resolve subpath imports like `weg-shared-layout/weg-header`.
|
|
4
|
+
|
|
5
|
+
| Doc | Use when |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| **[angular-integration-guide.md](./angular-integration-guide.md)** | Full integration steps |
|
|
8
|
+
| **[angular.md](./angular.md)** | Quick start |
|
|
9
|
+
| **[demo/angular16/README.md](../demo/angular16/README.md)** | Copy-paste Angular 16 app (npm-style imports) |
|
|
10
|
+
| **This doc** | `stencil-public-runtime.d.ts` / `Mixin<const …>` errors, subpath import resolution, layout typing on TS 4.9 |
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Short answers
|
|
15
|
+
|
|
16
|
+
### Is `src/types/layout-data.ts` using `type` the problem?
|
|
17
|
+
|
|
18
|
+
**No.** Those definitions compile to plain `.d.ts` shapes. They do not use TypeScript 5-only syntax.
|
|
19
|
+
|
|
20
|
+
The errors you see point at **`node_modules/weg-shared-layout/dist/types/stencil-public-runtime.d.ts`**. That file is **generated by Stencil** when the package is built, not authored from `layout-data.ts`.
|
|
21
|
+
|
|
22
|
+
### Can we switch to `interface` or `class` instead?
|
|
23
|
+
|
|
24
|
+
You can use **`interface`** in your **Angular app** for the same fields (see [Layout types in your app](#layout-types-in-your-app)). Changing the library from `type` to `interface` **does not fix** the Stencil `Mixin<const …>` errors, because Angular still type-checks (or parses) Stencil’s runtime declarations when you import from the package entry or component subpaths that pull in `components.d.ts`.
|
|
25
|
+
|
|
26
|
+
**`class`** is not a good fit here: layout payloads are JSON-shaped data, not class instances.
|
|
27
|
+
|
|
28
|
+
String unions (e.g. `'sign-in' | 'sign-out'`) must stay as **`type` aliases** in TypeScript; they cannot be expressed as interfaces.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Error 1: `Mixin<const TMixins …>` / TS1139 in `stencil-public-runtime.d.ts`
|
|
33
|
+
|
|
34
|
+
### What it means
|
|
35
|
+
|
|
36
|
+
Stencil 4.x ships declaration files that use **TypeScript 5.0+** features, including **`const` type parameters** on generics:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
export declare function Mixin<const TMixins extends readonly MixinFactory[]>(...): …;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If your app uses **TypeScript 4.9.x** (common on Angular 16.0–16.1 without a manual upgrade), the compiler **cannot parse** that line and reports many follow-on errors (TS1139, TS1005, etc.).
|
|
43
|
+
|
|
44
|
+
This is unrelated to whether layout shapes are declared with `type`, `interface`, or `class`.
|
|
45
|
+
|
|
46
|
+
### Fix A (recommended): Enable `skipLibCheck`
|
|
47
|
+
|
|
48
|
+
In the Angular app’s root **`tsconfig.json`** (or `tsconfig.app.json` if that is where `compilerOptions` live):
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"compilerOptions": {
|
|
53
|
+
"skipLibCheck": true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This tells TypeScript to **skip type-checking of all `.d.ts` files**, including Stencil’s. Your app source is still checked; only third-party declarations are skipped.
|
|
59
|
+
|
|
60
|
+
Angular CLI **newer workspaces** often set this already. Older HeroJobs-style projects may have it **missing** — add it and rebuild.
|
|
61
|
+
|
|
62
|
+
### Fix B: Use TypeScript 5.0+ (within Angular 16’s range)
|
|
63
|
+
|
|
64
|
+
Angular **16.1+** supports TypeScript **`>=4.9.3` and `<5.2.0`**. Upgrade the app’s `typescript` devDependency to **5.0.x or 5.1.x** (match your exact `@angular/core` patch — see [Angular version compatibility](https://angular.dev/reference/versions)).
|
|
65
|
+
|
|
66
|
+
Example:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm i -D typescript@~5.1.6
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Then confirm:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx tsc --version
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
You should see **5.0+**. The `const` type parameter syntax will parse correctly even without relying only on `skipLibCheck`.
|
|
79
|
+
|
|
80
|
+
### Fix C: Import layout types without the Stencil graph
|
|
81
|
+
|
|
82
|
+
If you only need **`LayoutData`** (and related names) and want to avoid pulling `components.d.ts` → `stencil-public-runtime.d.ts`, import from the **types-only** subpath (package **0.0.24+**, or current main after publish):
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import type { LayoutData, LayoutHeaderAuthAction } from 'weg-shared-layout/layout-data';
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Requires **`moduleResolution`**: `"bundler"`, `"node16"`, or `"nodenext"` (see [Error 2](#error-2-cannot-find-module-weg-shared-layoutweg-header)). The `./layout-data` export is defined in this repo’s `package.json`; use a published version that includes it, or link the package locally while testing.
|
|
89
|
+
|
|
90
|
+
Alternatively, keep the existing pattern from the integration guide — no import from the package at all:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
94
|
+
export type LayoutData = typeof layoutFixture;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
That ties your app type to the fixture shape and never touches Stencil’s runtime `.d.ts` files.
|
|
98
|
+
|
|
99
|
+
### What we are not changing in the library (for now)
|
|
100
|
+
|
|
101
|
+
Replacing `type` with `interface` in `layout-data.ts` would be a **cosmetic** API change for consumers and **would not remove** `stencil-public-runtime.d.ts` from the published tarball. The durable fixes are **consumer `tsconfig`** (Fix A/B) or **types-only imports** (Fix C).
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Error 2: Cannot find module `weg-shared-layout/weg-header`
|
|
106
|
+
|
|
107
|
+
Typical message:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
Cannot find module or type declarations for side-effect import of 'weg-shared-layout/weg-header'.
|
|
111
|
+
There are types at '.../node_modules/weg-shared-layout/dist/components/weg-header.d.ts',
|
|
112
|
+
but this result could not be resolved under your current 'moduleResolution' setting.
|
|
113
|
+
Consider updating to 'node16', 'nodenext', or 'bundler'.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### What it means
|
|
117
|
+
|
|
118
|
+
`weg-shared-layout` exposes components via the **`exports`** field in `package.json` (subpaths like `./weg-header`). **Classic** `"moduleResolution": "node"` (still common in Angular 16 apps) does **not** resolve those subpaths the same way, even when the `.d.ts` files exist on disk.
|
|
119
|
+
|
|
120
|
+
### Fix A (recommended): Use the Stencil loader
|
|
121
|
+
|
|
122
|
+
In **`src/main.ts`**, register all components **once before** `bootstrapApplication`:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
126
|
+
|
|
127
|
+
defineCustomElements();
|
|
128
|
+
|
|
129
|
+
// then bootstrapApplication(...)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The loader path is documented in the main integration guide and avoids per-tag side-effect imports.
|
|
133
|
+
|
|
134
|
+
### Fix B: Modernize `moduleResolution`
|
|
135
|
+
|
|
136
|
+
In **`tsconfig.json`** (app root), set:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"compilerOptions": {
|
|
141
|
+
"moduleResolution": "bundler"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Angular **17+** schematics often use `bundler`. On **Angular 16**, `bundler` is supported by TypeScript 5.0+; with TS 4.9, prefer **`"node16"`** or **`"nodenext"`** if `bundler` is not available.
|
|
147
|
+
|
|
148
|
+
Then side-effect imports can work:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import 'weg-shared-layout/weg-header';
|
|
152
|
+
import 'weg-shared-layout/weg-footer';
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Use **one** registration strategy: loader **or** side-effect imports, not both.
|
|
156
|
+
|
|
157
|
+
### Fix C: Stay on loader only
|
|
158
|
+
|
|
159
|
+
If you cannot change `moduleResolution` (team policy, older tooling), **do not** use `import 'weg-shared-layout/weg-header'`. Use **`defineCustomElements()`** from `weg-shared-layout/loader` only.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Layout types in your app
|
|
164
|
+
|
|
165
|
+
Three supported patterns (pick one):
|
|
166
|
+
|
|
167
|
+
| Pattern | Example | Stencil `.d.ts` pulled? |
|
|
168
|
+
| --- | --- | --- |
|
|
169
|
+
| **Fixture-derived type** (default in guides) | `export type LayoutData = typeof layoutFixture` | No (only JSON + your file) |
|
|
170
|
+
| **Package types subpath** | `import type { LayoutData } from 'weg-shared-layout/layout-data'` | No |
|
|
171
|
+
| **Local interfaces** | Copy shapes into `layout.types.ts` | No |
|
|
172
|
+
|
|
173
|
+
Example local interfaces (equivalent to package shapes; adjust if your API differs):
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
export interface LayoutLink {
|
|
177
|
+
label: string;
|
|
178
|
+
href?: string;
|
|
179
|
+
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
180
|
+
items?: LayoutLink[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface LayoutHeaderData {
|
|
184
|
+
logoSrc?: string;
|
|
185
|
+
menu?: LayoutLink[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export type LayoutHeaderAuthAction = 'sign-in' | 'sign-out';
|
|
189
|
+
|
|
190
|
+
export interface LayoutFooterSocialLink {
|
|
191
|
+
platform: 'LinkedIn' | 'Instagram' | 'TikTok' | 'YouTube';
|
|
192
|
+
href: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface LayoutFooterData {
|
|
196
|
+
menu?: LayoutLink[][];
|
|
197
|
+
social?: LayoutFooterSocialLink[];
|
|
198
|
+
credits?: string;
|
|
199
|
+
copyright?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface LayoutData {
|
|
203
|
+
header?: Partial<LayoutHeaderData>;
|
|
204
|
+
footer?: Partial<LayoutFooterData>;
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Recommended `tsconfig` snippet (Angular 16 + this package)
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"compilerOptions": {
|
|
215
|
+
"skipLibCheck": true,
|
|
216
|
+
"resolveJsonModule": true,
|
|
217
|
+
"moduleResolution": "bundler"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Use **`node16`** instead of **`bundler`** if you must stay on TypeScript 4.9.
|
|
223
|
+
|
|
224
|
+
Pair with **`defineCustomElements()`** in `main.ts` and **`CUSTOM_ELEMENTS_SCHEMA`** on the shell component — unchanged from the main integration guide.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Checklist for HeroJobs / similar Angular 16 apps
|
|
229
|
+
|
|
230
|
+
1. Confirm TypeScript version: `npx tsc --version` (4.9 vs 5.x).
|
|
231
|
+
2. Add or verify **`skipLibCheck": true`**.
|
|
232
|
+
3. Set **`moduleResolution`** to `bundler` or `node16`, **or** switch to **`weg-shared-layout/loader`** only.
|
|
233
|
+
4. Prefer **`export type LayoutData = typeof layoutFixture`** or **`weg-shared-layout/layout-data`** for typing — avoid `import type { LayoutData } from 'weg-shared-layout'` if you still see Stencil errors and cannot use `skipLibCheck`.
|
|
234
|
+
5. Rebuild: `ng build` / CI pipeline.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## In-repo Angular 16 demo
|
|
239
|
+
|
|
240
|
+
Runnable app: **[demo/angular16/README.md](../demo/angular16/README.md)** — same imports as a published npm install (`weg-shared-layout/dummy-data.json`, `weg-shared-layout/loader`); only the `package.json` dependency line differs (`file:../..` vs `^0.0.x`). Run with `npm run demo:angular16` from repo root.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Related
|
|
245
|
+
|
|
246
|
+
- [Documentation index](./README.md)
|
|
247
|
+
- [Angular integration guide](./angular-integration-guide.md)
|
|
248
|
+
- [Angular quick start](./angular.md)
|
|
249
|
+
- [In-repo Angular 16 demo](../demo/angular16/README.md)
|
|
250
|
+
- [Publishing](./publishing.md)
|