Files
developtools_ace-ets2bundle/compiler/src/process_js_ast.ts
T
zhangrengao c120766ac7 adapter module compile
Signed-off-by: zhangrengao <zhangrengao1@huawei.com>
Change-Id: Ib47c77cf607a8a4af4240e22d8196fd8a350149c
2022-06-07 14:18:29 +08:00

35 lines
1.2 KiB
TypeScript

/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ts from 'typescript';
import path from 'path';
import { BUILD_ON } from './pre_define';
import { writeFileSyncByNode } from './utils';
export function processJs(program: ts.Program, ut = false): Function {
return (context: ts.TransformationContext) => {
return (node: ts.SourceFile) => {
if (process.env.compiler === BUILD_ON) {
if (process.env.processTs && process.env.processTs === 'false') {
writeFileSyncByNode(node, false);
}
return node;
} else {
return node;
}
}
}
}