diff --git a/.eslintignore b/.eslintignore index de4d1f0..8704933 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ dist node_modules +*.vue diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 054e238..88725e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,13 +8,15 @@ on: jobs: release: runs-on: ubuntu-latest + permissions: + contents: write steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - uses: actions/setup-node@v2 with: - node-version: '14' + node-version: lts/* registry-url: https://registry.npmjs.org/ - run: npm i -g pnpm @antfu/ni - run: nci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d00e33..fde9231 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - node: [14.x] + node: [18.x] os: [ubuntu-latest, windows-latest, macos-latest] fail-fast: false @@ -25,15 +25,13 @@ jobs: - uses: actions/checkout@v2 - name: Install pnpm - uses: pnpm/action-setup@v2.0.1 - with: - version: 6.23.5 + uses: pnpm/action-setup@v2 - name: Set node version to ${{ matrix.node }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} - cache: "pnpm" + cache: pnpm - uses: actions/checkout@v2 diff --git a/.npmrc b/.npmrc index bac7fb0..0483dfa 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,2 @@ -shamefully-hoist=true ignore-workspace-root-check=true +strict-peer-dependencies=false diff --git a/README.md b/README.md index d389f8b..91f4c1d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Bring [` - - -``` - -###### TypeScript - -To use TypeScript with Nuxt, install the [`@nuxtjs/typescript-module`](https://typescript.nuxtjs.org/) but disable the type check: - -```bash -npm i -D @nuxt/typescript-build vue-tsc -``` - -```ts -// nuxt.config.js -export default { - buildModules: [ - ['@nuxt/typescript-build', { typeCheck: false }], - '@nuxtjs/composition-api/module', - 'unplugin-vue2-script-setup/nuxt', - ], -} -``` - -And then use [`vue-tsc`](https://github.com/johnsoncodehk/volar) to do the type check at build time: - -```jsonc -// package.json -{ - "scripts": { - "dev": "nuxt", - "build": "vue-tsc --noEmit && nuxt build" - } -} -``` +> It's built-in in [Nuxt Bridge](https://github.com/nuxt/bridge). -
+
Vue CLI
@@ -123,7 +58,7 @@ And then use [`vue-tsc`](https://github.com/johnsoncodehk/volar) to do the type const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default module.exports = { - parallel: false, // disable thread-loader, which is not compactible with this plugin + parallel: false, // disable thread-loader, which is not compactible with this plugin configureWebpack: { plugins: [ ScriptSetup({ /* options */ }), @@ -144,6 +79,7 @@ npm i -D @vue/cli-plugin-typescript vue-tsc ```ts const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default + module.exports = { parallel: false, configureWebpack: { @@ -178,6 +114,7 @@ And then use [`vue-tsc`](https://github.com/johnsoncodehk/volar) to do the type ```ts // webpack.config.js const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default + module.exports = { /* ... */ plugins: [ @@ -213,6 +150,7 @@ export default { // esbuild.config.js import { build } from 'esbuild' import ScriptSetup from 'unplugin-vue2-script-setup/esbuild' + build({ /* ... */ plugins: [ @@ -249,7 +187,7 @@ module.exports = { ```ts import { transform } from 'unplugin-vue2-script-setup' -const Vue2SFC = transform(` +const Vue2SFC = await transform(` @@ -295,11 +233,11 @@ Volar preferentially supports Vue 3. Vue 3 and Vue 2 template has some different ```jsonc { "compilerOptions": { - ... + // ... }, "vueCompilerOptions": { - "experimentalCompatMode": 2 - }, + "target": 2 + } } ``` diff --git a/esbuild.d.ts b/esbuild.d.ts index c882474..c7f713d 100644 --- a/esbuild.d.ts +++ b/esbuild.d.ts @@ -1,2 +1 @@ -import './shims' export { default } from './dist/esbuild' diff --git a/examples/nuxt-bridge/README.md b/examples/nuxt-bridge/README.md deleted file mode 100644 index d5a58db..0000000 --- a/examples/nuxt-bridge/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Nuxt Bridge - -This plugin has been included in Nuxt Bridge out-of-the-box. This example only serves the purpose of testing the plugin integration with Nuxt Bridge. diff --git a/examples/nuxt-bridge/layouts/default.vue b/examples/nuxt-bridge/layouts/default.vue deleted file mode 100644 index 770674e..0000000 --- a/examples/nuxt-bridge/layouts/default.vue +++ /dev/null @@ -1,11 +0,0 @@ - - - diff --git a/examples/nuxt-bridge/nuxt.config.ts b/examples/nuxt-bridge/nuxt.config.ts deleted file mode 100644 index f3184f0..0000000 --- a/examples/nuxt-bridge/nuxt.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { defineNuxtConfig } from '@nuxt/bridge' - -export default defineNuxtConfig({ - components: true, - bridge: { - meta: true, - vite: true, - }, -}) diff --git a/examples/nuxt-bridge/package.json b/examples/nuxt-bridge/package.json deleted file mode 100644 index fe7859f..0000000 --- a/examples/nuxt-bridge/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "example-bridge", - "private": true, - "scripts": { - "build": "nuxi build", - "dev": "nuxi dev" - }, - "devDependencies": { - "@nuxt/bridge": "latest", - "nuxt-edge": "latest", - "vue": "^2.6.14", - "vue2": "npm:vue@^2.6.14" - } -} diff --git a/examples/nuxt-bridge/pages/index.vue b/examples/nuxt-bridge/pages/index.vue deleted file mode 100644 index 7448b07..0000000 --- a/examples/nuxt-bridge/pages/index.vue +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/examples/nuxt-bridge/pages/test/_slug.vue b/examples/nuxt-bridge/pages/test/_slug.vue deleted file mode 100644 index ed1ce39..0000000 --- a/examples/nuxt-bridge/pages/test/_slug.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/examples/nuxt-bridge/tsconfig.json b/examples/nuxt-bridge/tsconfig.json deleted file mode 100644 index 4b34df1..0000000 --- a/examples/nuxt-bridge/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./.nuxt/tsconfig.json" -} diff --git a/examples/vue-cli/package.json b/examples/vue-cli/package.json index 261323e..1d7fe0d 100644 --- a/examples/vue-cli/package.json +++ b/examples/vue-cli/package.json @@ -2,24 +2,23 @@ "name": "vue-cli", "private": true, "scripts": { + "type-check": "vue-tsc --noEmit", "dev": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, "dependencies": { - "@vue/composition-api": "^1.4.3", - "core-js": "^3.20.2", - "vue": "^2.6.14" + "@vue/composition-api": "^1.7.1", + "core-js": "^3.32.0", + "vue": "~2.6.14" }, "devDependencies": { - "@vue/cli-plugin-babel": "^4.5.15", - "@vue/cli-plugin-typescript": "^4.5.15", - "@vue/cli-service": "^4.5.15", - "typescript": "^4.5.4", + "@vue/cli-plugin-babel": "^5.0.8", + "@vue/cli-plugin-typescript": "^5.0.8", + "@vue/cli-service": "^5.0.8", + "typescript": "^5.1.6", "unplugin-vue2-script-setup": "workspace:*", - "vue-template-compiler": "^2.6.14" - }, - "vueCompilerOptions": { - "experimentalCompatMode": 2 + "vue-template-compiler": "~2.6.14", + "vue-tsc": "^1.8.8" } } diff --git a/examples/vue-cli/tsconfig.json b/examples/vue-cli/tsconfig.json index aaea037..31d74df 100644 --- a/examples/vue-cli/tsconfig.json +++ b/examples/vue-cli/tsconfig.json @@ -26,6 +26,6 @@ "node_modules" ], "vueCompilerOptions": { - "experimentalCompatMode": 2 + "target": 2 } } diff --git a/examples/vue-cli/vue.config.js b/examples/vue-cli/vue.config.cjs similarity index 82% rename from examples/vue-cli/vue.config.js rename to examples/vue-cli/vue.config.cjs index e2789a3..cfe8aca 100644 --- a/examples/vue-cli/vue.config.js +++ b/examples/vue-cli/vue.config.cjs @@ -1,11 +1,7 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ - +const { defineConfig } = require('@vue/cli-service') const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default -/** - * @type {import('@vue/cli-service').ProjectOptions} - */ -module.exports = { +module.exports = defineConfig({ configureWebpack: { plugins: [ ScriptSetup({ @@ -24,4 +20,4 @@ module.exports = { config.module.rule('ts').uses.delete('cache-loader') config.module.rule('tsx').uses.delete('cache-loader') }, -} +}) diff --git a/index.d.ts b/index.d.ts index cc8b2ef..5437e96 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,2 +1 @@ -import './shims' export { default } from './dist/index' diff --git a/jest.js b/jest.js index bf42d7c..802eaa6 100644 --- a/jest.js +++ b/jest.js @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ const { transform } = require('./dist/index') function requireVueJest() { @@ -15,8 +14,8 @@ function requireVueJest() { } module.exports = { - process(source, filename, ...args) { - const transformed = transform(source, filename) + async process(source, filename, ...args) { + const transformed = await transform(source, filename) const code = transformed ? transformed.code : source return requireVueJest().process.call(this, code, filename, ...args) }, diff --git a/nuxt.d.ts b/nuxt.d.ts index b08cd2c..3a5fdb3 100644 --- a/nuxt.d.ts +++ b/nuxt.d.ts @@ -1,2 +1 @@ -import './shims' export { default } from './dist/nuxt' diff --git a/package.json b/package.json index ae6a1d5..b8157d3 100644 --- a/package.json +++ b/package.json @@ -1,58 +1,52 @@ { "name": "unplugin-vue2-script-setup", - "version": "0.9.3", + "version": "0.11.4", + "packageManager": "pnpm@8.6.11", "description": "Bring