microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.8.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/common/customRequire.ts

24lines · modeblame

2d8af448Yuri Skorokhodov6 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
65e55367RedMickey4 years ago4interface CustomRequire extends NodeRequireFunction {
5cache: any;
6}
7
2d8af448Yuri Skorokhodov6 years ago8// Portion of code was taken from https://github.com/sindresorhus/ow/blob/d62a06c192b892d504887f0b97fdc842e8cbf862/source/utils/node/require.ts
65e55367RedMickey4 years ago9let customRequire: CustomRequire;
2d8af448Yuri Skorokhodov6 years ago10
11try {
12// Export `__non_webpack_require__` in Webpack environments to make sure it doesn't bundle modules loaded via this method
34472878RedMickey5 years ago13customRequire =
14(global as any).__non_webpack_require__ === "function"
15? (global as any).__non_webpack_require__
16: eval("require");
2d8af448Yuri Skorokhodov6 years ago17} catch {
18// Use a noop in case both `__non_webpack_require__` and `require` does not exist
65e55367RedMickey4 years ago19customRequire = ((() => {
20customRequire.cache = {}; // eslint-disable-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-empty-function
21}) as any) as CustomRequire;
2d8af448Yuri Skorokhodov6 years ago22}
23
34472878RedMickey5 years ago24export default customRequire;