create-portfoliable 1.4.0 → 1.4.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-portfoliable",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Unified Portfoliable package with initializer and runtime CLI",
5
5
  "private": false,
6
6
  "type": "module",
@@ -89,6 +89,7 @@
89
89
  "markdown-it-deflist": "^2.1.0",
90
90
  "markdown-it-footnote": "^4.0.0",
91
91
  "markdown-it-task-lists": "^2.1.1",
92
+ "prismjs": "^1.30.0",
92
93
  "vite": "^8.1.1"
93
94
  },
94
95
  "devDependencies": {
@@ -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
@@ -27,6 +27,7 @@ import {
27
27
  resolveReturnOnlyVisibilityOverrides
28
28
  } from './header-visibility.contract.js';
29
29
  import { pickReachableRuntimeMediaUrl } from './runtime-media.contract.js';
30
+ import './prism-runtime.js';
30
31
  import Lenis from 'lenis';
31
32
  import {
32
33
  AudioPlayer,
@@ -35,6 +36,7 @@ import {
35
36
  A11Y_THEME_TOKEN_KEYS,
36
37
  Header,
37
38
  HomeView,
39
+ Gallery,
38
40
  MermaidDiagram,
39
41
  Summary,
40
42
  Thumbnail,
@@ -43,14 +45,29 @@ import {
43
45
  PlayerView
44
46
  } from '@portfoliablejs/valence';
45
47
 
46
- void Article;
47
- void Header;
48
- void HomeView;
49
- void Summary;
50
- void Thumbnail;
51
- void Toast;
52
- void VideoPlayer;
53
- void MermaidDiagram;
48
+ // Keeps Valence component modules in production bundles so their module-level
49
+ // customElements.define calls are not removed as unused tree-shaken exports.
50
+ function retainValenceComponentRegistrations() {
51
+ const componentRegistrations = [
52
+ ['ds-audio-player', AudioPlayer],
53
+ ['ds-article', Article],
54
+ ['ds-header', Header],
55
+ ['ds-home-view', HomeView],
56
+ ['ds-gallery', Gallery],
57
+ ['mermaid-diagram', MermaidDiagram],
58
+ ['ds-summary', Summary],
59
+ ['ds-thumbnail', Thumbnail],
60
+ ['ds-toast', Toast],
61
+ ['ds-video-player', VideoPlayer],
62
+ ['ds-player-view', PlayerView]
63
+ ];
64
+
65
+ for (const [elementName, component] of componentRegistrations) {
66
+ if (typeof component !== 'function' || customElements.get(elementName) !== component) {
67
+ throw new Error(`[portfoliable] Valence component registration failed: ${elementName}`);
68
+ }
69
+ }
70
+ }
54
71
 
55
72
  // MARK: HEADER DEFAULTS
56
73
  // Resolves runtime defaults and persistence keys used across navigation and resume flows.
@@ -958,6 +975,7 @@ class AppShell extends HTMLElement {
958
975
  // Initializes shadow DOM, source content, and default runtime state.
959
976
  constructor() {
960
977
  super();
978
+ retainValenceComponentRegistrations();
961
979
  this.attachShadow({ mode: 'open' });
962
980
  this.shadowRoot.appendChild(template.content.cloneNode(true));
963
981
  this._portfolioCases = getPortfolioCases();
@@ -0,0 +1,5 @@
1
+ import Prism from 'prismjs';
2
+
3
+ if (typeof globalThis.Prism === 'undefined') {
4
+ globalThis.Prism = Prism;
5
+ }
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
  }