diff --git a/packages/fes-plugin-icon/package.json b/packages/fes-plugin-icon/package.json
index 842738ef..810198da 100644
--- a/packages/fes-plugin-icon/package.json
+++ b/packages/fes-plugin-icon/package.json
@@ -1,6 +1,6 @@
{
"name": "@fesjs/plugin-icon",
- "version": "2.0.1",
+ "version": "2.0.2",
"description": "@fesjs/plugin-icon",
"main": "lib/index.js",
"files": [
diff --git a/packages/fes-plugin-icon/src/optimizeSvg.js b/packages/fes-plugin-icon/src/optimizeSvg.js
index 09840aad..a945e31b 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: 'preset-default',
+ params: {
+ overrides: {
+ sortAttrs: true,
+ removeDimensions: true
+ }
+ }
+ },
{
name: 'removeAttrs',
params: {
- attrs: '(stroke|fill|class)'
+ attrs: '(fill|stroke|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..1cc82592 100644
--- a/packages/fes-preset-built-in/package.json
+++ b/packages/fes-preset-built-in/package.json
@@ -1,6 +1,6 @@
{
"name": "@fesjs/preset-built-in",
- "version": "2.0.3",
+ "version": "2.0.4",
"description": "@fesjs/preset-built-in",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -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-preset-built-in/src/utils/generateFiles.js b/packages/fes-preset-built-in/src/utils/generateFiles.js
index b3be02d0..ddc0534f 100644
--- a/packages/fes-preset-built-in/src/utils/generateFiles.js
+++ b/packages/fes-preset-built-in/src/utils/generateFiles.js
@@ -12,7 +12,7 @@ export default async ({ api, watch }) => {
});
}
- const watchers = [];
+ let watchers = [];
await generate();
@@ -20,6 +20,7 @@ export default async ({ api, watch }) => {
watchers.forEach((watcher) => {
watcher.close();
});
+ watchers = [];
}
function createWatcher(path) {
@@ -34,6 +35,7 @@ export default async ({ api, watch }) => {
await generate();
}, 100)
);
+ watchers.push(watcher);
}
if (watch) {
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 @@
+
+