Skip to content

Commit

Permalink
perf: ➖ Remove unnecessary language flags at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 23, 2024
1 parent e31a380 commit 227465f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ lerna-debug.log*
# User
node_modules
*.local
dist
dist
cleants.config.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"dev": "unbuild && npx .",
"dev": "cross-env CLEANTS_CONFIG_DIR=../ unbuild && npx .",
"build": "unbuild",
"release": "changelogen --release --push && unbuild && npm publish",
"prepare": "husky install"
Expand All @@ -53,6 +53,7 @@
"devDependencies": {
"@antfu/eslint-config": "^3.7.3",
"changelogen": "^0.5.7",
"cross-env": "^7.0.3",
"eslint": "^9.12.0",
"husky": "^9.1.6",
"unbuild": "latest"
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function capitalizeFirstLetter(str) {
* })();
*/
export async function loadConfig(configFileName = 'cleants.config.js') {
const configFilePath = path.join(process.cwd(), configFileName)
const configFilePath = path.join(process.cwd(), process.env.CLEANTS_CONFIG_DIR || '', configFileName)

try {
// 检查配置文件是否存在
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/vue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export const vuePlugin = () => ({
const script = descriptor.scriptSetup || descriptor.script

if (!script) {
return updateScriptAttrs(content, { lang: 'js' })
return updateScriptAttrs(content, { lang: void 0 })
}

const scriptContent = script.content

const lang = script.lang || 'js'

const replaceLang = lang === 'tsx' ? 'jsx' : 'js'
const replaceLang = lang === 'tsx' ? 'jsx' : void 0

let processContent = ['ts', 'tsx'].includes(lang)
? `\n${ctx.transpileFile(scriptContent, `.${lang}`)}`
Expand Down

0 comments on commit 227465f

Please sign in to comment.