@salla.sa/twilight-bundles-starter-kit 0.1.32 → 0.1.34

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": "@salla.sa/twilight-bundles-starter-kit",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Starter kit for building custom Salla components",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "lit": "^3.2.1",
36
- "@salla.sa/twilight-bundles": "0.1.38"
36
+ "@salla.sa/twilight-bundles": "0.1.40"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=16.0.0",
package/vite.config.ts CHANGED
@@ -8,11 +8,8 @@ sallaBuildPlugin,
8
8
  sallaDemoPlugin,
9
9
  sallaTransformPlugin,
10
10
  } from '@salla.sa/twilight-bundles/vite-plugins';
11
- import { litImportMapPlugin } from './src/plugins/lit-import-map';
12
-
13
- export default defineConfig({
11
+ export default defineConfig({
14
12
  plugins: [
15
- litImportMapPlugin(),
16
13
  sallaTransformPlugin(),
17
14
  sallaBuildPlugin(),
18
15
  sallaDemoPlugin({
@@ -1,53 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import type { HtmlTagDescriptor } from 'vite';
3
- import { litImportMapPlugin } from './lit-import-map';
4
-
5
- describe('litImportMapPlugin', () => {
6
- const plugin = litImportMapPlugin();
7
-
8
- it('should have the correct plugin name', () => {
9
- expect(plugin.name).toBe('lit-import-map');
10
- });
11
-
12
- it('should only apply during dev (serve)', () => {
13
- expect(plugin.apply).toBe('serve');
14
- });
15
-
16
- it('should return a valid import map tag descriptor', () => {
17
- const result = (plugin as any).transformIndexHtml('') as HtmlTagDescriptor[];
18
-
19
- expect(result).toHaveLength(1);
20
- expect(result[0].tag).toBe('script');
21
- expect(result[0].attrs).toEqual({ type: 'importmap' });
22
- expect(result[0].injectTo).toBe('head-prepend');
23
- });
24
-
25
- it('should produce valid JSON in the import map', () => {
26
- const result = (plugin as any).transformIndexHtml('') as HtmlTagDescriptor[];
27
- const parsed = JSON.parse(result[0].children as string);
28
-
29
- expect(parsed).toHaveProperty('imports');
30
- expect(typeof parsed.imports).toBe('object');
31
- });
32
-
33
- it('should map all required lit modules', () => {
34
- const result = (plugin as any).transformIndexHtml('') as HtmlTagDescriptor[];
35
- const { imports } = JSON.parse(result[0].children as string);
36
-
37
- expect(imports).toHaveProperty('lit');
38
- expect(imports).toHaveProperty('lit/decorators.js');
39
- expect(imports).toHaveProperty('@lit/reactive-element');
40
- expect(imports).toHaveProperty('lit-html');
41
- expect(imports).toHaveProperty('lit-element/lit-element.js');
42
- });
43
-
44
- it('should point all mappings to jsdelivr CDN with +esm suffix', () => {
45
- const result = (plugin as any).transformIndexHtml('') as HtmlTagDescriptor[];
46
- const { imports } = JSON.parse(result[0].children as string);
47
-
48
- for (const [key, url] of Object.entries(imports)) {
49
- expect(url).toMatch(/^https:\/\/cdn\.jsdelivr\.net\/npm\//);
50
- expect(url).toMatch(/\/\+esm$/);
51
- }
52
- });
53
- });
@@ -1,30 +0,0 @@
1
- import type { Plugin, HtmlTagDescriptor } from 'vite';
2
-
3
- /**
4
- * Vite plugin that injects a browser import map for Lit dependencies.
5
- * Restricted to dev mode (`apply: 'serve'`) so production builds are unaffected.
6
- */
7
- export function litImportMapPlugin(): Plugin {
8
- return {
9
- name: 'lit-import-map',
10
- apply: 'serve',
11
- transformIndexHtml(): HtmlTagDescriptor[] {
12
- return [
13
- {
14
- tag: 'script',
15
- attrs: { type: 'importmap' },
16
- children: JSON.stringify({
17
- imports: {
18
- 'lit': 'https://cdn.jsdelivr.net/npm/lit@3/+esm',
19
- 'lit/decorators.js': 'https://cdn.jsdelivr.net/npm/lit@3/decorators.js/+esm',
20
- '@lit/reactive-element': 'https://cdn.jsdelivr.net/npm/@lit/reactive-element@2/+esm',
21
- 'lit-html': 'https://cdn.jsdelivr.net/npm/lit-html@3/+esm',
22
- 'lit-element/lit-element.js': 'https://cdn.jsdelivr.net/npm/lit-element@4/lit-element.js/+esm',
23
- },
24
- }),
25
- injectTo: 'head-prepend',
26
- },
27
- ];
28
- },
29
- };
30
- }