Giter Club home page Giter Club logo

vite-plugin-squint's Introduction

squint-vite-plugin

A Squint plugin for Vite. Very early in it's development.

Demos

Squint + Vite (Vanilla)

This is the vite vanilla template with javascript removed and squint added. To play around with it:

cd demo/vanilla
# install dependencies
npm i
# run dev mode
npm run dev
# run build
npm run build
# run preview
npm run preview

React + Squint + Vite

This is the vite + react template with squint added. To play around with it:

cd demo/react
# install dependencies
npm i
# run dev mode
npm run dev
# run build
npm run build
# run preview
npm run preview

Preact + Squint + Vite

This is the vite + preact template with squint added. To play around with it:

cd demo/preact
# install dependencies
npm i
# run dev mode
npm run dev
# run build
npm run build
# run preview
npm run preview

Solid + Squint + Vite

This is the vite + solid template with squint added. To play around with it:

cd demo/solid
# install dependencies
npm i
# run dev mode
npm run dev
# run build
npm run build
# run preview
npm run preview

Qwik + Squint + Vite

This is the vite + qwik template with squint added. To play around with it:

cd demo/qwik
# install dependencies
npm i
# run dev mode
npm run dev
# run build
npm run build
# run preview
npm run preview

Currently unsupported / TODO

  • vite dev / Hot-Module-Reloading (HMR)
  • Squint Macros

vite-plugin-squint's People

Contributors

brandonstubbs avatar martinklepsch avatar borkdude avatar

Stargazers

Desmond Wang avatar

Watchers

 avatar  avatar  avatar

vite-plugin-squint's Issues

Repo name/ plugin name

Hey!

just wanted to share these conventions before we make a first release to NPM, I think vite-plugin-squint would adhere to their conventions.

I think technically this might also be a rollup plugin (vite is a superset of rollup in terms of their plugin API) but I don't have a strong opinion on that. Will explore the differences a bit more and report back.

Proper HMR Support

I don't fully grasp the details yet but I found this code from a haxe vite plugin. Could be that's all thats needed:

https://github.com/ciscoheat/vite-plugin-haxe/blob/2cb147281285ca533b1d21da625718538db5d7a5/src/index.ts#L42-L54

    handleHotUpdate(event) {
      let files: string[];
      if (event.file.endsWith(".hx")) files = Array.from(hxmlFiles.keys());
      else if (!event.file.endsWith(".hxml")) files = [event.file];
      else return;

      files.forEach((hxml) => {
        const module = event.server.moduleGraph.getModuleById(hxml);
        if (module) {
          event.server.reloadModule(module);
        }
      });
    },

NPM Package Dependencies

As we link to the root projects in the demos package.json

"vite-plugin-squint": "file:../.."

It seems that if you have not run npm i in the root project, npm won't resolve linked project dependencies automatically. Thus on a fresh checkout and going into a demo and running npm i npm run dev you get dependency errors on the dependencies the plugin is using.

I am not sure how to solve this with file linking?

cc: @borkdude @martinklepsch

Support direct imports of `cljs` in index.html

We could support direct imports of cljs files in the index.html.

This will allow them to specify a script tag like the following (Instead of the js file we have currently):

<script type="module" src="index.cljs"></script>

In order to support this we will need to plug into vite's transformindexhtml. We would write the code to rewrite the script tag to:

<script type="module" src="index.cljs.jsx"></script>

Then the rest of the plugin will work as usual.

It is not usual to see source files that the browser does not support in HTML. While this is possible, we need to decide if we want to support it as it's very vite specific, and the same index.html would not work if you switch tooling.

Official plugins like the one for vue does not support their custom extensions.

> npm create vite@latest
# choose the vue template

> cat index.html
...
<script type="module" src="/src/main.js"></script>
...

> cat src/main.js
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

createApp(App).mount('#app')

Test on Windows

Once we are happy with things we need to test this on windows to make sure the file paths don't cause any issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.