Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit cf82576

Browse files
committed
chore: init
0 parents  commit cf82576

27 files changed

+6988
-0
lines changed

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

Diff for: .eslintrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"env": {
3+
"jest": true
4+
},
5+
"extends": ["@antfu"],
6+
"plugins": ["jest"],
7+
"rules": {}
8+
}

Diff for: .github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [antfu]

Diff for: .github/workflows/release.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: '14'
18+
registry-url: https://registry.npmjs.org/
19+
- run: npm i -g pnpm @antfu/ni
20+
- run: nci
21+
- run: nr test --if-present
22+
# - run: npm publish --access public
23+
# env:
24+
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
25+
- run: npx conventional-github-releaser -p angular
26+
env:
27+
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}

Diff for: .github/workflows/test.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
9+
pull_request:
10+
branches:
11+
- main
12+
- master
13+
14+
jobs:
15+
build:
16+
runs-on: ${{ matrix.os }}
17+
18+
strategy:
19+
matrix:
20+
node-version: [12.x, 14.x]
21+
os: [ubuntu-latest, windows-latest, macos-latest]
22+
fail-fast: false
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- name: Use Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
32+
- name: Setup
33+
run: npm i -g pnpm @antfu/ni
34+
35+
- name: Install
36+
run: nci
37+
38+
# - name: Lint
39+
# run: nr lint --if-present
40+
41+
- name: Test
42+
run: nr test --if-present

Diff for: .gitignore

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Node template
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# nyc test coverage
23+
.nyc_output
24+
25+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26+
.grunt
27+
28+
# Bower dependency directory (https://bower.io/)
29+
bower_components
30+
31+
# node-waf configuration
32+
.lock-wscript
33+
34+
# Compiled binary addons (https://nodejs.org/api/addons.html)
35+
build/Release
36+
37+
# Dependency directories
38+
node_modules/
39+
jspm_packages/
40+
41+
# TypeScript v1 declaration files
42+
typings/
43+
44+
# Optional npm cache directory
45+
.npm
46+
47+
# Optional eslint cache
48+
.eslintcache
49+
50+
# Optional REPL history
51+
.node_repl_history
52+
53+
# Output of 'npm pack'
54+
*.tgz
55+
56+
# Yarn Integrity file
57+
.yarn-integrity
58+
59+
# dotenv environment variables file
60+
.env
61+
62+
# parcel-bundler cache (https://parceljs.org/)
63+
.cache
64+
65+
# next.js build output
66+
.next
67+
68+
# nuxt.js build output
69+
.nuxt
70+
71+
# Nuxt generate
72+
dist
73+
74+
# vuepress build output
75+
.vuepress/dist
76+
77+
# Serverless directories
78+
.serverless
79+
80+
# IDE
81+
.idea

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# vue2-script-setup-transform
2+
3+
[![NPM version](https://img.shields.io/npm/v/vue2-script-setup-transform?color=a1b858&label=)](https://www.npmjs.com/package/vue2-script-setup-transform)
4+
5+
Bring `<script setup>` to Vue 2
6+
7+
## Status
8+
9+
- [x] POC
10+
- [ ] Components registration
11+
- [ ] Compile time macros
12+
- [ ] Merge with normal scripts
13+
14+
## Sponsors
15+
16+
<p align="center">
17+
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
18+
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
19+
</a>
20+
</p>
21+
22+
## License
23+
24+
[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)

Diff for: jest.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
roots: [
3+
'<rootDir>/test',
4+
],
5+
testMatch: [
6+
'**/__tests__/**/*.+(ts|tsx|js)',
7+
'**/?(*.)+(spec|test).+(ts|tsx|js)',
8+
],
9+
transform: {
10+
'^.+\\.(ts|tsx)$': 'ts-jest',
11+
},
12+
}

Diff for: package.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "vue2-script-setup-transform",
3+
"version": "0.0.0",
4+
"description": "",
5+
"main": "dist/index.js",
6+
"module": "dist/index.mjs",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"require": "./dist/index.js",
11+
"import": "./dist/index.mjs"
12+
}
13+
},
14+
"funding": "https://github.com/sponsors/antfu",
15+
"author": "Anthony Fu <[email protected]>",
16+
"license": "MIT",
17+
"sideEffects": false,
18+
"bugs": {
19+
"url": "https://github.com/antfu/vue2-script-setup-transform/issues"
20+
},
21+
"homepage": "https://github.com/antfu/vue2-script-setup-transform#readme",
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/antfu/vue2-script-setup-transform.git"
25+
},
26+
"keywords": [],
27+
"files": [
28+
"dist"
29+
],
30+
"scripts": {
31+
"prepublishOnly": "nr build",
32+
"dev": "nr build --watch",
33+
"start": "esno src/index.ts",
34+
"build": "tsup src/index.ts --format cjs,esm --dts --no-splitting",
35+
"play": "npm -C playground run dev",
36+
"release": "bumpp --commit --push --tag && pnpm publish",
37+
"lint": "eslint \"{src,test}/**/*.ts\"",
38+
"lint:fix": "nr lint -- --fix",
39+
"test": "jest",
40+
"test:update": "jest -u"
41+
},
42+
"devDependencies": {
43+
"@antfu/eslint-config": "^0.7.0",
44+
"@antfu/ni": "^0.7.0",
45+
"@types/jest": "^26.0.24",
46+
"@types/node": "^16.4.12",
47+
"bumpp": "^6.0.6",
48+
"eslint": "^7.32.0",
49+
"eslint-plugin-jest": "^24.4.0",
50+
"esno": "^0.8.0",
51+
"jest": "^27.0.6",
52+
"ts-jest": "^27.0.4",
53+
"tsup": "^4.13.1",
54+
"typescript": "^4.3.5"
55+
},
56+
"dependencies": {
57+
"@babel/parser": "^7.15.3",
58+
"@babel/traverse": "^7.15.0",
59+
"@babel/types": "^7.15.0",
60+
"@vue/shared": "^3.2.4",
61+
"estree-walker": "^3.0.0",
62+
"htmlparser2": "^6.1.0",
63+
"magic-string": "^0.25.7"
64+
}
65+
}

