]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(build): rename __NODE_JS__ build flag to __CJS__
authorEvan You <yyx990803@gmail.com>
Thu, 11 Jan 2024 10:24:21 +0000 (18:24 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 11 Jan 2024 10:24:21 +0000 (18:24 +0800)
packages/compiler-sfc/src/script/resolveType.ts
packages/global.d.ts
packages/runtime-core/src/index.ts
packages/server-renderer/src/helpers/ssrCompile.ts
packages/server-renderer/src/renderToStream.ts
rollup.config.js
scripts/dev.js
vitest.config.ts

index 3f965e99735a187f93d79f790f1db3a1fc9c10f1..548d5d13c6d639f3101172ddc48382520fb983bc 100644 (file)
@@ -908,7 +908,7 @@ function importSourceToScope(
       resolved = resolveExt(filename, fs)
     } else {
       // module or aliased import - use full TS resolution, only supported in Node
-      if (!__NODE_JS__) {
+      if (!__CJS__) {
         return ctx.error(
           `Type import from non-relative sources is not supported in the browser build.`,
           node,
@@ -975,7 +975,7 @@ function resolveWithTS(
   ts: typeof TS,
   fs: FS,
 ): string | undefined {
-  if (!__NODE_JS__) return
+  if (!__CJS__) return
 
   // 1. resolve tsconfig.json
   const configPath = ts.findConfigFile(containingFile, fs.fileExists)
index 1367b69cd5b014f25c6b9eca280355b56b0c023c..704f6d0220dc8f41c256839524ab4bc165ed0842 100644 (file)
@@ -7,7 +7,7 @@ declare var __BROWSER__: boolean
 declare var __GLOBAL__: boolean
 declare var __ESM_BUNDLER__: boolean
 declare var __ESM_BROWSER__: boolean
-declare var __NODE_JS__: boolean
+declare var __CJS__: boolean
 declare var __SSR__: boolean
 declare var __COMMIT__: string
 declare var __VERSION__: string
index 13345b78a456d6f0eb2b50c960369de1a17e9a46..7d9bd102fb3699a52babf47f348d0b7dc03b0b1f 100644 (file)
@@ -150,7 +150,7 @@ import { ErrorTypeStrings as _ErrorTypeStrings } from './errorHandling'
  * @internal
  */
 export const ErrorTypeStrings = (
-  __ESM_BUNDLER__ || __NODE_JS__ || __DEV__ ? _ErrorTypeStrings : null
+  __ESM_BUNDLER__ || __CJS__ || __DEV__ ? _ErrorTypeStrings : null
 ) as typeof _ErrorTypeStrings
 
 // For devtools
index 6ab296976ace98b5eb342b65d63794dbe2553001..8412a65e843e975083bde340f1f485f2920b4591 100644 (file)
@@ -24,7 +24,7 @@ export function ssrCompile(
   instance: ComponentInternalInstance,
 ): SSRRenderFunction {
   // TODO: this branch should now work in ESM builds, enable it in a minor
-  if (!__NODE_JS__) {
+  if (!__CJS__) {
     throw new Error(
       `On-the-fly template compilation is not supported in the ESM build of ` +
         `@vue/server-renderer. All templates must be pre-compiled into ` +
index 828e385cb90031a7fcfb3daf99ebef2fb05e038f..60b277a4a9b48823edc8572472980563837df5ca 100644 (file)
@@ -108,7 +108,7 @@ export function renderToNodeStream(
   input: App | VNode,
   context: SSRContext = {},
 ): Readable {
-  const stream: Readable = __NODE_JS__
+  const stream: Readable = __CJS__
     ? new (require('node:stream').Readable)({ read() {} })
     : null
 
index b6a098fa69e2e498363ae5b72595eb43ef8d3e3e..657b711b1a32e74d5de12956eaa13e0a8e44dd06 100644 (file)
@@ -122,7 +122,7 @@ function createConfig(format, output, plugins = []) {
   const isBundlerESMBuild = /esm-bundler/.test(format)
   const isBrowserESMBuild = /esm-browser/.test(format)
   const isServerRenderer = name === 'server-renderer'
-  const isNodeBuild = format === 'cjs'
+  const isCJSBuild = format === 'cjs'
   const isGlobalBuild = /global/.test(format)
   const isCompatPackage =
     pkg.name === '@vue/compat' || pkg.name === '@vue/compat-canary'
@@ -138,7 +138,7 @@ function createConfig(format, output, plugins = []) {
 **/`
 
   output.exports = isCompatPackage ? 'auto' : 'named'
-  if (isNodeBuild) {
+  if (isCJSBuild) {
     output.esModule = true
   }
   output.sourcemap = !!process.env.SOURCE_MAP
@@ -172,9 +172,9 @@ function createConfig(format, output, plugins = []) {
       __ESM_BUNDLER__: String(isBundlerESMBuild),
       __ESM_BROWSER__: String(isBrowserESMBuild),
       // is targeting Node (SSR)?
-      __NODE_JS__: String(isNodeBuild),
+      __CJS__: String(isCJSBuild),
       // need SSR-specific branches?
-      __SSR__: String(isNodeBuild || isBundlerESMBuild || isServerRenderer),
+      __SSR__: String(isCJSBuild || isBundlerESMBuild || isServerRenderer),
 
       // 2.x compat build
       __COMPAT__: String(isCompatBuild),
@@ -329,7 +329,7 @@ function createConfig(format, output, plugins = []) {
         tsconfig: path.resolve(__dirname, 'tsconfig.json'),
         sourceMap: output.sourcemap,
         minify: false,
-        target: isServerRenderer || isNodeBuild ? 'es2019' : 'es2015',
+        target: isServerRenderer || isCJSBuild ? 'es2019' : 'es2015',
         define: resolveDefine(),
       }),
       ...resolveNodePlugins(),
index 2c3cdaf95e2e7f8957e7f36f36b0f4c978357354..b015835ab4f9b9c429e5ee0105ea5b90c7d8a942 100644 (file)
@@ -119,7 +119,7 @@ esbuild
       __GLOBAL__: String(format === 'global'),
       __ESM_BUNDLER__: String(format.includes('esm-bundler')),
       __ESM_BROWSER__: String(format.includes('esm-browser')),
-      __NODE_JS__: String(format === 'cjs'),
+      __CJS__: String(format === 'cjs'),
       __SSR__: String(format === 'cjs' || format.includes('esm-bundler')),
       __COMPAT__: String(target === 'vue-compat'),
       __FEATURE_SUSPENSE__: `true`,
index 6b5b93a45f9f80fc3536f92e08b5f9d0f2734377..e6436408adb68a87e02a0c0725128a5a69a4d509 100644 (file)
@@ -11,7 +11,7 @@ export default defineConfig({
     __GLOBAL__: false,
     __ESM_BUNDLER__: true,
     __ESM_BROWSER__: false,
-    __NODE_JS__: true,
+    __CJS__: true,
     __SSR__: true,
     __FEATURE_OPTIONS_API__: true,
     __FEATURE_SUSPENSE__: true,