This repository was archived by the owner on Oct 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): JSX 内置组件需要从@tarojs/components 引入
- Loading branch information
Showing
64 changed files
with
616 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const fs = require('fs') | ||
const { resolve } = require('path') | ||
const glob = require('glob') | ||
|
||
// 转换 小写 tag | ||
const formatTag = (file) => { | ||
let content = fs.readFileSync(file, { encoding: 'utf8' }) | ||
|
||
const matched = content.match(/<[a-z]+/g) | ||
|
||
const matchedUniq = Array.from(new Set(matched)) | ||
|
||
const comps = matchedUniq.map((item) => { | ||
const tag = item.replace('<', '').replace(/[a-z]/, (p) => p.toUpperCase()) | ||
content = content | ||
.replace(new RegExp('<' + tag, 'gi'), `<${tag}`) | ||
.replace(new RegExp(`</${tag}`, 'gi'), `</${tag}`) | ||
return tag | ||
}) | ||
if (comps) { | ||
const compStr = comps.join(', ') | ||
|
||
const impStr = `import { ${compStr} } from '@tarojs/components'\n` | ||
|
||
fs.writeFileSync(file, impStr + content, { encoding: 'utf8' }) | ||
} | ||
} | ||
|
||
// 匹配 所有组件 | ||
console.time('Time') | ||
glob(resolve(__dirname, '../src/components/**/*.[jt]sx'), {}, function (er, files) { | ||
files.forEach(formatTag) | ||
console.timeEnd('Time') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.