svelte-adapter-uws 0.2.2 → 0.2.3

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.
Files changed (2) hide show
  1. package/index.js +15 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -87,24 +87,21 @@ export default function (opts = {}) {
87
87
  }
88
88
 
89
89
  if (handlerFile) {
90
- if (handlerFile.endsWith('.ts')) {
91
- // TypeScript needs transpilation - Rollup can't handle .ts natively.
92
- // esbuild is always available (transitive dep via vite -> @sveltejs/kit).
93
- const { transform } = await import('esbuild');
94
- const tsSource = readFileSync(handlerFile, 'utf8');
95
- const { code } = await transform(tsSource, {
96
- loader: 'ts',
97
- format: 'esm',
98
- sourcefile: handlerFile
99
- });
100
- writeFileSync(`${tmp}/ws-handler.js`, code);
101
- } else {
102
- const handlerPath = path.resolve(handlerFile).replace(/\\/g, '/');
103
- writeFileSync(
104
- `${tmp}/ws-handler.js`,
105
- `export * from '${handlerPath}';\n`
106
- );
107
- }
90
+ // Bundle through esbuild to resolve SvelteKit aliases ($lib etc.)
91
+ // and handle TypeScript. Without this, $lib imports survive into
92
+ // the Rollup step which doesn't know about SvelteKit aliases.
93
+ const esbuild = await import('esbuild');
94
+ const libDir = path.resolve(builder.config.kit.files?.lib || 'src/lib');
95
+
96
+ await esbuild.build({
97
+ entryPoints: [path.resolve(handlerFile)],
98
+ bundle: true,
99
+ format: 'esm',
100
+ platform: 'node',
101
+ outfile: `${tmp}/ws-handler.js`,
102
+ alias: { '$lib': libDir },
103
+ packages: 'external'
104
+ });
108
105
  builder.log.minor(`WebSocket handler: ${handlerFile}`);
109
106
  } else {
110
107
  // No handler found - use built-in default (subscribe/unsubscribe only)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-adapter-uws",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "SvelteKit adapter for uWebSockets.js - high-performance C++ HTTP server with built-in WebSocket support",
5
5
  "author": "Kevin Radziszewski",
6
6
  "license": "MIT",