feat(core): add jsx support

This commit is contained in:
zouhang 2020-09-15 12:28:12 +08:00 committed by jeremywu
parent 849bd4e7c0
commit b37a21420c
5 changed files with 65 additions and 4 deletions

View File

@ -3,6 +3,10 @@ module.exports = {
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
tsx: true,
},
},
env: {
browser: true,

View File

@ -28,6 +28,7 @@
"@types/lodash": "^4.14.161",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"@vue/babel-plugin-jsx": "^1.0.0-rc.3",
"@vue/compiler-sfc": "^3.0.0-rc.9",
"@vue/component-compiler-utils": "^3.2.0",
"algoliasearch": "^4.4.0",

View File

@ -6,6 +6,7 @@
"removeComments": true,
"moduleResolution": "node",
"esModuleInterop": true,
"jsx": "preserve",
"noLib": false,
"target": "es6",
"sourceMap": true,
@ -18,4 +19,3 @@
"node_modules"
]
}

View File

@ -7,6 +7,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const isProd = process.env.NODE_ENV === 'production'
const isPlay = !!process.env.PLAY_ENV
const babelOptions = {
plugins: ['@vue/babel-plugin-jsx'],
}
module.exports = {
mode: isProd ? 'production' : 'development',
devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map',
@ -37,12 +41,40 @@ module.exports = {
},
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
transpileOnly: true,
},
},
{
test: /\.tsx$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: babelOptions,
},
{
loader: 'ts-loader',
options: {
appendTsxSuffixTo: [/\.vue$/],
transpileOnly: true,
},
},
],
},
{
test: /\.js(x?)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: babelOptions,
},
],
},
{
test: /\.md$/,
use: [
@ -71,7 +103,7 @@ module.exports = {
],
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.json'],
extensions: ['.ts', '.tsx', '.js', '.vue', '.json'],
alias: {
'vue': '@vue/runtime-dom',
examples: path.resolve(__dirname),

View File

@ -576,7 +576,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"
"@babel/plugin-syntax-jsx@^7.10.4":
"@babel/plugin-syntax-jsx@^7.0.0", "@babel/plugin-syntax-jsx@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.10.4.tgz#39abaae3cbf710c4373d8429484e6ba21340166c"
integrity sha512-KCg9mio9jwiARCB7WAcQ7Y1q+qicILjoK8LP/VkPkEKaf5dkaZZK1EcTe91a3JJlZ3qy6L5s9X52boEYi8DM9g==
@ -1082,7 +1082,7 @@
"@babel/parser" "^7.10.4"
"@babel/types" "^7.10.4"
"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.11.5":
"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.11.5":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.11.5.tgz#be777b93b518eb6d76ee2e1ea1d143daa11e61c3"
integrity sha512-EjiPXt+r7LiCZXEfRpSJd+jUMnBd4/9OUv7Nx3+0u9+eimMwJmG0Q98lw4/289JCoxSE8OolDMNZaaF/JZ69WQ==
@ -3473,6 +3473,25 @@
dependencies:
eslint-visitor-keys "^1.1.0"
"@vue/babel-helper-vue-transform-on@^1.0.0-rc.2":
version "1.0.0-rc.2"
resolved "https://registry.yarnpkg.com/@vue/babel-helper-vue-transform-on/-/babel-helper-vue-transform-on-1.0.0-rc.2.tgz#7246341f666e7c6e65b13da420e2ce85714fbbca"
integrity sha512-1+7CwjQ0Kasml6rHoNQUmbISwqLNNfFVBUcZl6QBremUl296ZmLrVQPqJP5pyAAWjZke5bpI1hlj+LVVuT7Jcg==
"@vue/babel-plugin-jsx@^1.0.0-rc.3":
version "1.0.0-rc.3"
resolved "https://registry.yarnpkg.com/@vue/babel-plugin-jsx/-/babel-plugin-jsx-1.0.0-rc.3.tgz#ab477ee95c764fbe68842a2eddd474f122e70ac6"
integrity sha512-/Ibq0hoKsidnHWPhgRpjcjYhYcHpqEm2fiKVAPO88OXZNHGwaGgS4yXkC6TDEvlZep4mBDo+2S5T81wpbVh90Q==
dependencies:
"@babel/helper-module-imports" "^7.0.0"
"@babel/plugin-syntax-jsx" "^7.0.0"
"@babel/traverse" "^7.0.0"
"@babel/types" "^7.0.0"
"@vue/babel-helper-vue-transform-on" "^1.0.0-rc.2"
camelcase "^6.0.0"
html-tags "^3.1.0"
svg-tags "^1.0.0"
"@vue/compiler-core@3.0.0-rc.10":
version "3.0.0-rc.10"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-rc.10.tgz#a76f713fb0462429ec0ec10a472fff1f539c5772"
@ -8788,6 +8807,11 @@ html-tags@^2.0.0:
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b"
integrity sha1-ELMKOGCF9Dzt41PMj6fLDe7qZos=
html-tags@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"
integrity sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==
html-webpack-plugin@^4.2.1, html-webpack-plugin@^4.3.0:
version "4.4.1"
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-4.4.1.tgz#61ab85aa1a84ba181443345ebaead51abbb84149"