diff --git a/packages/fes-plugin-icon/src/optimizeSvg.js b/packages/fes-plugin-icon/src/optimizeSvg.js index 09840aad..14111673 100644 --- a/packages/fes-plugin-icon/src/optimizeSvg.js +++ b/packages/fes-plugin-icon/src/optimizeSvg.js @@ -1,18 +1,24 @@ import { extname, basename } from 'path'; import { statSync, readFileSync } from 'fs'; -import { extendDefaultPlugins, optimize } from 'svgo'; +import { optimize } from 'svgo'; - -const plugins = extendDefaultPlugins([ - 'sortAttrs', - 'removeDimensions', +const presetDefault = [ { - name: 'removeAttrs', + name: 'preset-default', params: { - attrs: '(stroke|fill|class)' + overrides: { + sortAttrs: true, + removeDimensions: true, + // customize options + removeAttrs: { + params: { + attrs: '(stroke|fill|class)' + } + } + } } } -]); +]; export default function optimizeSvg(files) { @@ -20,7 +26,7 @@ export default function optimizeSvg(files) { for (const filePath of files) { if (statSync(filePath).isFile() && extname(filePath) === '.svg') { const data = readFileSync(filePath, 'utf-8'); - const svgData = optimize(data, { path: filePath, plugins }); + const svgData = optimize(data, { path: filePath, plugins: presetDefault }); optimizedSvgData.push({ fileName: basename(filePath), ...svgData diff --git a/packages/fes-preset-built-in/package.json b/packages/fes-preset-built-in/package.json index 51efa006..9147f279 100644 --- a/packages/fes-preset-built-in/package.json +++ b/packages/fes-preset-built-in/package.json @@ -32,6 +32,7 @@ "@babel/plugin-proposal-pipeline-operator": "^7.12.13", "@babel/plugin-transform-runtime": "^7.12.13", "@babel/preset-env": "^7.12.13", + "@babel/preset-typescript": "^7.15.0", "@fesjs/compiler": "^2.0.2", "@fesjs/utils": "^2.0.2", "@soda/friendly-errors-webpack-plugin": "^1.8.0", diff --git a/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/getBabelOpts.js b/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/getBabelOpts.js index 17d01c89..f49583c8 100644 --- a/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/getBabelOpts.js +++ b/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/getBabelOpts.js @@ -21,6 +21,16 @@ function getBabelOpts({ modules: false } ], + [ + // FEATURE 实现类型安全检查 + require('@babel/preset-typescript').default, + { + // https://babeljs.io/docs/en/babel-plugin-transform-typescript#impartial-namespace-support + allowNamespaces: true, + isTSX: true, + allExtensions: true + } + ], ...(config.extraBabelPresets || []) ]; const plugins = [ diff --git a/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/index.js b/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/index.js index 2c6795a9..d0e316a9 100644 --- a/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/index.js +++ b/packages/fes-preset-built-in/src/plugins/commands/webpackConfig/index.js @@ -99,7 +99,7 @@ export default async function getConfig({ .chunkFilename('[name].[contenthash:8].chunk.js'); // --------------- resolve ----------- - webpackConfig.resolve.extensions.merge(['.mjs', '.js', '.jsx', '.vue', '.json', '.wasm']); + webpackConfig.resolve.extensions.merge(['.mjs', '.js', '.jsx', '.vue', '.ts', '.tsx', '.json', '.wasm']); if (config.alias) { Object.keys(config.alias).forEach((key) => { @@ -173,7 +173,7 @@ export default async function getConfig({ webpackConfig.module .rule('js') - .test(/\.(js|mjs|jsx)$/) + .test(/\.(js|mjs|jsx|ts|tsx)$/) .exclude.add((filepath) => { // always transpile js in vue files if (/\.vue\.jsx?$/.test(filepath)) { diff --git a/packages/fes-template-h5/src/components/helloTS.ts b/packages/fes-template-h5/src/components/helloTS.ts new file mode 100644 index 00000000..44f321d6 --- /dev/null +++ b/packages/fes-template-h5/src/components/helloTS.ts @@ -0,0 +1,7 @@ +import { defineComponent } from 'vue'; + +export default defineComponent({ + setup() { + return () => 'hello ts'; + } +}); diff --git a/packages/fes-template-h5/src/components/helloTSX.tsx b/packages/fes-template-h5/src/components/helloTSX.tsx new file mode 100644 index 00000000..8a723c57 --- /dev/null +++ b/packages/fes-template-h5/src/components/helloTSX.tsx @@ -0,0 +1,9 @@ +import {defineComponent} from 'vue'; + +export default defineComponent({ + setup() { + return () => { + return 'hello tsx' + } + } +}) \ No newline at end of file diff --git a/packages/fes-template-h5/src/components/helloWorld.vue b/packages/fes-template-h5/src/components/helloWorld.vue new file mode 100644 index 00000000..72e8d144 --- /dev/null +++ b/packages/fes-template-h5/src/components/helloWorld.vue @@ -0,0 +1,14 @@ + + + diff --git a/packages/fes-template-h5/src/pages/index.vue b/packages/fes-template-h5/src/pages/index.vue index 25fef6f8..4ed55e6b 100644 --- a/packages/fes-template-h5/src/pages/index.vue +++ b/packages/fes-template-h5/src/pages/index.vue @@ -2,6 +2,9 @@
fes h5 & 拉夫德鲁
+ + +
@@ -14,8 +17,16 @@