How to use the enhanced-resolve/lib/node.create function in enhanced-resolve

To help you get started, we’ve selected a few enhanced-resolve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github callstack / linaria / src / loader.js View on Github external
const outputFilename = path.join(
    path.isAbsolute(cacheDirectory)
      ? cacheDirectory
      : path.join(process.cwd(), cacheDirectory),
    path.relative(
      process.cwd(),
      this.resourcePath.replace(/\.[^.]+$/, '.linaria.css')
    )
  );

  const resolveOptions = {
    extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
  };

  const resolveSync = enhancedResolve.create.sync(
    // this._compilation is a deprecated API
    // However there seems to be no other way to access webpack's resolver
    // There is this.resolve, but it's asynchronous
    // Another option is to read the webpack.config.js, but it won't work for programmatic usage
    // This API is used by many loaders/plugins, so hope we're safe for a while
    this._compilation && this._compilation.options.resolve
      ? {
          ...resolveOptions,
          alias: this._compilation.options.resolve.alias,
          modules: this._compilation.options.resolve.modules,
        }
      : resolveOptions
  );

  let result;
github TypeStrong / ts-loader / src / resolver.ts View on Github external
export function makeResolver(options: webpack.Configuration): ResolveSync {
  return node.create.sync(options.resolve);
}
github ecomfe / veui / packages / veui-loader / index.js View on Github external
function makeSyncResolver (options) {
  return resolve.create.sync(options.resolve)
}