| 220 | // esbuild define is a bit strict and only allows literal json or identifiers |
| 221 | // so we still need replace plugin in some cases |
| 222 | function resolveReplace() { |
| 223 | const replacements = { ...enumDefines } |
| 224 | |
| 225 | if (isProductionBuild && isBrowserBuild) { |
| 226 | Object.assign(replacements, { |
| 227 | 'context.onError(': `/*@__PURE__*/ context.onError(`, |
| 228 | 'emitError(': `/*@__PURE__*/ emitError(`, |
| 229 | 'createCompilerError(': `/*@__PURE__*/ createCompilerError(`, |
| 230 | 'createDOMCompilerError(': `/*@__PURE__*/ createDOMCompilerError(`, |
| 231 | }) |
| 232 | } |
| 233 | |
| 234 | if (isBundlerESMBuild) { |
| 235 | Object.assign(replacements, { |
| 236 | // preserve to be handled by bundlers |
| 237 | __DEV__: `!!(process.env.NODE_ENV !== 'production')`, |
| 238 | }) |
| 239 | } |
| 240 | |
| 241 | // for compiler-sfc browser build inlined deps |
| 242 | if (isBrowserESMBuild) { |
| 243 | Object.assign(replacements, { |
| 244 | 'process.env': '({})', |
| 245 | 'process.platform': '""', |
| 246 | 'process.stdout': 'null', |
| 247 | }) |
| 248 | } |
| 249 | |
| 250 | if (Object.keys(replacements).length) { |
| 251 | return [replace({ values: replacements, preventAssignment: true })] |
| 252 | } else { |
| 253 | return [] |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | function resolveExternal() { |
| 258 | const treeShakenDeps = [ |