From 5bd6997d3c2288a20d281b48256b0b67a94148be Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 31 Dec 2022 20:27:35 +0800 Subject: [PATCH] chore: add prefix of node core modules (#11440) --- packages/create-vant-cli-app/src/constant.ts | 2 +- packages/create-vant-cli-app/src/generator.ts | 2 +- packages/vant-cli/src/commands/build.ts | 2 +- packages/vant-cli/src/commands/changelog.ts | 6 +++--- packages/vant-cli/src/commands/commit-lint.ts | 2 +- packages/vant-cli/src/commands/release.ts | 4 ++-- packages/vant-cli/src/common/constant.ts | 6 +++--- packages/vant-cli/src/common/css.ts | 4 ++-- packages/vant-cli/src/common/index.ts | 2 +- packages/vant-cli/src/compiler/compile-less.ts | 4 ++-- packages/vant-cli/src/compiler/compile-sass.ts | 2 +- packages/vant-cli/src/compiler/compile-script.ts | 2 +- packages/vant-cli/src/compiler/compile-sfc.ts | 2 +- packages/vant-cli/src/compiler/compile-site.ts | 2 +- packages/vant-cli/src/compiler/compile-style.ts | 2 +- packages/vant-cli/src/compiler/gen-component-style.ts | 4 ++-- packages/vant-cli/src/compiler/gen-package-entry.ts | 2 +- packages/vant-cli/src/compiler/gen-package-style.ts | 6 +++--- packages/vant-cli/src/compiler/gen-site-desktop-shared.ts | 4 ++-- packages/vant-cli/src/compiler/gen-site-mobile-shared.ts | 4 ++-- packages/vant-cli/src/compiler/gen-style-deps-map.ts | 4 ++-- packages/vant-cli/src/compiler/get-deps.ts | 4 ++-- packages/vant-cli/src/compiler/web-types/index.ts | 2 +- packages/vant-cli/src/compiler/web-types/type.ts | 2 +- packages/vant-cli/src/config/vite.package.ts | 2 +- packages/vant-cli/src/config/vite.site.ts | 4 ++-- packages/vant-cli/src/index.ts | 4 ++-- 27 files changed, 43 insertions(+), 43 deletions(-) diff --git a/packages/create-vant-cli-app/src/constant.ts b/packages/create-vant-cli-app/src/constant.ts index 73406715d..e7fdbcfe5 100644 --- a/packages/create-vant-cli-app/src/constant.ts +++ b/packages/create-vant-cli-app/src/constant.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from 'node:path'; export const CWD = process.cwd(); export const GENERATOR_DIR = join(__dirname, '../generators'); diff --git a/packages/create-vant-cli-app/src/generator.ts b/packages/create-vant-cli-app/src/generator.ts index b8ba0f0bd..b478b1436 100644 --- a/packages/create-vant-cli-app/src/generator.ts +++ b/packages/create-vant-cli-app/src/generator.ts @@ -3,7 +3,7 @@ import glob from 'fast-glob'; import color from 'picocolors'; import consola from 'consola'; import { prompt } from 'enquirer'; -import { sep, join } from 'path'; +import { sep, join } from 'node:path'; import { CWD, GENERATOR_DIR } from './constant'; const PROMPTS = [ diff --git a/packages/vant-cli/src/commands/build.ts b/packages/vant-cli/src/commands/build.ts index b6a042686..24f5a0ad6 100644 --- a/packages/vant-cli/src/commands/build.ts +++ b/packages/vant-cli/src/commands/build.ts @@ -1,6 +1,6 @@ import fse from 'fs-extra'; import { execa } from 'execa'; -import { join, relative } from 'path'; +import { join, relative } from 'node:path'; import { clean } from './clean.js'; import { CSS_LANG } from '../common/css.js'; import { createSpinner, consola } from '../common/logger.js'; diff --git a/packages/vant-cli/src/commands/changelog.ts b/packages/vant-cli/src/commands/changelog.ts index ead45ab4f..e8e266d92 100644 --- a/packages/vant-cli/src/commands/changelog.ts +++ b/packages/vant-cli/src/commands/changelog.ts @@ -1,8 +1,8 @@ -import { join, dirname } from 'path'; -import { fileURLToPath } from 'url'; +import { join, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { ROOT } from '../common/constant.js'; import { createSpinner, slimPath } from '../common/logger.js'; -import { createWriteStream, readFileSync } from 'fs'; +import { createWriteStream, readFileSync } from 'node:fs'; import conventionalChangelog from 'conventional-changelog'; const DIST_FILE = join(ROOT, './changelog.generated.md'); diff --git a/packages/vant-cli/src/commands/commit-lint.ts b/packages/vant-cli/src/commands/commit-lint.ts index 94727d1d9..01d42ca26 100644 --- a/packages/vant-cli/src/commands/commit-lint.ts +++ b/packages/vant-cli/src/commands/commit-lint.ts @@ -1,4 +1,4 @@ -import { readFileSync } from 'fs'; +import { readFileSync } from 'node:fs'; import { consola } from '../common/logger.js'; const commitRE = diff --git a/packages/vant-cli/src/commands/release.ts b/packages/vant-cli/src/commands/release.ts index 52618e206..50b0cea59 100644 --- a/packages/vant-cli/src/commands/release.ts +++ b/packages/vant-cli/src/commands/release.ts @@ -1,7 +1,7 @@ /* eslint-disable no-template-curly-in-string */ import releaseIt from 'release-it'; -import { join, dirname } from 'path'; -import { fileURLToPath } from 'url'; +import { join, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js'); diff --git a/packages/vant-cli/src/common/constant.ts b/packages/vant-cli/src/common/constant.ts index 7ae07fd78..9a4f0e8ab 100644 --- a/packages/vant-cli/src/common/constant.ts +++ b/packages/vant-cli/src/common/constant.ts @@ -1,6 +1,6 @@ -import { existsSync, readFileSync } from 'fs'; -import { fileURLToPath, pathToFileURL } from 'url'; -import { join, dirname, isAbsolute } from 'path'; +import { existsSync, readFileSync } from 'node:fs'; +import { fileURLToPath, pathToFileURL } from 'node:url'; +import { join, dirname, isAbsolute } from 'node:path'; function findRootDir(dir: string): string { if (existsSync(join(dir, 'vant.config.mjs'))) { diff --git a/packages/vant-cli/src/common/css.ts b/packages/vant-cli/src/common/css.ts index 98f5679cd..c6aafad1c 100644 --- a/packages/vant-cli/src/common/css.ts +++ b/packages/vant-cli/src/common/css.ts @@ -1,5 +1,5 @@ -import { existsSync } from 'fs'; -import { join, isAbsolute } from 'path'; +import { existsSync } from 'node:fs'; +import { join, isAbsolute } from 'node:path'; import { getVantConfig } from '../common/index.js'; import { STYLE_DIR, SRC_DIR } from './constant.js'; diff --git a/packages/vant-cli/src/common/index.ts b/packages/vant-cli/src/common/index.ts index 3abefae87..4bb8a7b39 100644 --- a/packages/vant-cli/src/common/index.ts +++ b/packages/vant-cli/src/common/index.ts @@ -1,5 +1,5 @@ import fse from 'fs-extra'; -import { sep, join } from 'path'; +import { sep, join } from 'node:path'; import { SRC_DIR, getVantConfig } from './constant.js'; import { InlineConfig, loadConfigFromFile, mergeConfig } from 'vite'; diff --git a/packages/vant-cli/src/compiler/compile-less.ts b/packages/vant-cli/src/compiler/compile-less.ts index d75e22897..ce97c6ee7 100644 --- a/packages/vant-cli/src/compiler/compile-less.ts +++ b/packages/vant-cli/src/compiler/compile-less.ts @@ -1,6 +1,6 @@ import less from 'less'; -import { join } from 'path'; -import { readFileSync } from 'fs'; +import { join } from 'node:path'; +import { readFileSync } from 'node:fs'; import { CWD } from '../common/constant.js'; export async function compileLess(filePath: string) { diff --git a/packages/vant-cli/src/compiler/compile-sass.ts b/packages/vant-cli/src/compiler/compile-sass.ts index 6d853dd4d..822bfb1dd 100644 --- a/packages/vant-cli/src/compiler/compile-sass.ts +++ b/packages/vant-cli/src/compiler/compile-sass.ts @@ -1,4 +1,4 @@ -import { createRequire } from 'module'; +import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); diff --git a/packages/vant-cli/src/compiler/compile-script.ts b/packages/vant-cli/src/compiler/compile-script.ts index e1f14dd1f..fa5472203 100644 --- a/packages/vant-cli/src/compiler/compile-script.ts +++ b/packages/vant-cli/src/compiler/compile-script.ts @@ -1,7 +1,7 @@ import fse from 'fs-extra'; import babel from '@babel/core'; import esbuild, { type Format } from 'esbuild'; -import { sep } from 'path'; +import { sep } from 'node:path'; import { isJsx, replaceExt, getVantConfig } from '../common/index.js'; import { replaceCSSImportExt } from '../common/css.js'; import { replaceScriptImportExt } from './get-deps.js'; diff --git a/packages/vant-cli/src/compiler/compile-sfc.ts b/packages/vant-cli/src/compiler/compile-sfc.ts index 6c3acd0ff..72d153751 100644 --- a/packages/vant-cli/src/compiler/compile-sfc.ts +++ b/packages/vant-cli/src/compiler/compile-sfc.ts @@ -1,5 +1,5 @@ import fse from 'fs-extra'; -import path from 'path'; +import path from 'node:path'; import hash from 'hash-sum'; import { parse, diff --git a/packages/vant-cli/src/compiler/compile-site.ts b/packages/vant-cli/src/compiler/compile-site.ts index efdc6307a..a07ecedb6 100644 --- a/packages/vant-cli/src/compiler/compile-site.ts +++ b/packages/vant-cli/src/compiler/compile-site.ts @@ -1,5 +1,5 @@ import color from 'picocolors'; -import { createRequire } from 'module'; +import { createRequire } from 'node:module'; import { createServer, build } from 'vite'; import { getViteConfigForSiteDev, diff --git a/packages/vant-cli/src/compiler/compile-style.ts b/packages/vant-cli/src/compiler/compile-style.ts index bf5a64e24..15244e277 100644 --- a/packages/vant-cli/src/compiler/compile-style.ts +++ b/packages/vant-cli/src/compiler/compile-style.ts @@ -1,4 +1,4 @@ -import { parse } from 'path'; +import { parse } from 'node:path'; import fse from 'fs-extra'; import { getVantConfig, replaceExt } from '../common/index.js'; import { compileCss } from './compile-css.js'; diff --git a/packages/vant-cli/src/compiler/gen-component-style.ts b/packages/vant-cli/src/compiler/gen-component-style.ts index b098b0630..1236b4a8f 100644 --- a/packages/vant-cli/src/compiler/gen-component-style.ts +++ b/packages/vant-cli/src/compiler/gen-component-style.ts @@ -3,8 +3,8 @@ */ import fse from 'fs-extra'; -import { createRequire } from 'module'; -import { sep, join, relative } from 'path'; +import { createRequire } from 'node:module'; +import { sep, join, relative } from 'node:path'; import { getComponents, replaceExt } from '../common/index.js'; import { CSS_LANG, getCssBaseFile } from '../common/css.js'; import { checkStyleExists } from './gen-style-deps-map.js'; diff --git a/packages/vant-cli/src/compiler/gen-package-entry.ts b/packages/vant-cli/src/compiler/gen-package-entry.ts index 65510da1a..fb83b913e 100644 --- a/packages/vant-cli/src/compiler/gen-package-entry.ts +++ b/packages/vant-cli/src/compiler/gen-package-entry.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from 'node:path'; import { pascalize, getComponents, diff --git a/packages/vant-cli/src/compiler/gen-package-style.ts b/packages/vant-cli/src/compiler/gen-package-style.ts index fdb62612e..4b0896c2d 100644 --- a/packages/vant-cli/src/compiler/gen-package-style.ts +++ b/packages/vant-cli/src/compiler/gen-package-style.ts @@ -1,6 +1,6 @@ -import { join } from 'path'; -import { existsSync } from 'fs'; -import { createRequire } from 'module'; +import { join } from 'node:path'; +import { existsSync } from 'node:fs'; +import { createRequire } from 'node:module'; import { smartOutputFile, normalizePath } from '../common/index.js'; import { CSS_LANG, getCssBaseFile } from '../common/css.js'; import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant.js'; diff --git a/packages/vant-cli/src/compiler/gen-site-desktop-shared.ts b/packages/vant-cli/src/compiler/gen-site-desktop-shared.ts index d9214eeae..22d234c93 100644 --- a/packages/vant-cli/src/compiler/gen-site-desktop-shared.ts +++ b/packages/vant-cli/src/compiler/gen-site-desktop-shared.ts @@ -1,6 +1,6 @@ import glob from 'fast-glob'; -import { join, parse } from 'path'; -import { existsSync, readFileSync, readdirSync } from 'fs'; +import { join, parse } from 'node:path'; +import { existsSync, readFileSync, readdirSync } from 'node:fs'; import { pascalize, getVantConfig, normalizePath } from '../common/index.js'; import { SRC_DIR, diff --git a/packages/vant-cli/src/compiler/gen-site-mobile-shared.ts b/packages/vant-cli/src/compiler/gen-site-mobile-shared.ts index c6a9bf874..7911aec47 100644 --- a/packages/vant-cli/src/compiler/gen-site-mobile-shared.ts +++ b/packages/vant-cli/src/compiler/gen-site-mobile-shared.ts @@ -1,5 +1,5 @@ -import { join } from 'path'; -import { existsSync, readdirSync } from 'fs'; +import { join } from 'node:path'; +import { existsSync, readdirSync } from 'node:fs'; import { SRC_DIR } from '../common/constant.js'; import { pascalize, diff --git a/packages/vant-cli/src/compiler/gen-style-deps-map.ts b/packages/vant-cli/src/compiler/gen-style-deps-map.ts index e33605e55..fce68acd5 100644 --- a/packages/vant-cli/src/compiler/gen-style-deps-map.ts +++ b/packages/vant-cli/src/compiler/gen-style-deps-map.ts @@ -1,6 +1,6 @@ -import { relative, sep, join } from 'path'; +import { relative, sep, join } from 'node:path'; import { CSS_LANG } from '../common/css.js'; -import { existsSync } from 'fs'; +import { existsSync } from 'node:fs'; import { getDeps, clearDepsCache, fillExt } from './get-deps.js'; import { getComponents, smartOutputFile } from '../common/index.js'; import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant.js'; diff --git a/packages/vant-cli/src/compiler/get-deps.ts b/packages/vant-cli/src/compiler/get-deps.ts index 8c56f33a8..5fba5a936 100644 --- a/packages/vant-cli/src/compiler/get-deps.ts +++ b/packages/vant-cli/src/compiler/get-deps.ts @@ -1,6 +1,6 @@ -import { join } from 'path'; +import { join } from 'node:path'; import { SCRIPT_EXTS, STYLE_EXTS } from '../common/constant.js'; -import { readFileSync, existsSync } from 'fs'; +import { readFileSync, existsSync } from 'node:fs'; let depsMap: Record = {}; let existsCache: Record = {}; diff --git a/packages/vant-cli/src/compiler/web-types/index.ts b/packages/vant-cli/src/compiler/web-types/index.ts index 1d4dda415..b28aeeaff 100644 --- a/packages/vant-cli/src/compiler/web-types/index.ts +++ b/packages/vant-cli/src/compiler/web-types/index.ts @@ -1,5 +1,5 @@ import glob from 'fast-glob'; -import { join } from 'path'; +import { join } from 'node:path'; import fse from 'fs-extra'; import { mdParser } from './parser.js'; import { formatter } from './formatter.js'; diff --git a/packages/vant-cli/src/compiler/web-types/type.ts b/packages/vant-cli/src/compiler/web-types/type.ts index 834bba41f..ab7dbcf05 100644 --- a/packages/vant-cli/src/compiler/web-types/type.ts +++ b/packages/vant-cli/src/compiler/web-types/type.ts @@ -1,4 +1,4 @@ -import { PathLike } from 'fs'; +import { PathLike } from 'node:fs'; export type VueSlot = { name: string; diff --git a/packages/vant-cli/src/config/vite.package.ts b/packages/vant-cli/src/config/vite.package.ts index 94407927b..8c91ee2a8 100644 --- a/packages/vant-cli/src/config/vite.package.ts +++ b/packages/vant-cli/src/config/vite.package.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from 'node:path'; import { setBuildTarget } from '../common/index.js'; import { CWD, ES_DIR, getVantConfig, LIB_DIR } from '../common/constant.js'; import type { InlineConfig } from 'vite'; diff --git a/packages/vant-cli/src/config/vite.site.ts b/packages/vant-cli/src/config/vite.site.ts index 8e2f63aec..73c1b819c 100644 --- a/packages/vant-cli/src/config/vite.site.ts +++ b/packages/vant-cli/src/config/vite.site.ts @@ -1,5 +1,5 @@ -import { join } from 'path'; -import { createRequire } from 'module'; +import { join } from 'node:path'; +import { createRequire } from 'node:module'; import hljs from 'highlight.js'; import vitePluginMd from 'vite-plugin-md'; import vitePluginVue from '@vitejs/plugin-vue'; diff --git a/packages/vant-cli/src/index.ts b/packages/vant-cli/src/index.ts index 5f4f275f8..1003e554a 100755 --- a/packages/vant-cli/src/index.ts +++ b/packages/vant-cli/src/index.ts @@ -1,6 +1,6 @@ // @ts-ignore -import fs from 'fs'; -import { URL, fileURLToPath } from 'url'; +import fs from 'node:fs'; +import { URL, fileURLToPath } from 'node:url'; const packagePath = fileURLToPath(new URL('../package.json', import.meta.url)); const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));