How to use the neutrino/errors.ConfigurationError function in neutrino

To help you get started, we’ve selected a few neutrino 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 neutrinojs / neutrino / packages / web / index.js View on Github external
);
  }

  if (
    typeof options.devtool === 'string' ||
    typeof options.devtool === 'boolean'
  ) {
    options.devtool = {
      development: options.devtool,
      production: options.devtool,
      test: options.devtool,
    };
  }

  if (options.style && options.style.extract === true) {
    throw new ConfigurationError(
      'Setting `style.extract` to `true` is no longer supported. Override `style.extract.enabled` instead.',
    );
  }

  // Force @babel/preset-env default behavior (.browserslistrc)
  if (options.targets === false) {
    options.targets = {};
  } else if (!options.targets.node && !options.targets.browsers) {
    options.targets.browsers = [
      'last 2 Chrome versions',
      'last 2 Firefox versions',
      'last 2 Edge versions',
      'last 2 Opera versions',
      'last 2 Safari versions',
      'last 2 iOS versions',
    ];
github neutrinojs / neutrino / packages / eslint / index.js View on Github external
module.exports = ({ test, include, exclude, eslint = {} } = {}) => {
  // Neither eslint-loader nor ESLint's `CLIEngine` fully validate passed options,
  // so we do so here to make it easier to work out why settings seemingly aren't
  // taking effect. This is particularly important given that the configuration
  // options are inconsistently named between CLIEngine and the eslintrc schema.
  // Upstream issues for adding validation:
  // https://github.com/webpack-contrib/eslint-loader/issues/252
  // https://github.com/eslint/eslint/issues/10272
  const invalidOptions = Object.keys(eslint).filter(
    option => !validLoaderOptions.includes(option),
  );

  if (invalidOptions.length) {
    throw new ConfigurationError(
      `Unrecognised 'eslint' option(s): ${invalidOptions.join(', ')}\n` +
        `Valid options are: ${validLoaderOptions.sort().join(', ')}\n` +
        'If trying to set `extends`, `overrides` or `settings`, they must be ' +
        'defined under the `baseConfig` key and not as a top-level option. ' +
        'See: https://neutrinojs.org/packages/eslint/#usage',
    );
  }

  return neutrino => {
    if (neutrino.config.module.rules.has('compile')) {
      throw new ConfigurationError(
        'Lint presets must be defined prior to any other presets in .neutrinorc.js.',
      );
    }

    if (neutrino.config.module.rules.has('lint')) {
github neutrinojs / neutrino / packages / eslint / index.js View on Github external
return neutrino => {
    if (neutrino.config.module.rules.has('compile')) {
      throw new ConfigurationError(
        'Lint presets must be defined prior to any other presets in .neutrinorc.js.',
      );
    }

    if (neutrino.config.module.rules.has('lint')) {
      throw new DuplicateRuleError('@neutrinojs/eslint', 'lint');
    }

    const baseConfig = eslint.baseConfig || {};

    const loaderOptions = {
      // For supported options, see:
      // https://github.com/webpack-contrib/eslint-loader#options
      // https://eslint.org/docs/developer-guide/nodejs-api#cliengine
      cache: true,
      cwd: neutrino.options.root,
github neutrinojs / neutrino / packages / library / index.js View on Github external
module.exports = (opts = {}) => {
  if (!opts.name) {
    throw new ConfigurationError(
      'Missing required preset option "name". You must specify a library name when using this preset.',
    );
  }

  if ('polyfills' in opts) {
    throw new ConfigurationError(
      'The polyfills option has been removed, since polyfills are no longer included by default.',
    );
  }

  return neutrino => {
    const options = merge(
      {
        target: 'web',
        libraryTarget: 'umd',
        babel: {},
github neutrinojs / neutrino / packages / node / index.js View on Github external
module.exports = (opts = {}) => {
  if ('polyfills' in opts) {
    throw new ConfigurationError(
      'The polyfills option has been removed, since polyfills are no longer included by default.',
    );
  }

  return neutrino => {
    const pkg = neutrino.options.packageJson;
    const sourceMap =
      (pkg && pkg.dependencies && pkg.dependencies['source-map-support']) ||
      (pkg &&
        pkg.devDependencies &&
        pkg.devDependencies['source-map-support']) ||
      false;
    const options = merge(
      {
        hot: true,
        targets: {
github neutrinojs / neutrino / packages / web / index.js View on Github external
if ('hotEntries' in options) {
    throw new ConfigurationError(
      'The hotEntries option has been removed. See the "neutrino.options.mains" ' +
        'docs for how to add custom hot entries to your bundle without importing.',
    );
  }

  if ('manifest' in options) {
    throw new ConfigurationError(
      'The manifest option has been removed. See the v8 to v9 migration guide ' +
        'for how to generate a manifest manually.',
    );
  }

  if (typeof options.devServer.proxy === 'string') {
    throw new ConfigurationError(
      'The shorthand of setting `devServer.proxy` to a string is no longer supported. ' +
        'Use an object and the options listed here instead: ' +
        'https://webpack.js.org/configuration/dev-server/#devserver-proxy',
    );
  }

  if (
    typeof options.devtool === 'string' ||
    typeof options.devtool === 'boolean'
  ) {
    options.devtool = {
      development: options.devtool,
      production: options.devtool,
      test: options.devtool,
    };
  }
github neutrinojs / neutrino / packages / library / index.js View on Github external
module.exports = (opts = {}) => {
  if (!opts.name) {
    throw new ConfigurationError(
      'Missing required preset option "name". You must specify a library name when using this preset.',
    );
  }

  if ('polyfills' in opts) {
    throw new ConfigurationError(
      'The polyfills option has been removed, since polyfills are no longer included by default.',
    );
  }

  return neutrino => {
    const options = merge(
      {
        target: 'web',
        libraryTarget: 'umd',
        babel: {},
        externals: {},
        targets: {},
      },
      opts,
    );
github neutrinojs / neutrino / packages / web / index.js View on Github external
);

  if ('babel' in options.minify) {
    throw new ConfigurationError(
      'The minify.babel option has been removed. See the web preset docs for how to customise source minification.',
    );
  }

  if ('image' in options.minify) {
    throw new ConfigurationError(
      'The minify.image option has been removed. See: https://github.com/neutrinojs/neutrino/issues/1104',
    );
  }

  if ('style' in options.minify) {
    throw new ConfigurationError(
      'The minify.style option has been removed. To enable style minification use the @neutrinojs/style-minify preset.',
    );
  }

  if ('polyfills' in options) {
    throw new ConfigurationError(
      'The polyfills option has been removed, since polyfills are no longer included by default.',
    );
  }

  if ('hotEntries' in options) {
    throw new ConfigurationError(
      'The hotEntries option has been removed. See the "neutrino.options.mains" ' +
        'docs for how to add custom hot entries to your bundle without importing.',
    );
  }
github neutrinojs / neutrino / packages / web / index.js View on Github external
}

  if ('image' in options.minify) {
    throw new ConfigurationError(
      'The minify.image option has been removed. See: https://github.com/neutrinojs/neutrino/issues/1104',
    );
  }

  if ('style' in options.minify) {
    throw new ConfigurationError(
      'The minify.style option has been removed. To enable style minification use the @neutrinojs/style-minify preset.',
    );
  }

  if ('polyfills' in options) {
    throw new ConfigurationError(
      'The polyfills option has been removed, since polyfills are no longer included by default.',
    );
  }

  if ('hotEntries' in options) {
    throw new ConfigurationError(
      'The hotEntries option has been removed. See the "neutrino.options.mains" ' +
        'docs for how to add custom hot entries to your bundle without importing.',
    );
  }

  if ('manifest' in options) {
    throw new ConfigurationError(
      'The manifest option has been removed. See the v8 to v9 migration guide ' +
        'for how to generate a manifest manually.',
    );
github neutrinojs / neutrino / packages / web / index.js View on Github external
hot: opts.hot !== false,
      },
      style: {},
      minify: {
        source: isProduction,
      },
      babel: {},
      targets: {},
      font: {},
      image: {},
    },
    opts,
  );

  if ('babel' in options.minify) {
    throw new ConfigurationError(
      'The minify.babel option has been removed. See the web preset docs for how to customise source minification.',
    );
  }

  if ('image' in options.minify) {
    throw new ConfigurationError(
      'The minify.image option has been removed. See: https://github.com/neutrinojs/neutrino/issues/1104',
    );
  }

  if ('style' in options.minify) {
    throw new ConfigurationError(
      'The minify.style option has been removed. To enable style minification use the @neutrinojs/style-minify preset.',
    );
  }

neutrino

Create and build JS applications with managed configurations

MPL-2.0
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis