@csedl/svelte-on-rails 11.0.0 → 11.0.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.
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'vite';
2
+ export declare function devModuleMap(options?: {
3
+ fileName?: string;
4
+ includeNodeModules?: boolean;
5
+ moduleFilter?: (id: string) => boolean;
6
+ }): Plugin;
@@ -0,0 +1,29 @@
1
+ function m(i = {}) {
2
+ const {
3
+ fileName: l = ".vite/dev-module-map.json",
4
+ includeNodeModules: s = !1,
5
+ moduleFilter: n = null
6
+ } = i;
7
+ return {
8
+ name: "chunk-modules-manifest",
9
+ enforce: "post",
10
+ generateBundle(c, u) {
11
+ const t = {};
12
+ for (const [f, o] of Object.entries(u)) {
13
+ if (o.type !== "chunk") continue;
14
+ let e = Object.keys(o.modules ?? {});
15
+ s || (e = e.filter((d) => !d.includes("node_modules"))), n && (e = e.filter(n)), e.length > 0 && (t[f] = e);
16
+ }
17
+ this.emitFile({
18
+ type: "asset",
19
+ fileName: l,
20
+ // goes to outDir / fileName
21
+ source: JSON.stringify(t, null, 2)
22
+ });
23
+ }
24
+ };
25
+ }
26
+ export {
27
+ m as devModuleMap
28
+ };
29
+ //# sourceMappingURL=dev-module-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-module-map.js","sources":["../../src/ssr/vite-plugins/dev-module-map.ts"],"sourcesContent":["/**\n * Vite plugin that generates chunk-modules.json containing\n * a map of output chunk filenames → array of original module paths included in each chunk\n *\n * @param options - Plugin options\n * @param options.fileName - Name of the emitted manifest file (default: '.vite/chunk-modules.json')\n * @param options.includeNodeModules - Whether to include node_modules paths (default: false)\n * @param options.moduleFilter - Optional filter for modules to include/exclude\n * @returns Vite plugin\n */\n/// <reference path=\"../../types/vite.d.ts\" />\n\n\nimport type { Plugin, OutputBundle } from 'vite';\n\nexport function devModuleMap(\n options: {\n fileName?: string;\n includeNodeModules?: boolean;\n moduleFilter?: (id: string) => boolean;\n } = {}\n): Plugin {\n const {\n fileName = '.vite/dev-module-map.json',\n includeNodeModules = false,\n moduleFilter = null,\n } = options;\n\n return {\n name: 'chunk-modules-manifest',\n enforce: 'post',\n\n generateBundle(_options: unknown, bundle: OutputBundle) {\n /** Map: chunk filename → module paths */\n const manifest: Record<string, string[]> = {};\n\n for (const [chunkFileName, info] of Object.entries(bundle)) {\n if (info.type !== 'chunk') continue;\n\n let modules = Object.keys(info.modules ?? {});\n\n // Optional filtering\n if (!includeNodeModules) {\n modules = modules.filter((id) => !id.includes('node_modules'));\n }\n if (moduleFilter) {\n modules = modules.filter(moduleFilter);\n }\n\n if (modules.length > 0) {\n manifest[chunkFileName] = modules;\n }\n }\n\n // Emit the manifest as an asset\n this.emitFile({\n type: 'asset',\n fileName, // goes to outDir / fileName\n source: JSON.stringify(manifest, null, 2),\n });\n },\n };\n}"],"names":["devModuleMap","options","fileName","includeNodeModules","moduleFilter","_options","bundle","manifest","chunkFileName","info","modules","id"],"mappings":"AAeO,SAASA,EACZC,IAII,IACE;AACN,QAAM;AAAA,IACF,UAAAC,IAAW;AAAA,IACX,oBAAAC,IAAqB;AAAA,IACrB,cAAAC,IAAe;AAAA,EAAA,IACfH;AAEJ,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IAET,eAAeI,GAAmBC,GAAsB;AAEpD,YAAMC,IAAqC,CAAA;AAE3C,iBAAW,CAACC,GAAeC,CAAI,KAAK,OAAO,QAAQH,CAAM,GAAG;AACxD,YAAIG,EAAK,SAAS,QAAS;AAE3B,YAAIC,IAAU,OAAO,KAAKD,EAAK,WAAW,CAAA,CAAE;AAG5C,QAAKN,MACDO,IAAUA,EAAQ,OAAO,CAACC,MAAO,CAACA,EAAG,SAAS,cAAc,CAAC,IAE7DP,MACAM,IAAUA,EAAQ,OAAON,CAAY,IAGrCM,EAAQ,SAAS,MACjBH,EAASC,CAAa,IAAIE;AAAA,MAElC;AAGA,WAAK,SAAS;AAAA,QACV,MAAM;AAAA,QACN,UAAAR;AAAA;AAAA,QACA,QAAQ,KAAK,UAAUK,GAAU,MAAM,CAAC;AAAA,MAAA,CAC3C;AAAA,IACL;AAAA,EAAA;AAER;"}
package/package.json CHANGED
@@ -1,25 +1,24 @@
1
1
  {
2
2
  "name": "@csedl/svelte-on-rails",
3
- "version": "11.0.0",
4
- "description": "Hydrates Svelte components from the svelte-on-rails gem and can handle Actions received by Web Socket.",
3
+ "version": "11.0.2",
4
+ "description": "Client-side runtime for svelte-on-rails: hydration, SSR build support & Turbo Stream actions",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
+ "scripts": {
8
+ "build": "vite build"
9
+ },
7
10
  "exports": {
8
11
  ".": "./index.js",
9
-
10
12
  "./utils": "./utils/index.js",
11
13
  "./config": "./src/config.js",
12
-
13
14
  "./ssr": {
14
- "types": "./types/ssr.d.ts",
15
- "default": "./src/ssr/vite-plugins/dev-module-map.ts"
15
+ "types": "./dist/ssr/dev-module-map.d.ts",
16
+ "default": "./dist/ssr/dev-module-map.js"
16
17
  },
17
-
18
18
  "./src/streams/componentStreamListener": "./src/streams/componentStreamListener.js",
19
19
  "./src/streams/dispatch-event.js": "./src/streams/dispatch-event.js",
20
20
  "./src/logger.js": "./src/logger.js",
21
21
  "./src/config.js": "./src/config.js"
22
-
23
22
  },
24
23
  "peerDependencies": {
25
24
  "@hotwired/stimulus": "^3.2.2",
@@ -40,6 +39,13 @@
40
39
  },
41
40
  "homepage": "https://svelte-on-rails.dev",
42
41
  "devDependencies": {
43
- "playwright": "^1.58.2"
42
+ "@types/node": "^25.3.3",
43
+ "minimatch": "^10.2.3",
44
+ "playwright": "^1.58.2",
45
+ "vite": "^7.3.1",
46
+ "vite-plugin-dts": "^4.5.4"
47
+ },
48
+ "overrides": {
49
+ "minimatch": "^10.2.3"
44
50
  }
45
51
  }
package/src/logger.js CHANGED
@@ -1,4 +1,4 @@
1
- import SvelteOnRails from './config.js'
1
+ import {SvelteOnRails} from './config.js'
2
2
 
3
3
  export function debugLog(message, object, object2) {
4
4
  log( null, message, object, object2);
@@ -9,7 +9,7 @@ export function streamDebugLog(message, object, object2) {
9
9
  }
10
10
 
11
11
  function log(namespace, message, object, object2) {
12
- if (window.SvelteOnRails.debug) {
12
+ if (SvelteOnRails.debug) {
13
13
 
14
14
  const nmsp = (namespace ? `:${namespace}` : '');
15
15
 
@@ -1,5 +1,5 @@
1
1
 
2
- // componentStreamListener.js (in your npm package)
2
+
3
3
  export function addComponentStreamListener(node, callback) {
4
4
 
5
5
  // Find the wrapping element
@@ -0,0 +1,7 @@
1
+ {
2
+ "success": true,
3
+ "errors": "",
4
+ "timestamp": "2026-03-03 12:45:09",
5
+ "vite_ruby": "3.9.3",
6
+ "digest": "48301b9ceb26ddb2b6b1e63eb310a76781dec22e"
7
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { defineConfig } from 'vite'
2
+ import { resolve } from 'node:path';
3
+ import dts from 'vite-plugin-dts'
4
+
5
+ export default defineConfig({
6
+ plugins: [
7
+ dts({
8
+ include: ['src/ssr/vite-plugins/dev-module-map.ts'],
9
+ outDir: 'dist',
10
+ tsconfigPath: './tsconfig.json',
11
+ }),
12
+ ],
13
+
14
+ build: {
15
+ lib: {
16
+ // single entry = simplest possible
17
+ entry: resolve(__dirname, 'src/ssr/vite-plugins/dev-module-map.ts'),
18
+ formats: ['es'],
19
+ //fileName: (format, entryName) => `ssr/${entryName}.js`,
20
+ fileName: 'ssr/dev-module-map',
21
+ },
22
+
23
+ rollupOptions: {
24
+ // Very important for libraries – don't bundle your peers
25
+ external: [
26
+ '@hotwired/stimulus',
27
+ 'svelte',
28
+ // add anything else that should stay external
29
+ ],
30
+ },
31
+
32
+ sourcemap: true,
33
+ emptyOutDir: true,
34
+ },
35
+ })