0.16.1 • Published 2 months ago

tvkit v0.16.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

TVKit

A proxy server which allows using modern dev servers in old browsers. "Run SvelteKit on a TV"

TVKit intercepts requests to a webserver and converts the responses to make them work in old browsers. This works by injecting polyfills and transpiling the modern JavaScript and CSS to code that's compatible with older browsers.

Usage (dev server)

  • Start your vite project as normal
  • Run npx tvkit@latest serve --browser "chrome 50" in another terminal
  • Open http://localhost:3000/ in an old browser to visit your website

tvkit serve

OptionDefault valueDescription
targethttp://localhost:5173The URL of the website that is too new
--port3000The port the proxy server is going to run on
--browserThe transpilation target (uses browserslist)
--addOverride feature. Ex --add "es6-module" forces adding systemjs polyfill
--removeOverride feature: Ex --remove fetch forces omitting whatwg-fetch polyfill
--no-cssfalseDisable CSS transpilation
--ssl-certPath to the SSL certificate for https
--ssl-keyPath to the SSL certificate's private key
--no-minifyfalseDisable minificaton for the polyfills
--helpShow message per command. Ex: tvkit serve --help

TVKit adds browser aliases for SmartTV platforms: Example --browser "Tizen 5" is aliased to Chrome 63

Start tvkit & servers at the same time

Use concurrently to start both servers at the same time:

// package.json
"scripts": {
  "dev": "concurrently --kill-others-on-fail \"npm:dev:*\"",
  "dev:vite": "vite dev",
  "dev:tvkit": "tvkit serve --browser \"Tizen 4, WebOS 4\"",

Usage (build)

Copy folder contents and transform all html, js & css files into new directory.

Build your project for modern browsers (example: vite build) and then use the tvkit build to convert the generated folder into something that is compatible for older browsers.

npx tvkit@latest build path/to/build --out path/to/output --browser "chrome 50"

tvkit build

OptionDefault valueDescription
folderThe folder containing modern javascript
--outThe output folder
--browserThe transpilation target (uses browserslist)
--forcefalseOverwrite files in output folder
--addOverride feature. Ex --add "es6-module" forces adding systemjs polyfill
--removeOverride feature: Ex --remove fetch forces omitting whatwg-fetch polyfill
--no-cssfalseDisable CSS transpilation
--no-minifyfalseDisable minificaton
--quietfalseOnly log errors
--helpShow message per command. Ex: tvkit build --help

Note: Polyfilling will degrade the performance for platforms that could've run the modern javascript version. An alternative to tvkit build is using @vitejs/plugin-legacy which has better performance on modern browsers, but doesn't work for some project setups (like SvelteKit projects).

TVKit supports static builds from any framework and has special support for SvelteKit's node-adapter & vercel-adapter builds.

Technology

Consider funding these projects as they do a lot of the heavy lifting.