Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[feat] Added support for Bun#630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mchao123 wants to merge4 commits intovuejs:main
base:main
Choose a base branch
Loading
frommchao123:main
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletionsindex.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,6 +63,22 @@ function emptyDir(dir) {
)
}

// get now user runtime
function detectRuntime() {
// @ts-ignore
if (typeof Bun !== 'undefined') {
return 'bun'
}
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
return 'node'
}
// @ts-ignore
if (typeof Deno !== 'undefined') {
return 'deno'
}
return 'unknown'
}

const helpMessage = `\
Usage: create-vue [FEATURE_FLAGS...] [OPTIONS...] [DIRECTORY]

Expand DownExpand Up@@ -105,6 +121,9 @@ Available feature flags:
--eslint-with-prettier
Add Prettier for code formatting in addition to ESLint.

--runtime
Show runtime environment selection prompt.

Unstable feature flags:
--tests, --with-tests
Add both unit testing and end-to-end testing support.
Expand All@@ -123,6 +142,7 @@ async function init() {
tests: { type: 'boolean' },
'vue-router': { type: 'boolean' },
router: { type: 'boolean' },
runtime: { type: 'boolean' },
} as const

const { values: argv, positionals } = parseArgs({
Expand DownExpand Up@@ -178,6 +198,7 @@ async function init() {
needsEslint?: false | 'eslintOnly' | 'speedUpWithOxlint'
needsOxlint?: boolean
needsPrettier?: boolean
runtime?: 'node' | 'bun'
} = {}

console.log()
Expand All@@ -190,6 +211,7 @@ async function init() {

try {
// Prompts:
// - Choose runtime environment: Node.js / Bun
// - Project name:
// - whether to overwrite the existing directory or not?
// - enter a valid package name for package.json
Expand All@@ -202,8 +224,27 @@ async function init() {
// - Add Playwright for end-to-end testing?
// - Add ESLint for code quality?
// - Add Prettier for code formatting?

result = await prompts(
[
{
name: 'runtime',
type: () => (argv.runtime ? 'select' : null),
message: language.needsRuntime.message,
initial: 0,
choices: [
{
title: language.needsRuntime.selectOptions.node.title,
description: language.needsRuntime.selectOptions.node.desc,
value: 'node',
},
{
title: language.needsRuntime.selectOptions.bun.title,
description: language.needsRuntime.selectOptions.bun.desc,
value: 'bun',
},
],
},
{
name: 'projectName',
type: targetDir ? null : 'text',
Expand DownExpand Up@@ -370,6 +411,7 @@ async function init() {
needsPinia = argv.pinia,
needsVitest = argv.vitest || argv.tests,
needsPrettier = argv['eslint-with-prettier'],
runtime = detectRuntime(),
} = result

const needsEslint = Boolean(argv.eslint || argv['eslint-with-prettier'] || result.needsEslint)
Expand DownExpand Up@@ -401,8 +443,11 @@ async function init() {
// const templateRoot = new URL('./template', import.meta.url).pathname
const templateRoot = path.resolve(__dirname, 'template')
const callbacks = []
const render = function render(templateName) {
const templateDir = path.resolve(templateRoot, templateName)
const render = function render(templateName: string) {
let templateDir = path.resolve(templateRoot, 'others-runtime', runtime, templateName)
if (!fs.existsSync(templateDir)) {
templateDir = path.resolve(templateRoot, templateName)
}
renderTemplate(templateDir, root, callbacks)
}
// Render base template
Expand DownExpand Up@@ -449,7 +494,7 @@ async function init() {
// All templates contain at least a `.node` and a `.app` tsconfig.
references: [
{
path:'./tsconfig.node.json',
path:`./tsconfig.${runtime}.json`,
},
{
path: './tsconfig.app.json',
Expand Down
13 changes: 13 additions & 0 deletionslocales/en-US.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,19 @@
"needsPrettier": {
"message": "Add Prettier for code formatting?"
},
"needsRuntime": {
"message": "Choose runtime environment:",
"selectOptions": {
"node": {
"title": "Node.js",
"desc": "Traditional and widely supported runtime"
},
"bun": {
"title": "Bun",
"desc": "Fast all-in-one JavaScript runtime"
}
}
},
"errors": {
"operationCancelled": "Operation cancelled"
},
Expand Down
13 changes: 13 additions & 0 deletionslocales/fr-FR.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,19 @@
"needsPrettier": {
"message": "Ajouter Prettier pour le formatage du code\u00a0?"
},
"needsRuntime": {
"message": "Choisir l'environnement d'exécution :",
"selectOptions": {
"node": {
"title": "Node.js",
"desc": "Runtime traditionnel largement supporté"
},
"bun": {
"title": "Bun",
"desc": "Runtime JavaScript tout-en-un rapide"
}
}
},
"errors": {
"operationCancelled": "Operation annulée"
},
Expand Down
13 changes: 13 additions & 0 deletionslocales/tr-TR.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,19 @@
"needsPrettier": {
"message": "Kod formatlama için Prettier eklensin mi?"
},
"needsRuntime": {
"message": "Çalışma zamanı ortamını seçin:",
"selectOptions": {
"node": {
"title": "Node.js",
"desc": "Geleneksel ve yaygın olarak desteklenen çalışma zamanı"
},
"bun": {
"title": "Bun",
"desc": "Hızlı, hepsi bir arada JavaScript çalışma zamanı"
}
}
},
"errors": {
"operationCancelled": "İşlem iptal edildi"
},
Expand Down
13 changes: 13 additions & 0 deletionslocales/zh-Hans.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,19 @@
"needsPrettier": {
"message": "是否引入 Prettier 用于代码格式化?"
},
"needsRuntime": {
"message": "选择运行时环境:",
"selectOptions": {
"node": {
"title": "Node.js",
"desc": "传统且广泛支持的运行时"
},
"bun": {
"title": "Bun",
"desc": "快速的一体化 JavaScript 运行时"
}
}
},
"errors": {
"operationCancelled": "操作取消"
},
Expand Down
13 changes: 13 additions & 0 deletionslocales/zh-Hant.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,6 +63,19 @@
"needsPrettier": {
"message": "是否引入 Prettier 用於程式碼格式化?"
},
"needsRuntime": {
"message": "選擇執行環境:",
"selectOptions": {
"node": {
"title": "Node.js",
"desc": "傳統且廣泛支援的執行環境"
},
"bun": {
"title": "Bun",
"desc": "快速的一體化 JavaScript 執行環境"
}
}
},
"errors": {
"operationCancelled": "操作取消"
},
Expand Down
1 change: 1 addition & 0 deletionstemplate/others-runtime/bun/config/typescript/env.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
13 changes: 13 additions & 0 deletionstemplate/others-runtime/bun/config/typescript/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
{
"scripts": {
"build": "run-p type-check \"build-only {@}\" --",
"build-only": "vite build",
"type-check": "vue-tsc --build"
},
"devDependencies": {
"@types/bun": "^1.1.13",
"npm-run-all2": "^7.0.2",
"typescript": "~5.7.3",
"vue-tsc": "^2.2.0"
}
}
6 changes: 6 additions & 0 deletionstemplate/others-runtime/bun/tsconfig/base/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
{
"devDependencies": {
"@tsconfig/bun": "^1.0.7",
"@vue/tsconfig": "^0.7.0"
}
}
13 changes: 13 additions & 0 deletionstemplate/others-runtime/bun/tsconfig/base/tsconfig.app.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",

"paths": {
"@/*": ["./src/*"]
}
}
}
19 changes: 19 additions & 0 deletionstemplate/others-runtime/bun/tsconfig/base/tsconfig.bun.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
{
"extends": "@tsconfig/bun/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",

"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}
1 change: 1 addition & 0 deletionsutils/getLanguage.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@ interface Language {
needsE2eTesting: LanguageItem
needsEslint: LanguageItem
needsPrettier: LanguageItem
needsRuntime: LanguageItem
errors: {
operationCancelled: string
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp