vite-plugin-ts
Advanced tools
Comparing version 1.1.3 to 1.1.7
@@ -0,1 +1,44 @@ | ||
## [1.1.7](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.6...plugin-vue-jsx@1.1.7) (2021-07-27) | ||
### Bug Fixes | ||
* **deps:** update all non-major dependencies ([#4387](https://github.com/vitejs/vite/issues/4387)) ([2f900ba](https://github.com/vitejs/vite/commit/2f900ba4d4ad8061e0046898e8d1de3129e7f784)) | ||
## [1.1.6](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.5...plugin-vue-jsx@1.1.6) (2021-06-27) | ||
### Bug Fixes | ||
* **deps:** update all non-major dependencies ([#3791](https://github.com/vitejs/vite/issues/3791)) ([74d409e](https://github.com/vitejs/vite/commit/74d409eafca8d74ec4a6ece621ea2895bc1f2a32)) | ||
* **plugin-vue-jsx:** replace default export with helper during SSR ([#3966](https://github.com/vitejs/vite/issues/3966)) ([bc86464](https://github.com/vitejs/vite/commit/bc86464d3c6591eae96e070a1724a3f21874c8ce)) | ||
* **ssr:** normalize manifest filenames ([#3706](https://github.com/vitejs/vite/issues/3706)) ([aa8ca3f](https://github.com/vitejs/vite/commit/aa8ca3f35218c9fb48f87d3f6f4681d379ee45ca)), closes [#3303](https://github.com/vitejs/vite/issues/3303) | ||
### Features | ||
* **plugin-vue-jsx:** jsx plugin should have extra babel plugins option ([#3923](https://github.com/vitejs/vite/issues/3923)) ([aada0c5](https://github.com/vitejs/vite/commit/aada0c5e71e4826cf049596f3459d48b386ea4da)) | ||
## [1.1.5](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.4...plugin-vue-jsx@1.1.5) (2021-06-01) | ||
### Bug Fixes | ||
* include/exclude options for vue-jsx .d.ts ([#3573](https://github.com/vitejs/vite/issues/3573)) ([82ec0ca](https://github.com/vitejs/vite/commit/82ec0ca69c1f077cf518073edca4e6580ebd4892)) | ||
## [1.1.4](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.3...plugin-vue-jsx@1.1.4) (2021-05-03) | ||
### Features | ||
* include/exclude options for vue-jsx plugin ([#1953](https://github.com/vitejs/vite/issues/1953)) ([fbecf1e](https://github.com/vitejs/vite/commit/fbecf1e5349ea5da8ff6f194efdcb152e2995398)) | ||
## [1.1.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.2...plugin-vue-jsx@1.1.3) (2021-03-31) | ||
@@ -2,0 +45,0 @@ |
import { Plugin } from 'vite' | ||
import { VueJSXPluginOptions } from '@vue/babel-plugin-jsx' | ||
import { FilterPattern } from '@rollup/pluginutils' | ||
export type Options = VueJSXPluginOptions | ||
declare interface FilterOptions { | ||
include?: FilterPattern | ||
exclude?: FilterPattern | ||
} | ||
declare function createPlugin(options?: Options): Plugin | ||
declare function createPlugin( | ||
options?: VueJSXPluginOptions & FilterOptions & { babelPlugins?: any[] } | ||
): Plugin | ||
export default createPlugin |
37
index.js
@@ -5,4 +5,5 @@ const fs = require('fs') | ||
const importMeta = require('@babel/plugin-syntax-import-meta') | ||
const { createFilter } = require('@rollup/pluginutils') | ||
const { createFilter, normalizePath } = require('@rollup/pluginutils') | ||
const hash = require('hash-sum') | ||
const path = require('path') | ||
@@ -34,3 +35,3 @@ const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper' | ||
* @typedef { import('@rollup/pluginutils').FilterPattern} FilterPattern | ||
* @typedef { { include?: FilterPattern, exclude?: FilterPattern } } CommonOtions | ||
* @typedef { { include?: FilterPattern, exclude?: FilterPattern, babelPlugins?: any[] } } CommonOptions | ||
*/ | ||
@@ -40,6 +41,7 @@ | ||
* | ||
* @param {import('@vue/babel-plugin-jsx').VueJSXPluginOptions & CommonOtions} options | ||
* @param {import('@vue/babel-plugin-jsx').VueJSXPluginOptions & CommonOptions} options | ||
* @returns {import('vite').Plugin} | ||
*/ | ||
function tsPlugin(options = {}) { | ||
let root = '' | ||
let needHmr = false | ||
@@ -68,2 +70,3 @@ let needSourceMap = true | ||
needSourceMap = config.command === 'serve' || !!config.build.sourcemap | ||
root = config.root | ||
}, | ||
@@ -84,3 +87,8 @@ | ||
transform(code, id, ssr) { | ||
const { include, exclude, ...babelPluginOptions } = options | ||
const { | ||
include, | ||
exclude, | ||
babelPlugins = [], | ||
...babelPluginOptions | ||
} = options | ||
@@ -122,3 +130,3 @@ const filter = createFilter(include || /\.(jsx|tsx?)$/, exclude) | ||
/** @type {any[]} */ | ||
const plugins = [importMeta] | ||
const plugins = [importMeta, ...babelPlugins] | ||
if (id.endsWith('x')) plugins.push([jsx, babelPluginOptions]) | ||
@@ -225,12 +233,12 @@ | ||
if (hotComponents.length) { | ||
if (hasDefault && (needHmr || ssr)) { | ||
result.code = | ||
result.code.replace( | ||
/export default defineComponent/g, | ||
`const __default__ = defineComponent` | ||
) + `\nexport default __default__` | ||
} | ||
if (needHmr && !ssr) { | ||
let code = result.code | ||
if (hasDefault) { | ||
code = | ||
code.replace( | ||
/export default defineComponent/g, | ||
`const __default__ = defineComponent` | ||
) + `\nexport default __default__` | ||
} | ||
let callbackCode = `` | ||
@@ -252,5 +260,6 @@ for (const { local, exported, id } of hotComponents) { | ||
if (ssr) { | ||
const normalizedId = normalizePath(path.relative(root, id)) | ||
let ssrInjectCode = | ||
`\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"` + | ||
`\nconst __moduleId = ${JSON.stringify(id)}` | ||
`\nconst __moduleId = ${JSON.stringify(normalizedId)}` | ||
for (const { local } of hotComponents) { | ||
@@ -257,0 +266,0 @@ ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)` |
{ | ||
"name": "vite-plugin-ts", | ||
"version": "1.1.3", | ||
"version": "1.1.7", | ||
"license": "MIT", | ||
@@ -37,9 +37,9 @@ "author": "Evan You", | ||
"dependencies": { | ||
"@babel/core": "^7.13.16", | ||
"@babel/core": "^7.14.8", | ||
"@babel/plugin-syntax-import-meta": "^7.10.4", | ||
"@rollup/pluginutils": "^4.1.0", | ||
"@vue/babel-plugin-jsx": "^1.0.5", | ||
"@rollup/pluginutils": "^4.1.1", | ||
"@vue/babel-plugin-jsx": "^1.0.6", | ||
"hash-sum": "^2.0.0", | ||
"typescript": "^4.2.4" | ||
"typescript": "^4.3.5" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16867
285
Updated@babel/core@^7.14.8
Updated@rollup/pluginutils@^4.1.1
Updated@vue/babel-plugin-jsx@^1.0.6
Updatedtypescript@^4.3.5