Diff for: playground/App.vue

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template>
2+
<div>
3+
<button @click="inc">
4+
Inc
5+
</button>
6+
<div>{{ count }} x 2 = {{ doubled }}</div>
7+
<button @click="dec()" v-html="decText" />
8+
</div>
9+
</template>
10+
11+
<script setup lang="ts">
12+
import { ref, computed } from '@vue/composition-api'
13+
14+
const count = ref(0)
15+
const doubled = computed(() => count.value * 2)
16+
17+
function inc() {
18+
count.value += 1
19+
}
20+
21+
function dec() {
22+
count.value += 1
23+
}
24+
25+
const decText = '<b>Dec</b>'
26+
</script>

Diff for: playground/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<link rel="icon" href="/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Vite App</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="./main.ts"></script>
12+
</body>
13+
</html>

Diff for: playground/main.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Vue from 'vue'
2+
import VueComposisionAPI from '@vue/composition-api'
3+
import App from './App.vue'
4+
5+
Vue.use(VueComposisionAPI)
6+
7+
const app = new Vue({
8+
render: h => h(App),
9+
})
10+
app.$mount('#app')

Diff for: playground/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite --open"
5+
},
6+
"dependencies": {
7+
"@vue/composition-api": "^1.1.1",
8+
"vue": "^2.6.14"
9+
},
10+
"devDependencies": {
11+
"@vue/reactivity": "^3.2.4",
12+
"vite": "^2.5.0",
13+
"vite-plugin-inspect": "^0.2.1",
14+
"vite-plugin-vue2": "^1.8.1",
15+
"vue-template-compiler": "^2.6.14"
16+
}
17+
}

Diff for: playground/vite.config.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineConfig } from 'vite'
2+
import { createVuePlugin as Vue2 } from 'vite-plugin-vue2'
3+
import Inspect from 'vite-plugin-inspect'
4+
import { transform } from '../src'
5+
6+
export default defineConfig({
7+
plugins: [
8+
Vue2(),
9+
Inspect(),
10+
{
11+
name: 'vue2-script-setup-transform',
12+
enforce: 'pre',
13+
transform(code, id) {
14+
if (id.endsWith('.vue'))
15+
return transform(code)
16+
},
17+
},
18+
],
19+
})

0 commit comments

Comments
 (0)