Skip to content

Commit

Permalink
Merge pull request #1 from GauharChan/v1.0.7
Browse files Browse the repository at this point in the history
feat: 支持tsx
  • Loading branch information
GauharChan authored Apr 6, 2023
2 parents 756035d + b851acb commit f1b2961
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ module.exports = defineConfig({
parser: '@typescript-eslint/parser',
ecmaVersion: 2022,
sourceType: 'module',
// jsxPragma: "React",
// ecmaFeatures: {
// jsx: true,
// },
jsxPragma: 'React',
ecmaFeatures: {
jsx: true,
},
},
extends: ['prettier', 'plugin:prettier/recommended'],
// plugins: ['prettier'],
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-shared",
"version": "1.0.6",
"version": "1.0.7",
"description": "一款针对assets目录规范,自动生成出口shared.ts的工具",
"author": "Gauhar Chan",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function createShared(targetPath: string) {
// 遍历获取所有ts文件
const allTs = recursion(
targetPath,
assetsModules.filter((file) => !file.endsWith('.ts')) // 剔除shared.ts
assetsModules.filter((file) => !file.endsWith('.ts') || !file.endsWith('.tsx')) // 剔除shared.ts
);
if (allTs.size) {
// 写入代码内容
Expand Down Expand Up @@ -100,7 +100,7 @@ function recursion(
// 递归遍历解析文件夹
recursion(path, dir, pathSet);
}
} else if (item.endsWith('.ts')) {
} else if (item.endsWith('.ts') || item.endsWith('.tsx')) {
// && stat.size > 0 stat.size 过滤空文件
// ts文件,直接记录
pathSet.add({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const b = 22;
6 changes: 6 additions & 0 deletions playground/shared/src/views/moduleA/assets/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as ComAIndex from './components/ComA/index';
import * as hooksUseA from './data/hooks/useA';
import * as hooksUseB from './data/hooks/useB';
import * as storeStoreA from './store/storeA';

export { ComAIndex, hooksUseA, hooksUseB, storeStoreA };
1 change: 1 addition & 0 deletions playground/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"jsx": "react",
// esbuild transpile should ignore this
"target": "ES5"
},
Expand Down

0 comments on commit f1b2961

Please sign in to comment.