Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve webpack dynamic require problem, add additional attribution
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for details. | ||
|
||
// Portion of code was taken from https://github.com/sindresorhus/ow/blob/d62a06c192b892d504887f0b97fdc842e8cbf862/source/utils/node/require.ts | ||
let customRequire: (packageName: string) => any; | ||
|
||
try { | ||
// Export `__non_webpack_require__` in Webpack environments to make sure it doesn't bundle modules loaded via this method | ||
customRequire = (global as any).__non_webpack_require__ === 'function' | ||
? (global as any).__non_webpack_require__ | ||
: eval('require'); // tslint:disable-line:no-eval | ||
} catch { | ||
// Use a noop in case both `__non_webpack_require__` and `require` does not exist | ||
customRequire = () => {}; // tslint:disable-line:no-empty | ||
} | ||
|
||
export default customRequire; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters