/*! * Copyright 2019 acrazing . All rights reserved. * @since 2019-11-02 00:10:00 */ import * as ts from 'typescript'; const REQUIRE_SYNC_BODY = ts.factory.createReturnStatement( ts.factory.createConditionalExpression( ts.factory.createBinaryExpression( ts.factory.createTypeOfExpression( ts.factory.createIdentifier('__webpack_require__'), ), ts.SyntaxKind.ExclamationEqualsEqualsToken, ts.factory.createStringLiteral('undefined'), ), ts.factory.createToken(ts.SyntaxKind.QuestionToken), ts.factory.createCallExpression( ts.factory.createIdentifier('__webpack_require__'), void 0, [ ts.factory.createCallExpression( ts.factory.createPropertyAccessExpression( ts.factory.createThis(), 'resolve', ), void 0, [ts.factory.createIdentifier('props')], ), ], ), ts.factory.createToken(ts.SyntaxKind.ColonToken), ts.factory.createCallExpression( ts.factory.createCallExpression( ts.factory.createIdentifier('eval'), void 0, [ts.factory.createStringLiteral('module.require')], ), void 0, [ ts.factory.createCallExpression( ts.factory.createPropertyAccessExpression( ts.factory.createThis(), 'resolve', ), void 0, [ts.factory.createIdentifier('props')], ), ], ), ), ); const REQUIRE_SYNC_PROPERTY = ts.factory.createMethodDeclaration( undefined, undefined, 'requireSync', undefined, undefined, [ ts.factory.createParameterDeclaration( undefined, undefined, 'props', undefined, undefined, ), ], undefined, ts.factory.createBlock([REQUIRE_SYNC_BODY]), ); export function createRequireSync(): ts.ObjectLiteralElementLike { return REQUIRE_SYNC_PROPERTY; }