@mapvx/web-components-ssr 1.1.1 → 1.2.0-dev.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/README.md CHANGED
@@ -32,8 +32,9 @@ import '@mapvx/web-components-ssr/dist/browser/styles.css'
32
32
  **HTML:**
33
33
 
34
34
  ```html
35
- <!-- Include the component files -->
36
- <script src="node_modules/@mapvx/web-components-ssr/dist/browser/main.js"></script>
35
+ <!-- Include the component files. `type="module"` is required: the bundle is an
36
+ ES module that lazy-loads sibling `chunk-*.js` files from the same folder. -->
37
+ <script type="module" src="node_modules/@mapvx/web-components-ssr/dist/browser/main.js"></script>
37
38
  <link rel="stylesheet" href="node_modules/@mapvx/web-components-ssr/dist/browser/styles.css" />
38
39
  ```
39
40
 
@@ -105,8 +106,11 @@ Configure assets in `angular.json` and use script tags in `index.html`:
105
106
  Then reference the files in your `index.html`:
106
107
 
107
108
  ```html
108
- <!-- Web Component Scripts -->
109
- <script src="website-component/main.js" defer></script>
109
+ <!-- Web Component Scripts. `type="module"` is required: the bundle is an ES module
110
+ that lazy-loads sibling `chunk-*.js` files, so it must not be a classic script
111
+ (a classic script fails with "Unexpected token 'export'"). `defer` is implicit
112
+ for modules, and the `glob: "**/*"` asset rule above already copies the chunks. -->
113
+ <script type="module" src="website-component/main.js"></script>
110
114
 
111
115
  <!-- Web Component Styles -->
112
116
  <link rel="stylesheet" href="website-component/styles.css" />
@@ -152,8 +156,12 @@ npm install @mapvx/web-components-ssr-helpers
152
156
  ### Via CDN (unpkg)
153
157
 
154
158
  ```html
155
- <!-- Include the component files -->
156
- <script src="https://unpkg.com/@mapvx/web-components-ssr@latest/dist/browser/main.js"></script>
159
+ <!-- Include the component files. `type="module"` is required: the bundle is an
160
+ ES module that lazy-loads sibling `chunk-*.js` files from the same URL prefix. -->
161
+ <script
162
+ type="module"
163
+ src="https://unpkg.com/@mapvx/web-components-ssr@latest/dist/browser/main.js"
164
+ ></script>
157
165
  <link
158
166
  rel="stylesheet"
159
167
  href="https://unpkg.com/@mapvx/web-components-ssr@latest/dist/browser/styles.css"
@@ -559,13 +567,13 @@ The `userAction` event provides detailed information about user interactions wit
559
567
 
560
568
  #### UserAction Types
561
569
 
562
- | Type | Description | Data Structure |
570
+ | Type | Description | Data Structure |
563
571
  | -------------------- | ------------------------------------------ | --------------------------------------- | ------------ |
564
- | `select-filter` | Emitted when a filter is selected | `{ filter: string }` |
565
- | `show-place` | Emitted when a place is displayed | `{ placeId: string, alias: string | undefined }` |
566
- | `select-destination` | Emitted when a destination is selected | `{ destinationId: string, alias: string | undefined }` |
567
- | `search` | Emitted when a search is performed | `{ searchTerm: string }` |
568
- | `return-to-home` | Emitted when user returns to the home view | `{ filter: string }` |
572
+ | `select-filter` | Emitted when a filter is selected | `{ filter: string }` |
573
+ | `show-place` | Emitted when a place is displayed | `{ placeId: string, alias: string | undefined }` |
574
+ | `select-destination` | Emitted when a destination is selected | `{ destinationId: string, alias: string | undefined }` |
575
+ | `search` | Emitted when a search is performed | `{ searchTerm: string }` |
576
+ | `return-to-home` | Emitted when user returns to the home view | `{ filter: string }` |
569
577
 
570
578
  #### UserAction Usage Examples
571
579
 
@@ -807,10 +815,14 @@ npm install @mapvx/web-components-ssr @mapvx/web-components-ssr-helpers
807
815
  ```javascript
808
816
  #!/usr/bin/env node
809
817
 
810
- import { existsSync, mkdirSync, copyFileSync } from 'fs'
818
+ import { existsSync, mkdirSync, copyFileSync, readdirSync } from 'fs'
811
819
  import { join } from 'path'
812
820
 
813
- const sourcePath = 'node_modules/@mapvx/web-components-ssr/dist/browser/main.js'
821
+ // The bundle is an ES module that lazy-loads sibling `chunk-*.js` files via relative
822
+ // `import('./chunk-*.js')` calls, so every .js file must be copied and the chunks must
823
+ // keep their original names. Copying main.js alone leaves the component unable to boot.
824
+ const sourceDir = 'node_modules/@mapvx/web-components-ssr/dist/browser'
825
+ const sourcePath = join(sourceDir, 'main.js')
814
826
  const targetDir = 'public/mapvx-website'
815
827
  const targetPath = join(targetDir, 'bundle.js')
816
828
 
@@ -824,6 +836,11 @@ if (!existsSync(targetDir)) {
824
836
  }
825
837
 
826
838
  copyFileSync(sourcePath, targetPath)
839
+
840
+ for (const chunk of readdirSync(sourceDir).filter((f) => f.endsWith('.js') && f !== 'main.js')) {
841
+ copyFileSync(join(sourceDir, chunk), join(targetDir, chunk))
842
+ }
843
+
827
844
  console.log(`✅ Bundle copied successfully!`)
828
845
  ```
829
846
 
@@ -840,7 +857,7 @@ export default async function HomePage() {
840
857
 
841
858
  return (
842
859
  <div>
843
- <Script src='/mapvx-website/bundle.js' />
860
+ <Script type='module' src='/mapvx-website/bundle.js' />
844
861
  <mapvx-website
845
862
  api-key={process.env.NEXT_PUBLIC_MAPVX_API_KEY}
846
863
  institution-id={process.env.NEXT_PUBLIC_MAPVX_INSTITUTION_ID}