Skip to content

Commit 050eb64

Browse files
committed
fix: strip v5 prefix from docs titles, replace @jspm/generator with @pwrs/mappa
Strip the tag prefix (pf-v5-) from element display names in the docs site sidebar, page titles, and demo headings so they show "Accordion" instead of "V5 Accordion". Replace @jspm/generator with @pwrs/mappa for import map generation in both the 11ty docs build and the dev server plugin. This fixes the "Unable to resolve npm:lit@3.3.2" build error and simplifies the import map infrastructure. Also adds v5 to the docs version dropdown and marks it as current. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e120ec3 commit 050eb64

11 files changed

Lines changed: 256 additions & 1063 deletions

File tree

docs/_data/importMap.cjs

Lines changed: 27 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,83 +12,44 @@ function readPackageVersion(module) {
1212
return packageLock.packages[`node_modules/${module}`].version;
1313
}
1414

15-
const LIT_VERSION = readPackageVersion('lit');
16-
const FUSE_VERSION = readPackageVersion('fuse.js');
17-
const PRISM_VERSION = readPackageVersion('prismjs');
18-
19-
const LIT_DEPS = [
20-
{
21-
target: `lit@${LIT_VERSION}`,
22-
subpaths: [
23-
'.',
24-
'./decorators/query-all.js',
25-
'./decorators/query-assigned-nodes.js',
26-
'./decorators/query-assigned-elements.js',
27-
'./decorators/query-async.js',
28-
'./decorators/query.js',
29-
'./decorators/state.js',
30-
'./decorators/property.js',
31-
'./decorators/custom-element.js',
32-
'./directives/async-append.js',
33-
'./directives/async-replace.js',
34-
'./directives/cache.js',
35-
'./directives/class-map.js',
36-
'./directives/guard.js',
37-
'./directives/if-defined.js',
38-
'./directives/live.js',
39-
'./directives/ref.js',
40-
'./directives/repeat.js',
41-
'./directives/style-map.js',
42-
'./directives/template-content.js',
43-
'./directives/unsafe-html.js',
44-
'./directives/unsafe-svg.js',
45-
'./directives/until.js',
46-
'./async-directive.js',
47-
'./decorators.js',
48-
'./directive.js',
49-
'./directive-helpers.js',
50-
'./html.js',
51-
'./polyfill-support.js',
52-
'./static-html.js',
53-
],
54-
},
55-
{
56-
target: `@lit-labs/ssr-client`,
57-
subpaths: [
58-
'.',
59-
'./lit-element-hydrate-support.js',
60-
],
61-
},
15+
const LOCAL_PACKAGES = [
16+
'@patternfly/elements',
17+
'@patternfly/pfe-core',
18+
'@patternfly/pfe-tools',
19+
'@patternfly/icons',
6220
];
6321

6422
module.exports = async function() {
65-
const { Generator } = await import('@jspm/generator');
66-
67-
const generator = new Generator({
68-
defaultProvider: 'jsdelivr',
69-
env: ['production', 'browser', 'module'],
23+
const { generate } = await import('@pwrs/mappa');
24+
25+
const map = await generate({
26+
dependencies: {
27+
'tslib': readPackageVersion('tslib'),
28+
'@rhds/elements': readPackageVersion('@rhds/elements'),
29+
'prismjs': readPackageVersion('prismjs'),
30+
'element-internals-polyfill': readPackageVersion('element-internals-polyfill'),
31+
'fuse.js': readPackageVersion('fuse.js'),
32+
'lit': readPackageVersion('lit'),
33+
'@lit-labs/ssr-client': readPackageVersion('@lit-labs/ssr-client'),
34+
},
35+
}, {
36+
cdn: 'jsdelivr',
37+
exclude: LOCAL_PACKAGES,
7038
});
7139

72-
await generator.install([
73-
'tslib',
74-
'@rhds/elements',
75-
'@rhds/elements/rh-footer/rh-footer-universal.js',
76-
`prismjs@${PRISM_VERSION}`,
77-
'element-internals-polyfill',
78-
`fuse.js@${FUSE_VERSION}`,
79-
...LIT_DEPS,
80-
]);
40+
for (const key of Object.keys(map.imports)) {
41+
for (const pkg of LOCAL_PACKAGES) {
42+
if (key === pkg || key.startsWith(`${pkg}/`)) {
43+
delete map.imports[key];
44+
}
45+
}
46+
}
8147

82-
const map = generator.getMap();
8348
map.imports['/docs/zero-md.js'] = '/zero-md.js';
8449
map.imports['@patternfly/elements/'] = '/assets/@patternfly/elements/';
8550
map.imports['@patternfly/pfe-core/'] = '/assets/@patternfly/pfe-core/';
8651
map.imports['@patternfly/pfe-core'] = '/assets/@patternfly/pfe-core/core.js';
8752
map.imports['@patternfly/pfe-tools/'] = '/assets/@patternfly/pfe-tools/';
8853
map.imports['@patternfly/icons/'] = '/assets/@patternfly/icons/';
89-
map.imports['@lit/context'] = map.scopes['https://cdn.jsdelivr.net/']['@lit/context'];
90-
map.imports['lit/'] = map.imports.lit.replace('index.js', '');
91-
map.scopes['https://cdn.jsdelivr.net/'].lit = map.imports.lit;
92-
map.scopes['https://cdn.jsdelivr.net/']['lit/'] = map.imports.lit.replace('index.js', '');
9354
return map;
9455
};

docs/_data/versions.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
[
2+
{
3+
"version": "v5.0.0",
4+
"slug": "v5",
5+
"label": "v5",
6+
"current": true
7+
},
28
{
39
"version": "v4.0.0",
410
"slug": "v4",
511
"label": "v4",
6-
"current": true
12+
"current": false
713
},
814
{
915
"version": "v3.0.0",

docs/_plugins/create-import-map.cjs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
module.exports = function(eleventyConfig) {
22
eleventyConfig.addPairedAsyncShortcode('generateImportMap', async content => {
3-
const { Generator } = await import('@jspm/generator');
3+
const { generate } = await import('@pwrs/mappa');
44

5-
const generator = new Generator({
6-
defaultProvider: 'jspm.io',
7-
env: ['production', 'browser', 'module'],
8-
});
5+
const deps = {};
6+
const specifierRe = /['"]([^'"]+)['"]/g;
7+
for (const match of content.matchAll(specifierRe)) {
8+
const spec = match[1];
9+
if (!spec.startsWith('.') && !spec.startsWith('/')) {
10+
const name = spec.startsWith('@')
11+
? spec.split('/').slice(0, 2).join('/')
12+
: spec.split('/')[0];
13+
deps[name] = '*';
14+
}
15+
}
916

10-
const pins = await generator.addMappings(content);
17+
const map = await generate({ dependencies: deps }, { cdn: 'esm.sh' });
1118

12-
const html = await generator.htmlInject(content, {
13-
pins,
14-
esModuleShims: true,
15-
whitespace: true,
16-
});
17-
18-
return html;
19+
const script = `<script type="importmap">\n${JSON.stringify(map, null, 2)}\n</script>`;
20+
return content.replace(/<script\b[^>]*type=["']module["'][^>]*>[\s\S]*?<\/script>/g, found =>
21+
`${script}\n${found}`);
1922
});
2023
};
21-

0 commit comments

Comments
 (0)