Git Product home page Git Product logo

unplugin-vue-tsx-auto-props's Introduction


unplugin-vue-tsx-auto-props

NPM version

Why?

Vue does not provide a way to automatically specify props for functional components written in TSX. This plugin solves this problem.

Before:

import { defineComponent } from "vue";

interface Props {
	foo: string;
}

const Foo = defineComponent((props: Props) => () => <div>{props.foo}</div>);
Foo.props = ["foo"]; // πŸ‘ˆ You need to manually specify the props :(

After:

import { defineComponent } from "vue";

interface Props {
	foo: string;
}

const Foo = defineComponent((props: Props) => () => <div>{props.foo}</div>);
Object.defineProperty(Foo, "props", {
	value: ["foo"],
}); // πŸ‘ˆ This plugin will do it for you!

πŸ“¦ Installation

$ npm install -D unplugin-vue-tsx-auto-props
$ yarn add -D unplugin-vue-tsx-auto-props
$ pnpm add -D unplugin-vue-tsx-auto-props

πŸš€ Usage

Vite
// vite.config.ts
import VueTsxAutoProps from "unplugin-vue-tsx-auto-props/vite";

export default defineConfig({
	plugins: [
		VueTsxAutoProps({
			/* options */
		}),
	],
});


Rollup
// rollup.config.js
import VueTsxAutoProps from "unplugin-vue-tsx-auto-props/rollup";

export default {
	plugins: [
		VueTsxAutoProps({
			/* options */
		}),
		// other plugins
	],
};


Webpack
// webpack.config.js
module.exports = {
	/* ... */
	plugins: [
		require("unplugin-vue-tsx-auto-props/webpack")({
			/* options */
		}),
	],
};


Nuxt
// nuxt.config.ts
export default defineNuxtConfig({
	modules: ["unplugin-vue-tsx-auto-props/nuxt"],
});


Vue CLI
// vue.config.js
module.exports = {
	configureWebpack: {
		plugins: [
			require("unplugin-vue-tsx-auto-props/webpack")({
				/* options */
			}),
		],
	},
};


Quasar
// quasar.conf.js [Vite]
module.exports = {
	vitePlugins: [
		[
			"unplugin-vue-tsx-auto-props/vite",
			{
				/* options */
			},
		],
	],
};
// quasar.conf.js [Webpack]
const VueTsxAutoPropsPlugin = require("unplugin-vue-tsx-auto-props/webpack");

module.exports = {
	build: {
		chainWebpack(chain) {
			chain.plugin("unplugin-vue-tsx-auto-props").use(
				VueTsxAutoPropsPlugin({
					/* options */
				}),
			);
		},
	},
};


esbuild
// esbuild.config.js
import { build } from "esbuild";

build({
	/* ... */
	plugins: [
		require("unplugin-vue-tsx-auto-props/esbuild")({
			/* options */
		}),
	],
});


Astro
// astro.config.mjs
import VueTsxAutoProps from "unplugin-vue-tsx-auto-props/astro";

export default defineConfig({
	integrations: [
		VueTsxAutoProps({
			/* options */
		}),
	],
});


πŸ“ License

MIT. Made with ❀️ by Ray

unplugin-vue-tsx-auto-props's People

Contributors

renovate[bot] avatar so1ve avatar autofix-ci[bot] avatar kyle1an avatar

Stargazers

Kuqoi avatar jiaxiangZhang avatar 郝晨光 avatar CJBoy avatar η™½ι›ΎδΈ‰θ―­ avatar Kevin Deng 三咲智子 avatar Artem Melnyk avatar xsfour avatar Mo avatar Agan avatar varHarrie avatar JasKang avatar chenglu avatar Emmanuel Salomon avatar jinwandalaohu avatar Richard Zhang avatar Benny Eu avatar Zhazha_JiaYiZhen avatar Harry Tran avatar Skywalker512 avatar antx avatar Algernon avatar  avatar Ehsan Shahvirdi avatar Sandalots avatar Baki avatar Qin Guan avatar Alex Yang avatar Muhammad Ubaid Raza avatar  avatar  avatar markthree avatar Melih Ozdemir avatar Nouvistiardi avatar Hazel avatar Anthony Fu avatar leokun avatar Lockinwize Lolite avatar zhuddan avatar enpitsulin avatar  avatar

Watchers

 avatar

unplugin-vue-tsx-auto-props's Issues

🍳 Renovate Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: File contents are invalid JSON but parse using JSON5. Support for this will be removed in a future release so please change to a support .json5 file name or ensure correct JSON syntax.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency rollup to v4
  • chore(deps): update dependency tsx to v4
  • chore(deps): update dependency unbuild to v2
  • chore(deps): update dependency vite to v5
  • chore(deps): update dessant/lock-threads action to v5
  • πŸ” Create all pending approval PRs at once πŸ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update dependency @antfu/ni to v0.21.12
  • chore(deps): update dependency vitest to v0.34.6
  • fix(deps): update dependency magic-string to v0.30.5
  • fix(deps): update all non-major dependencies (@babel/parser, @babel/traverse, @babel/types, @nuxt/kit, @nuxt/schema, @types/babel__traverse, @types/node, eslint, rollup, tsx, typescript, unplugin, vite, webpack)

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/autofix-ci.yml
  • actions/checkout v3
  • actions/setup-node v3
  • autofix-ci/action bee19d72e71787c12ca0f29de72f2833e437e4c9
.github/workflows/ci.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/checkout v3
  • actions/setup-node v3
  • actions/checkout v3
  • actions/setup-node v3
.github/workflows/lock.yml
  • dessant/lock-threads v4
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @babel/parser ^7.21.9
  • @babel/traverse ^7.21.5
  • @babel/types ^7.21.5
  • @nuxt/kit ^3.5.1
  • magic-string ^0.30.0
  • unplugin ^1.3.1
  • @antfu/ni ^0.21.3
  • @nuxt/schema ^3.5.1
  • @so1ve/eslint-config ^0.120.2
  • @so1ve/prettier-config ^0.120.2
  • @types/babel__traverse ^7.20.0
  • @types/node ^18.16.15
  • bumpp ^9.1.0
  • eslint ^8.41.0
  • rollup ^3.23.0
  • tsx ^3.12.7
  • typescript ^5.0.4
  • unbuild ^1.2.1
  • vite ^4.3.9
  • vitest ^0.34.0
  • webpack ^5.84.1
  • typescript *
  • pnpm 8.11.0

  • Check this box to trigger a request for Renovate to run again on this repository

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.