chore(build): rename __NODE_JS__ build flag to __CJS__
This commit is contained in:
parent
8fda856a82
commit
bceccf9e21
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ` +
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue