diff --git a/package.json b/package.json index 4efc4a6d453df0..ed2ad360dd5d30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "@vitejs/vite-monorepo", "private": true, + "type": "module", "engines": { "node": "^14.18.0 || >=16.0.0" }, @@ -50,17 +51,15 @@ "@types/json-stable-stringify": "^1.0.34", "@types/less": "^3.0.3", "@types/micromatch": "^4.0.2", - "@types/minimist": "^1.2.2", "@types/node": "^18.15.5", "@types/picomatch": "^2.3.0", - "@types/prompts": "2.4.2", "@types/resolve": "^1.20.2", "@types/sass": "~1.43.1", - "@types/semver": "^7.3.13", "@types/stylus": "^0.48.38", "@types/ws": "^8.5.4", "@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/parser": "^5.56.0", + "@vitejs/release-scripts": "^1.1.0", "conventional-changelog-cli": "^2.2.2", "eslint": "^8.36.0", "eslint-define-config": "^1.17.0", @@ -71,16 +70,13 @@ "fast-glob": "^3.2.12", "fs-extra": "^11.1.1", "lint-staged": "^13.2.0", - "minimist": "^1.2.8", "npm-run-all": "^4.1.5", "picocolors": "^1.0.0", "playwright-chromium": "^1.31.2", "prettier": "2.8.5", - "prompts": "^2.4.2", "resolve": "^1.22.1", "rimraf": "^4.4.0", "rollup": "^3.20.2", - "semver": "^7.3.8", "simple-git-hooks": "^2.8.1", "tslib": "^2.5.0", "tsx": "^3.12.6", diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 57f24d87f6ac7f..e5232c9bdf48f9 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -13,7 +13,6 @@ "template-*", "dist" ], - "main": "index.js", "scripts": { "dev": "unbuild --stub", "build": "unbuild", @@ -33,6 +32,8 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/create-vite#readme", "devDependencies": { + "@types/minimist": "^1.2.2", + "@types/prompts": "^2.4.4", "cross-spawn": "^7.0.3", "kolorist": "^1.7.0", "minimist": "^1.2.8", diff --git a/playground/css/__tests__/no-css-minify/vite.config.js b/playground/css/__tests__/no-css-minify/vite.config.js index 260e7f253520be..0f9d18ad3ed221 100644 --- a/playground/css/__tests__/no-css-minify/vite.config.js +++ b/playground/css/__tests__/no-css-minify/vite.config.js @@ -1 +1,2 @@ -module.exports = require('../../vite.config-no-css-minify') +import config from '../../vite.config-no-css-minify' +export default config diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8900cb622457a2..9459b1c3d56402 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,17 +34,15 @@ importers: '@types/json-stable-stringify': ^1.0.34 '@types/less': ^3.0.3 '@types/micromatch': ^4.0.2 - '@types/minimist': ^1.2.2 '@types/node': ^18.15.5 '@types/picomatch': ^2.3.0 - '@types/prompts': 2.4.2 '@types/resolve': ^1.20.2 '@types/sass': ~1.43.1 - '@types/semver': ^7.3.13 '@types/stylus': ^0.48.38 '@types/ws': ^8.5.4 '@typescript-eslint/eslint-plugin': ^5.56.0 '@typescript-eslint/parser': ^5.56.0 + '@vitejs/release-scripts': ^1.1.0 conventional-changelog-cli: ^2.2.2 eslint: ^8.36.0 eslint-define-config: ^1.17.0 @@ -55,16 +53,13 @@ importers: fast-glob: ^3.2.12 fs-extra: ^11.1.1 lint-staged: ^13.2.0 - minimist: ^1.2.8 npm-run-all: ^4.1.5 picocolors: ^1.0.0 playwright-chromium: ^1.31.2 prettier: 2.8.5 - prompts: ^2.4.2 resolve: ^1.22.1 rimraf: ^4.4.0 rollup: ^3.20.2 - semver: ^7.3.8 simple-git-hooks: ^2.8.1 tslib: ^2.5.0 tsx: ^3.12.6 @@ -89,17 +84,15 @@ importers: '@types/json-stable-stringify': 1.0.34 '@types/less': 3.0.3 '@types/micromatch': 4.0.2 - '@types/minimist': 1.2.2 '@types/node': 18.15.5 '@types/picomatch': 2.3.0 - '@types/prompts': 2.4.2 '@types/resolve': 1.20.2 '@types/sass': 1.43.1 - '@types/semver': 7.3.13 '@types/stylus': 0.48.38 '@types/ws': 8.5.4 '@typescript-eslint/eslint-plugin': 5.56.0_2hcjazgfnbtq42tcc73br2vup4 '@typescript-eslint/parser': 5.56.0_j4766f7ecgqbon3u7zlxn5zszu + '@vitejs/release-scripts': 1.1.0 conventional-changelog-cli: 2.2.2 eslint: 8.36.0 eslint-define-config: 1.17.0 @@ -110,16 +103,13 @@ importers: fast-glob: 3.2.12 fs-extra: 11.1.1 lint-staged: 13.2.0 - minimist: 1.2.8 npm-run-all: 4.1.5 picocolors: 1.0.0 playwright-chromium: 1.31.2 prettier: 2.8.5 - prompts: 2.4.2 resolve: 1.22.1 rimraf: 4.4.0 rollup: 3.20.2 - semver: 7.3.8 simple-git-hooks: 2.8.1 tslib: 2.5.0 tsx: 3.12.6 @@ -132,11 +122,15 @@ importers: packages/create-vite: specifiers: + '@types/minimist': ^1.2.2 + '@types/prompts': ^2.4.4 cross-spawn: ^7.0.3 kolorist: ^1.7.0 minimist: ^1.2.8 prompts: ^2.4.2 devDependencies: + '@types/minimist': 1.2.2 + '@types/prompts': 2.4.4 cross-spawn: 7.0.3 kolorist: 1.7.0 minimist: 1.2.8 @@ -3521,8 +3515,8 @@ packages: resolution: {integrity: sha512-2lqsQt1iXkiTqwuzw2SS50iduoPZNpV/ou4/vJD443C0weF63Gqd3ErGS811CBNMzLO64zVJ+tiyh+4yimdYkg==} dev: true - /@types/prompts/2.4.2: - resolution: {integrity: sha512-TwNx7qsjvRIUv/BCx583tqF5IINEVjCNqg9ofKHRlSoUHE62WBHrem4B1HGXcIrG511v29d1kJ9a/t2Esz7MIg==} + /@types/prompts/2.4.4: + resolution: {integrity: sha512-p5N9uoTH76lLvSAaYSZtBCdEXzpOOufsRjnhjVSrZGXikVGHX9+cc9ERtHRV4hvBKHyZb1bg4K+56Bd2TqUn4A==} dependencies: '@types/node': 18.15.5 kleur: 3.0.3 @@ -3713,6 +3707,17 @@ packages: vue: 3.2.47 dev: true + /@vitejs/release-scripts/1.1.0: + resolution: {integrity: sha512-pxP72AGDRGu6vufj8vrdmFll++N0K7aNDSWWYzPb28NgE5RjOdo99uLgJEpl3Ee/wEOnHKT2zJ9HN2GN44SUPQ==} + dependencies: + execa: 6.1.0 + minimist: 1.2.8 + picocolors: 1.0.0 + prompts: 2.4.2 + publint: 0.1.11 + semver: 7.3.8 + dev: true + /@vitest/expect/0.29.7: resolution: {integrity: sha512-UtG0tW0DP6b3N8aw7PHmweKDsvPv4wjGvrVZW7OSxaFg76ShtVdMiMcUkZJgCE8QWUmhwaM0aQhbbVLo4F4pkA==} dependencies: @@ -5746,6 +5751,21 @@ packages: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: true + /execa/6.1.0: + resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + cross-spawn: 7.0.3 + get-stream: 6.0.1 + human-signals: 3.0.1 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.1.0 + onetime: 6.0.0 + signal-exit: 3.0.7 + strip-final-newline: 3.0.0 + dev: true + /execa/7.1.1: resolution: {integrity: sha512-wH0eMf/UXckdUYnO21+HDztteVv05rq2GXksxT4fCGeHkBhw1DROXh40wcjMcRqDOWE7iPJ4n3M7e2+YFP+76Q==} engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} @@ -6366,6 +6386,11 @@ packages: - supports-color dev: false + /human-signals/3.0.1: + resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} + engines: {node: '>=12.20.0'} + dev: true + /human-signals/4.3.0: resolution: {integrity: sha512-zyzVyMjpGBX2+6cDVZeFPCdtOtdsxOeseRhB9tkQ6xXmGUNrcnBzdEKPy3VPNYz+4gy1oukVOXcrJCunSyc6QQ==} engines: {node: '>=14.18.0'} @@ -6394,6 +6419,13 @@ packages: postcss: 8.4.21 dev: true + /ignore-walk/5.0.1: + resolution: {integrity: sha512-yemi4pMf51WKT7khInJqAvsIGzoqYXblnsz0ql8tM+yi1EKYTY1evX4NAbJrLL/Aanr2HyZeluqU+Oi7MGHokw==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + dependencies: + minimatch: 5.1.0 + dev: true + /ignore/5.2.0: resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} engines: {node: '>= 4'} @@ -7510,6 +7542,29 @@ packages: resolution: {integrity: sha512-qizSNPO93t1YUuUhP22btGOo3chcvDFqFaj2TRybP0DMxkHOCTYwp3n34fel4a31ORXy4m1Xq0Gyqpb5m33qIg==} dev: false + /npm-bundled/2.0.1: + resolution: {integrity: sha512-gZLxXdjEzE/+mOstGDqR6b0EkhJ+kM6fxM6vUuckuctuVPh80Q6pw/rSZj9s4Gex9GxWtIicO1pc8DB9KZWudw==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + dependencies: + npm-normalize-package-bin: 2.0.0 + dev: true + + /npm-normalize-package-bin/2.0.0: + resolution: {integrity: sha512-awzfKUO7v0FscrSpRoogyNm0sajikhBWpU0QMrW09AMi9n1PoKU6WaIqUzuJSQnpciZZmJ/jMZ2Egfmb/9LiWQ==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + dev: true + + /npm-packlist/5.1.3: + resolution: {integrity: sha512-263/0NGrn32YFYi4J533qzrQ/krmmrWwhKkzwTuM4f/07ug51odoaNjUexxO4vxlzURHcmYMH1QjvHjsNDKLVg==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + hasBin: true + dependencies: + glob: 8.0.3 + ignore-walk: 5.0.1 + npm-bundled: 2.0.1 + npm-normalize-package-bin: 2.0.0 + dev: true + /npm-run-all/4.1.5: resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==} engines: {node: '>= 4'} @@ -8135,6 +8190,16 @@ packages: dev: true optional: true + /publint/0.1.11: + resolution: {integrity: sha512-sD0rtIEadks83MkpomJswBO/YHExJLkta1TyqUhb0/aVV+o3ZlVnwsDPjCAow8tpfxmLGutCSLWq32yfhPB98w==} + engines: {node: '>=16'} + hasBin: true + dependencies: + npm-packlist: 5.1.3 + picocolors: 1.0.0 + sade: 1.8.1 + dev: true + /pug-attrs/3.0.0: resolution: {integrity: sha512-azINV9dUtzPMFQktvTXciNAfAuVh/L/JCl0vtPCwvOA21uZrC08K/UnmrL+SXGEVc1FwzjW62+xw5S/uaLj6cA==} dependencies: @@ -8594,6 +8659,13 @@ packages: tslib: 2.5.0 dev: true + /sade/1.8.1: + resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} + engines: {node: '>=6'} + dependencies: + mri: 1.2.0 + dev: true + /safe-buffer/5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} dev: true diff --git a/scripts/publishCI.ts b/scripts/publishCI.ts index 02dbef74908032..a6d83385739ae6 100644 --- a/scripts/publishCI.ts +++ b/scripts/publishCI.ts @@ -1,47 +1,3 @@ -import semver from 'semver' -import { - args, - getActiveVersion, - getPackageInfo, - publishPackage, - step, -} from './releaseUtils' +import { publish } from '@vitejs/release-scripts' -async function main() { - const tag = args._[0] - - if (!tag) { - throw new Error('No tag specified') - } - - let pkgName = 'vite' - let version - - if (tag.includes('@')) [pkgName, version] = tag.split('@') - else version = tag - - if (version.startsWith('v')) version = version.slice(1) - - const { currentVersion, pkgDir } = getPackageInfo(pkgName) - if (currentVersion !== version) - throw new Error( - `Package version from tag "${version}" mismatches with current version "${currentVersion}"`, - ) - - const activeVersion = await getActiveVersion(pkgName) - - step('Publishing package...') - const releaseTag = version.includes('beta') - ? 'beta' - : version.includes('alpha') - ? 'alpha' - : semver.lt(currentVersion, activeVersion) - ? 'previous' - : undefined - await publishPackage(pkgDir, releaseTag) -} - -main().catch((err) => { - console.error(err) - process.exit(1) -}) +publish({ defaultPackage: 'vite' }) diff --git a/scripts/release.ts b/scripts/release.ts index b17f328518bcf1..5226cfc51e2083 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -1,128 +1,28 @@ -import prompts from 'prompts' -import semver from 'semver' +import { release } from '@vitejs/release-scripts' import colors from 'picocolors' -import { - args, - getPackageInfo, - getVersionChoices, - isDryRun, - logRecentCommits, - packages, - run, - runIfNotDry, - step, - updateTemplateVersions, - updateVersion, -} from './releaseUtils' - -async function main(): Promise { - let targetVersion: string | undefined - - const { pkg }: { pkg: string } = await prompts({ - type: 'select', - name: 'pkg', - message: 'Select package', - choices: packages.map((i) => ({ value: i, title: i })), - }) - - if (!pkg) return - - await logRecentCommits(pkg) - - const { currentVersion, pkgName, pkgPath, pkgDir } = getPackageInfo(pkg) - - if (!targetVersion) { - const { release }: { release: string } = await prompts({ - type: 'select', - name: 'release', - message: 'Select release type', - choices: getVersionChoices(currentVersion), - }) - - if (release === 'custom') { - const res: { version: string } = await prompts({ - type: 'text', - name: 'version', - message: 'Input custom version', - initial: currentVersion, - }) - targetVersion = res.version - } else { - targetVersion = release - } - } - - if (!semver.valid(targetVersion)) { - throw new Error(`invalid target version: ${targetVersion}`) - } - - const tag = - pkgName === 'vite' ? `v${targetVersion}` : `${pkgName}@${targetVersion}` - - if (targetVersion.includes('beta') && !args.tag) { - args.tag = 'beta' - } - if (targetVersion.includes('alpha') && !args.tag) { - args.tag = 'alpha' - } - - const { yes }: { yes: boolean } = await prompts({ - type: 'confirm', - name: 'yes', - message: `Releasing ${colors.yellow(tag)} Confirm?`, - }) - - if (!yes) { - return - } - - step('\nUpdating package version...') - updateVersion(pkgPath, targetVersion) - if (pkgName === 'create-vite') updateTemplateVersions() - - step('\nGenerating changelog...') - const changelogArgs = [ - 'conventional-changelog', - '-p', - 'angular', - '-i', - 'CHANGELOG.md', - '-s', - '--commit-path', - '.', - ] - if (pkgName !== 'vite') changelogArgs.push('--lerna-package', pkgName) - await run('npx', changelogArgs, { cwd: pkgDir }) - - const { stdout } = await run('git', ['diff'], { stdio: 'pipe' }) - if (stdout) { - step('\nCommitting changes...') - await runIfNotDry('git', ['add', '-A']) - await runIfNotDry('git', ['commit', '-m', `release: ${tag}`]) - await runIfNotDry('git', ['tag', tag]) - } else { - console.log('No changes to commit.') - return - } - - step('\nPushing to GitHub...') - await runIfNotDry('git', ['push', 'origin', `refs/tags/${tag}`]) - await runIfNotDry('git', ['push']) - - if (isDryRun) { - console.log(`\nDry run finished - run git diff to see package changes.`) - } else { - console.log( - colors.green( - '\nPushed, publishing should starts shortly on CI.\nhttps://github.com/vitejs/vite/actions/workflows/publish.yml', - ), - ) - } - - console.log() -} - -main().catch((err) => { - console.error(err) - process.exit(1) +import { logRecentCommits, run, updateTemplateVersions } from './releaseUtils' + +release({ + repo: 'vite', + packages: ['vite', 'create-vite', 'plugin-legacy'], + toTag: (pkg, version) => + pkg === 'vite' ? `v${version}` : `${pkg}@${version}`, + logChangelog: (pkg) => logRecentCommits(pkg), + generateChangelog: async (pkgName) => { + if (pkgName === 'create-vite') await updateTemplateVersions() + + console.log(colors.cyan('\nGenerating changelog...')) + const changelogArgs = [ + 'conventional-changelog', + '-p', + 'angular', + '-i', + 'CHANGELOG.md', + '-s', + '--commit-path', + '.', + ] + if (pkgName !== 'vite') changelogArgs.push('--lerna-package', pkgName) + await run('npx', changelogArgs, { cwd: `packages/${pkgName}` }) + }, }) diff --git a/scripts/releaseUtils.ts b/scripts/releaseUtils.ts index e971cdb24406cf..c2315ab883667f 100644 --- a/scripts/releaseUtils.ts +++ b/scripts/releaseUtils.ts @@ -1,71 +1,9 @@ -/** - * modified from https://github.com/vuejs/core/blob/master/scripts/release.js - */ -import { existsSync, readdirSync, writeFileSync } from 'node:fs' +import { readdirSync, writeFileSync } from 'node:fs' import path from 'node:path' import colors from 'picocolors' import type { Options as ExecaOptions, ExecaReturnValue } from 'execa' import { execa } from 'execa' -import type { ReleaseType } from 'semver' -import semver from 'semver' import fs from 'fs-extra' -import minimist from 'minimist' - -export const args = minimist(process.argv.slice(2)) - -export const isDryRun = !!args.dry - -if (isDryRun) { - console.log(colors.inverse(colors.yellow(' DRY RUN '))) - console.log() -} - -export const packages = ['vite', 'create-vite', 'plugin-legacy'] - -export const versionIncrements: ReleaseType[] = [ - 'patch', - 'minor', - 'major', - // 'prepatch', - // 'preminor', - // 'premajor', - // 'prerelease' -] - -interface Pkg { - name: string - version: string - private?: boolean -} -export function getPackageInfo(pkgName: string): { - pkg: Pkg - pkgName: string - pkgDir: string - pkgPath: string - currentVersion: string -} { - const pkgDir = path.resolve(__dirname, '../packages/' + pkgName) - - if (!existsSync(pkgDir)) { - throw new Error(`Package ${pkgName} not found`) - } - - const pkgPath = path.resolve(pkgDir, 'package.json') - const pkg: Pkg = require(pkgPath) - const currentVersion = pkg.version - - if (pkg.private) { - throw new Error(`Package ${pkgName} is private`) - } - - return { - pkg, - pkgName, - pkgDir, - pkgPath, - currentVersion, - } -} export async function run( bin: string, @@ -75,110 +13,6 @@ export async function run( return execa(bin, args, { stdio: 'inherit', ...opts }) } -export async function dryRun( - bin: string, - args: string[], - opts?: ExecaOptions, -): Promise { - return console.log( - colors.blue(`[dryrun] ${bin} ${args.join(' ')}`), - opts || '', - ) -} - -export const runIfNotDry = isDryRun ? dryRun : run - -export function step(msg: string): void { - return console.log(colors.cyan(msg)) -} - -interface VersionChoice { - title: string - value: string -} -export function getVersionChoices(currentVersion: string): VersionChoice[] { - const currentBeta = currentVersion.includes('beta') - const currentAlpha = currentVersion.includes('alpha') - const isStable = !currentBeta && !currentAlpha - - function inc(i: ReleaseType, tag = currentAlpha ? 'alpha' : 'beta') { - return semver.inc(currentVersion, i, tag)! - } - - let versionChoices: VersionChoice[] = [ - { - title: 'next', - value: inc(isStable ? 'patch' : 'prerelease'), - }, - ] - - if (isStable) { - versionChoices.push( - { - title: 'beta-minor', - value: inc('preminor'), - }, - { - title: 'beta-major', - value: inc('premajor'), - }, - { - title: 'alpha-minor', - value: inc('preminor', 'alpha'), - }, - { - title: 'alpha-major', - value: inc('premajor', 'alpha'), - }, - { - title: 'minor', - value: inc('minor'), - }, - { - title: 'major', - value: inc('major'), - }, - ) - } else if (currentAlpha) { - versionChoices.push({ - title: 'beta', - value: inc('patch') + '-beta.0', - }) - } else { - versionChoices.push({ - title: 'stable', - value: inc('patch'), - }) - } - versionChoices.push({ value: 'custom', title: 'custom' }) - - versionChoices = versionChoices.map((i) => { - i.title = `${i.title} (${i.value})` - return i - }) - - return versionChoices -} - -export function updateVersion(pkgPath: string, version: string): void { - const pkg = fs.readJSONSync(pkgPath) - pkg.version = version - writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n') -} - -export async function publishPackage( - pkdDir: string, - tag?: string, -): Promise { - const publicArgs = ['publish', '--access', 'public'] - if (tag) { - publicArgs.push(`--tag`, tag) - } - await runIfNotDry('npm', publicArgs, { - cwd: pkdDir, - }) -} - export async function getLatestTag(pkgName: string): Promise { const tags = (await run('git', ['tag'], { stdio: 'pipe' })).stdout .split(/\n/) @@ -190,15 +24,6 @@ export async function getLatestTag(pkgName: string): Promise { .reverse()[0] } -export async function getActiveVersion(pkgName: string): Promise { - const npmName = - pkgName === 'vite' || pkgName === 'create-vite' - ? pkgName - : `@vitejs/${pkgName}` - return (await run('npm', ['info', npmName, 'version'], { stdio: 'pipe' })) - .stdout -} - export async function logRecentCommits(pkgName: string): Promise { const tag = await getLatestTag(pkgName) if (!tag) return @@ -228,19 +53,16 @@ export async function logRecentCommits(pkgName: string): Promise { } export async function updateTemplateVersions(): Promise { - const viteVersion = ( - await fs.readJSON(path.resolve(__dirname, '../packages/vite/package.json')) - ).version + const viteVersion = fs.readJSONSync('packages/vite/package.json').version if (/beta|alpha|rc/.test(viteVersion)) return - const dir = path.resolve(__dirname, '../packages/create-vite') - + const dir = 'packages/create-vite' const templates = readdirSync(dir).filter((dir) => dir.startsWith('template-'), ) for (const template of templates) { const pkgPath = path.join(dir, template, `package.json`) - const pkg = require(pkgPath) + const pkg = fs.readJSONSync(pkgPath) pkg.devDependencies.vite = `^` + viteVersion writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n') } diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 06fd68cfc95572..359dd1aeafb2b3 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "include": ["."], "compilerOptions": { - "module": "CommonJS", + "module": "ES2020", "target": "ES2020", "moduleResolution": "Node", "strict": true,