Skip to content

Commit

Permalink
feat: support jsx, closes element-plus#5708 (element-plus#5947)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Feb 11, 2022
1 parent 23c7c78 commit 879ea6d
Show file tree
Hide file tree
Showing 12 changed files with 1,414 additions and 178 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = defineConfig({
files: ['**/__tests__/**', '**/gulpfile.ts'],
rules: {
'no-console': 'off',
'vue/one-component-per-file': 'off',
},
},
],
Expand Down
8 changes: 8 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// For jest use only
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
plugins: ['@vue/babel-plugin-jsx'],
}
2 changes: 2 additions & 0 deletions build/full-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { rollup } from 'rollup'
import commonjs from '@rollup/plugin-commonjs'
import vue from '@vitejs/plugin-vue'
import DefineOptions from 'unplugin-vue-define-options/vite'
import vueJsx from '@vitejs/plugin-vue-jsx'
import esbuild from 'rollup-plugin-esbuild'
import replace from '@rollup/plugin-replace'
import filesize from 'rollup-plugin-filesize'
Expand Down Expand Up @@ -35,6 +36,7 @@ async function buildFullEntry(minify: boolean) {
vue({
isProduction: true,
}) as Plugin,
vueJsx(),
nodeResolve({
extensions: ['.mjs', '.js', '.json', '.ts'],
}),
Expand Down
2 changes: 2 additions & 0 deletions build/modules.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { rollup } from 'rollup'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import DefineOptions from 'unplugin-vue-define-options/vite'
import css from 'rollup-plugin-css-only'
import { nodeResolve } from '@rollup/plugin-node-resolve'
Expand Down Expand Up @@ -32,6 +33,7 @@ export const buildModules = async () => {
vue({
isProduction: false,
}),
vueJsx(),
nodeResolve({
extensions: ['.mjs', '.js', '.json', '.ts'],
}),
Expand Down
2 changes: 2 additions & 0 deletions docs/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DefineOptions from 'unplugin-vue-define-options/vite'
import WindiCSS from 'vite-plugin-windicss'
import mkcert from 'vite-plugin-mkcert'
import glob from 'fast-glob'
import vueJsx from '@vitejs/plugin-vue-jsx'

import Components from 'unplugin-vue-components/vite'
import Icons from 'unplugin-icons/vite'
Expand Down Expand Up @@ -70,6 +71,7 @@ export default async () => {
},
},
plugins: [
vueJsx(),
DefineOptions(),

// https://github.com/antfu/unplugin-vue-components
Expand Down
11 changes: 1 addition & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@
* @type import('@jest/types').Config.InitialOptions
*/
module.exports = {
globals: {
// work around: https://github.com/kulshekhar/ts-jest/issues/748#issuecomment-423528659
'ts-jest': {
diagnostics: {
ignoreCodes: [151001],
},
},
},
setupFiles: ['./jest.setup.js'],
testPathIgnorePatterns: ['/node_modules/', 'dist'],
modulePathIgnorePatterns: ['/node_modules/', 'dist', 'cypress'],
testEnvironment: 'jsdom',
transform: {
// Doesn't support jsx/tsx since sucrase doesn't support Vue JSX
'\\.(j|t)s$': '@sucrase/jest-plugin',
'\\.[jt]sx?$': 'babel-jest',
'^.+\\.vue$': '<rootDir>/build/vue-jest-transformer.js',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'vue'],
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
"normalize-wheel-es": "^1.1.1"
},
"devDependencies": {
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@commitlint/cli": "16.1.0",
"@commitlint/config-conventional": "16.0.0",
"@pnpm/find-workspace-packages": "3.1.40",
Expand All @@ -81,7 +84,6 @@
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-node-resolve": "13.1.3",
"@rollup/plugin-replace": "3.0.1",
"@sucrase/jest-plugin": "2.2.0",
"@types/fs-extra": "9.0.13",
"@types/gulp": "4.0.9",
"@types/jest": "26.0.24",
Expand All @@ -92,7 +94,10 @@
"@typescript-eslint/eslint-plugin": "5.11.0",
"@typescript-eslint/parser": "5.11.0",
"@vitejs/plugin-vue": "2.2.0",
"@vitejs/plugin-vue-jsx": "^1.3.3",
"@vue/babel-plugin-jsx": "^1.1.1",
"@vue/test-utils": "2.0.0-rc.16",
"babel-jest": "26.6.3",
"chalk": "4.1.2",
"components-helper": "2.0.0",
"csstype": "2.6.19",
Expand Down
2 changes: 2 additions & 0 deletions play/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Inspect from 'vite-plugin-inspect'
Expand Down Expand Up @@ -39,6 +40,7 @@ export default defineConfig(async () => {
},
plugins: [
vue(),
vueJsx(),
DefineOptions(),
Components({
include: `${__dirname}/**`,
Expand Down
Loading

0 comments on commit 879ea6d

Please sign in to comment.