My scripted migration inserted the import behind a guard that silently did not fire:
`if 'defineMapElement' not in s.split('function')[0]` became false as soon as the
inserted CALL appeared before the first `function` keyword — so the files that most
needed the import were exactly the ones that did not get it. 11 of 16.
Every one of those elements would have thrown "defineMapElement is not defined" on
load. A bundler does not error on a free identifier; only loading does. studio caught it
in L64 via landing-preconditions, which imports each profile, and fixed it there
(37f75601) plus added an arm to check:element-bootstrap.
This repairs the same 11 on this branch so it is not a landmine if it lands after L64,
and it is byte-equivalent to studio's fix in effect. Verified by PARSING each entry and
resolving the identifier against its import bindings — 16 of 16 bound — rather than by
re-running the kind of regex that wrote the bug.
45 lines
1.7 KiB
JavaScript
45 lines
1.7 KiB
JavaScript
import { defineMapElement } from '@map/elements/defineMapElement.js'
|
|
/**
|
|
* plugin-designs/key-cities/index.js — bundle entry for KEY CITIES.
|
|
*
|
|
* Registers ONE custom-element tag:
|
|
* <key-cities-map profile-config='{"profile":"cities-list"}'></key-cities-map>
|
|
*
|
|
* Same shape as country-posters/index.js — folder = bundle, each flat .vue = a
|
|
* profile, `profile` is the FILENAME not the folder. ProfileLoader lives in @map
|
|
* and cannot glob into a bundle folder, so the BUNDLE evaluates the glob and hands
|
|
* the registry over via app.provide('profileModules').
|
|
*
|
|
* NO COLOR STRATEGIES registered here: this bundle currently ships a list profile
|
|
* only. When the map profile lands it will need one, and it goes in src/colors/
|
|
* where the registry auto-discovers it by filename.
|
|
*
|
|
* NO MAPBOX RTL PLUGIN either — nothing here renders a basemap yet. Adding the
|
|
* plugin call before a map exists would be dead code implying a capability the
|
|
* bundle does not have.
|
|
*/
|
|
|
|
// Evaluated by Vite at build time relative to THIS file, so it captures only this
|
|
// bundle's profiles.
|
|
const profileModules = import.meta.glob('./*.vue')
|
|
|
|
function buildKeyCitiesElement() {
|
|
return defineMapElement({
|
|
profileModules,
|
|
configureApp: (app, { pinia, i18n }) => {
|
|
// Per-instance Pinia + i18n so multiple embeds on one page never bleed state.
|
|
},
|
|
})
|
|
}
|
|
|
|
const KeyCitiesElement = buildKeyCitiesElement()
|
|
|
|
// Guarded: customElements.define() is one-shot per tag per page session, so an
|
|
// IIFE loaded twice would throw without this.
|
|
if (typeof customElements !== 'undefined') {
|
|
if (!customElements.get('key-cities-map')) {
|
|
customElements.define('key-cities-map', KeyCitiesElement)
|
|
}
|
|
}
|
|
|
|
export default KeyCitiesElement
|