How to use schema-utils - 10 common examples

To help you get started, we’ve selected a few schema-utils 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 lavas-project / vue-style-variables-loader / src / index.js View on Github external
export default async function (source) {

    // use cache if possible
    this.cacheable();

    const options = loaderUtils.getOptions(this);
    const {variablesFiles = [], importStatements = []} = options;

    // validate options according to schema
    validateOptions(VALIDATE_OPTIONS_SCHEMA, options, 'vue-style-variables-loader');

    // use current hash of webpack compilation
    // console.log(convertor.cacheVersion++);
    // console.log(this.request);
    // convertor.cacheVersion = this._compilation.hash;
    for (const file of variablesFiles) {
        await convertor.read(file);
        this.addDependency(file);
    }

    return convertor.convert(source, importStatements);
};
github SinaMFE / assemblyscript-typescript-loader / src / index.js View on Github external
options.limit ||
                (me.options && me.options.url && me.options.url.dataUrlLimit);
            if (limit) {
                limit = parseInt(limit, 10);
            }
            // var mimetype = options.mimetype || options.minetype || mime.lookup(this.resourcePath)
            if (!limit || distStates.size < limit) {
                me.addDependency(wasmFooterPath);
                var jsModule = transpile2Js(source);
                var wasmModule = transpile2Wasm(source, new Buffer(distFile));
                return innerCallback(
                    null,
                    createCompatibleModuleInBundle(jsModule, wasmModule)
                );
            } else {
                validateOptions(
                    schema4file,
                    options,
                    "AssemblyScript-TypeScript File Loader"
                );
                const url = loaderUtils.interpolateName(me, options.name, {
                    me,
                    content: distFile
                });
                var filePath = me.resourcePath;
                let outputPath = url;

                if (options.outputPath) {
                    if (typeof options.outputPath === "function") {
                        outputPath = options.outputPath(url);
                    } else {
                        outputPath = path.posix.join(options.outputPath, url);
github SinaMFE / assemblyscript-typescript-loader / src / index.js View on Github external
export default function loader(source) {
    var innerCallback = this.async();
    const options = loaderUtils.getOptions(this) || {};
    validateOptions(schema, options, "AssemblyScript-TypeScript Buffer Loader");
    if (this.cacheable) {
        this.cacheable();
    }
    var me = this;
    var targetPath = this._compiler.outputPath;
    var buildTempPath = path.join(this._compiler.context, "/temp/assembly/");
    targetPath = path.join(
        buildTempPath,
        path.parse(this.resourcePath).name + ".wasm"
    );
    mkDirsSync(buildTempPath);
    let params = [
        path.relative(process.cwd(), this.resourcePath),
        "-o",
        path.relative(process.cwd(), targetPath)
        // ,
github pigcan / extra-watch-webpack-plugin / src / index.js View on Github external
constructor(options = {}) {
    validateOptions(require('../options.json'), options, 'ExtraWatchWebpackPlugin'); // eslint-disable-line
    this.options = { ...ExtraWatchWebpackPlugin.defaults, ...options };
  }
github pranaygp / now-loader / src / index.js View on Github external
export default function(content){
  const options = getOptions(this) || {};
  
  validateOptions(schema, options, 'now-loader');
  const callback = this.async();
  
  const context = options.context || this.rootContext || (this.options && this.options.context);
  let apiKey = options.apiKey;
  if(!apiKey) {
    const apiKeyPath = path.join(process.env.HOME, '.now/auth.json');
    this.addDependency(apiKeyPath);
    const { credentials } = JSON.parse(fs.readFileSync(apiKeyPath, 'utf8'));
    apiKey = credentials.find(({provider}) => provider === 'sh').token;
  }
  const name = interpolateName(this, options.name, {
    context,
    content,
    regExp: options.regExp,
  });
github remaxjs / remax / packages / remax-cli / src / getConfig.ts View on Github external
export default function getConfig(): RemaxOptions {
  const configPath: string = path.join(process.cwd(), './remax.config');
  let options = {};

  if (fs.existsSync(configPath + '.js')) {
    options = readJavascriptConfig(configPath + '.js');
  }

  validateOptions(schema as any, options, {
    name: 'remax',
  });

  return {
    ...defaultOptions,
    ...options,
  };
}
github aruntk / wc-loader / src / index.js View on Github external
function getLoaderConfig(context) {
  const options = loaderUtils.getOptions(context) || {}
  validateOptions(schema, options, 'HTML Loader')
  return options
}
function convertPlaceholder(html, links, config) {
github borela-tech / js-toolbox / src / configs / webpack / plugins / Html / index.js View on Github external
constructor(options) {
    validateOptions(OPTIONS_SCHEMA, options, PLUGIN_NAME)

    let {base, dir, name} = parsePath(options.templatePath)
    let {
      alwaysWriteToDisk,
      head: {appendScripts = []},
      hot,
      minify,
      templatePath,
    } = options

    this._alwaysWriteToDisk = alwaysWriteToDisk || true
    this._head.appendScripts = appendScripts
    this._hot = hot
    this._minify = minify
    this._template = {
      ...this._template,
github jahredhope / html-render-webpack-plugin / src / index.ts View on Github external
constructor(options: Options = {}) {
    validateOptions(schema, options || {}, "HTML Render Webpack Plugin");

    const pluginName = "HtmlRenderPlugin";

    const {
      extraGlobals = {},
      skipAssets = false,
      mapStatsToParams = defaultMapStats,
      renderEntry = "main",
      getRouteFromRequest,
      transformFilePath = defaultTransform,
      transformExpressPath = defaultTransform,
      renderConcurrency = "serial"
    } = options;

    const routes: Route[] = (options.routes || [""]).map(route =>
      typeof route === "string" ? ({ route } as Route) : route

schema-utils

webpack Validation Utils

MIT
Latest version published 12 months ago

Package Health Score

80 / 100
Full package analysis

Popular schema-utils functions