From 400112b1ed3cdcae99827191628d3eae6bbfc839 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Tue, 23 May 2023 16:40:25 +0800 Subject: [PATCH] wip(uts): isGloballyWhitelisted --- .../uvue/compiler/transforms/transformExpression.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/uni-app-uts/src/plugins/uvue/compiler/transforms/transformExpression.ts b/packages/uni-app-uts/src/plugins/uvue/compiler/transforms/transformExpression.ts index a8b617fb4b..ea501ed050 100644 --- a/packages/uni-app-uts/src/plugins/uvue/compiler/transforms/transformExpression.ts +++ b/packages/uni-app-uts/src/plugins/uvue/compiler/transforms/transformExpression.ts @@ -9,7 +9,7 @@ // support and the code is wrapped in `with (this) { ... }`. import { NodeTransform, TransformContext } from '../transform' -import { isGloballyWhitelisted, makeMap, hasOwn, isString } from '@vue/shared' +import { makeMap, hasOwn, isString } from '@vue/shared' import { Node, Identifier } from '@babel/types' import { parse } from '@babel/parser' @@ -31,6 +31,11 @@ import { import { createCompilerError, ErrorCodes } from '../errors' +const GLOBALS_WHITE_LISTED = `Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI, + decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array, + Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console` +const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED) + const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this') export const transformExpression: NodeTransform = (node, context) => { @@ -249,7 +254,7 @@ function canPrefix(id: Identifier) { return false } // special case for webpack compilation - if (id.name === 'require' || (id.loc as any)?.identifierName === 'console') { + if (id.name === 'require') { return false } return true -- GitLab