MCPcopy
hub / github.com/TypeStrong/ts-loader / getOptions

Function getOptions

src/loaderUtils.ts:12–30  ·  view source on GitHub ↗
(
  loaderContext: webpack.LoaderContext<LoaderOptions>
)

Source from the content-addressed store, hash-verified

10let loaderUtils: LoaderUtilsModule | undefined;
11
12export function getOptions(
13 loaderContext: webpack.LoaderContext<LoaderOptions>
14) {
15 if (isWebpack5) {
16 return loaderContext.getOptions();
17 }
18
19 if (!loaderUtils) {
20 try {
21 loaderUtils = module.require('loader-utils') as LoaderUtilsModule;
22 } catch {
23 throw new Error(
24 'ts-loader requires loader-utils to be installed when used with webpack 4.'
25 );
26 }
27 }
28
29 return loaderUtils.getOptions<LoaderOptions>(loaderContext as any) || ({} as LoaderOptions);
30}
31
32/**
33 * webpack 4 and webpack 5 have different APIs for adding errors to modules. This function abstracts that away.

Callers

nothing calls this directly

Calls 1

getOptionsMethod · 0.80

Tested by

no test coverage detected