create-portfoliable 1.4.0 → 1.4.1
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 +1 -1
- package/scripts/smoke-homeview.mjs +12 -0
- package/src/App.js +25 -8
- package/vite.config.js +5 -0
package/package.json
CHANGED
|
@@ -80,6 +80,16 @@ function assertIncludes(haystack, needle, message) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// Verifies a custom element registration call survives production bundling.
|
|
84
|
+
function assertCustomElementRegistration(haystack, elementName) {
|
|
85
|
+
const registrationPattern = new RegExp(
|
|
86
|
+
`customElements\\.define\\(["'\`]${elementName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}["'\`]`
|
|
87
|
+
);
|
|
88
|
+
if (!registrationPattern.test(haystack)) {
|
|
89
|
+
fail(`Production bundle does not register ${elementName}.`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
83
93
|
// MARK: SMOKE ORCHESTRATION
|
|
84
94
|
// Runs build, inspects emitted bundle/assets, and validates HomeView/CaseView route expectations.
|
|
85
95
|
function main() {
|
|
@@ -94,6 +104,8 @@ function main() {
|
|
|
94
104
|
|
|
95
105
|
// HomeView template is mounted through ds-home-view.
|
|
96
106
|
assertIncludes(bundleText, 'ds-home-view', 'HomeView marker not found in bundle.');
|
|
107
|
+
assertCustomElementRegistration(bundleText, 'ds-home-view');
|
|
108
|
+
assertCustomElementRegistration(bundleText, 'ds-gallery');
|
|
97
109
|
|
|
98
110
|
// CaseView template must exist for in-app Home -> Case transitions.
|
|
99
111
|
assertIncludes(bundleText, 'ds-case-view', 'CaseView marker not found in bundle.');
|
package/src/App.js
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
A11Y_THEME_TOKEN_KEYS,
|
|
36
36
|
Header,
|
|
37
37
|
HomeView,
|
|
38
|
+
Gallery,
|
|
38
39
|
MermaidDiagram,
|
|
39
40
|
Summary,
|
|
40
41
|
Thumbnail,
|
|
@@ -43,14 +44,29 @@ import {
|
|
|
43
44
|
PlayerView
|
|
44
45
|
} from '@portfoliablejs/valence';
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
// Keeps Valence component modules in production bundles so their module-level
|
|
48
|
+
// customElements.define calls are not removed as unused tree-shaken exports.
|
|
49
|
+
function retainValenceComponentRegistrations() {
|
|
50
|
+
const componentRegistrations = [
|
|
51
|
+
['ds-audio-player', AudioPlayer],
|
|
52
|
+
['ds-article', Article],
|
|
53
|
+
['ds-header', Header],
|
|
54
|
+
['ds-home-view', HomeView],
|
|
55
|
+
['ds-gallery', Gallery],
|
|
56
|
+
['mermaid-diagram', MermaidDiagram],
|
|
57
|
+
['ds-summary', Summary],
|
|
58
|
+
['ds-thumbnail', Thumbnail],
|
|
59
|
+
['ds-toast', Toast],
|
|
60
|
+
['ds-video-player', VideoPlayer],
|
|
61
|
+
['ds-player-view', PlayerView]
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
for (const [elementName, component] of componentRegistrations) {
|
|
65
|
+
if (typeof component !== 'function' || customElements.get(elementName) !== component) {
|
|
66
|
+
throw new Error(`[portfoliable] Valence component registration failed: ${elementName}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
54
70
|
|
|
55
71
|
// MARK: HEADER DEFAULTS
|
|
56
72
|
// Resolves runtime defaults and persistence keys used across navigation and resume flows.
|
|
@@ -958,6 +974,7 @@ class AppShell extends HTMLElement {
|
|
|
958
974
|
// Initializes shadow DOM, source content, and default runtime state.
|
|
959
975
|
constructor() {
|
|
960
976
|
super();
|
|
977
|
+
retainValenceComponentRegistrations();
|
|
961
978
|
this.attachShadow({ mode: 'open' });
|
|
962
979
|
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
963
980
|
this._portfolioCases = getPortfolioCases();
|
package/vite.config.js
CHANGED
|
@@ -108,6 +108,11 @@ export default defineConfig(({ command }) => {
|
|
|
108
108
|
// Keep warnings useful while avoiding noisy false alarms for optional async chunks.
|
|
109
109
|
chunkSizeWarningLimit: 3000,
|
|
110
110
|
rollupOptions: {
|
|
111
|
+
treeshake: {
|
|
112
|
+
// Valence modules register custom elements at module evaluation time.
|
|
113
|
+
// Preserve those registration side effects in production bundles.
|
|
114
|
+
moduleSideEffects: true
|
|
115
|
+
},
|
|
111
116
|
output: {
|
|
112
117
|
manualChunks: getManualChunk
|
|
113
118
|
}
|