question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

More than a single candidate module for core-js/object/assign

See original GitHub issue
webpack-isomorphic-tools/plugin] [error]  More than a single candidate module was found in webpack stats for require()d path "[object Object]"
[webpack-isomorphic-tools/plugin]   {
  "id": 304,
  "identifier": "/__redacted__/node_modules/babel-runtime/core-js/object/assign.js",
  "name": "./~/babel-runtime/core-js/object/assign.js",
  "index": 525,
  "index2": 525,
  "size": 94,
  "cacheable": true,
  "built": true,
  "optional": false,
  "prefetched": false,
  "chunks": [
    0
  ],
  "assets": [],
  "issuer": "/__redacted__/node_modules/babel-runtime/helpers/extends.js",
  "failed": false,
  "errors": 0,
  "warnings": 0,
  "reasons": [
    {
      "moduleId": 3,
      "moduleIdentifier": "/__redacted__/node_modules/babel-runtime/helpers/extends.js",
      "module": "./~/babel-runtime/helpers/extends.js",
      "moduleName": "./~/babel-runtime/helpers/extends.js",
      "type": "cjs require",
      "userRequest": "babel-runtime/core-js/object/assign",
      "loc": "3:21-67"
    },
    {
      "moduleId": 29,
      "moduleIdentifier": "/__redacted__/node_modules/react-bootstrap/lib/styleMaps.js",
      "module": "./~/react-bootstrap/lib/styleMaps.js",
      "moduleName": "./~/react-bootstrap/lib/styleMaps.js",
      "type": "cjs require",
      "userRequest": "babel-runtime/core-js/object/assign",
      "loc": "3:21-67"
    }
  ],
  "source": "module.exports = { \"default\": require(\"core-js/library/fn/object/assign\"), __esModule: true };"
}
[webpack-isomorphic-tools/plugin]   {
  "id": 838,
  "identifier": "/__redacted__/node_modules/isomorphic-style-loader/node_modules/babel-runtime/core-js/object/assign.js",
  "name": "./~/isomorphic-style-loader/~/babel-runtime/core-js/object/assign.js",
  "index": 734,
  "index2": 727,
  "size": 94,
  "cacheable": true,
  "built": true,
  "optional": false,
  "prefetched": false,
  "chunks": [
    0
  ],
  "assets": [],
  "issuer": "/__redacted__/node_modules/isomorphic-style-loader/lib/insertCss.js",
  "failed": false,
  "errors": 0,
  "warnings": 0,
  "reasons": [
    {
      "moduleId": 10,
      "moduleIdentifier": "/__redacted__/node_modules/isomorphic-style-loader/lib/insertCss.js",
      "module": "./~/isomorphic-style-loader/lib/insertCss.js",
      "moduleName": "./~/isomorphic-style-loader/lib/insertCss.js",
      "type": "cjs require",
      "userRequest": "babel-runtime/core-js/object/assign",
      "loc": "3:14-60"
    }
  ],
  "source": "module.exports = { \"default\": require(\"core-js/library/fn/object/assign\"), __esModule: true };"
}
/__redacted__/node_modules/webpack-isomorphic-tools/babel-transpiled-modules/plugin/write assets.js:369
            throw new Error('More than a single candidate module was found in webpack stats');
            ^

Error: More than a single candidate module was found in webpack stats
    at /__redacted__/node_modules/webpack-isomorphic-tools/babel-transpiled-modules/plugin/write assets.js:369:10
    at resolver (/__redacted__/node_modules/webpack-isomorphic-tools/node_modules/require-hacker/babel-transpiled-modules/require hacker.js:131:17)
    at Function._module3.default._findPath (/__redacted__/node_modules/webpack-isomorphic-tools/node_modules/require-hacker/babel-transpiled-modules/require hacker.js:436:24)
    at Function.Module._resolveFilename (module.js:335:25)
    at Function._module3.default._resolveFilename (/__redacted__/node_modules/webpack-isomorphic-tools/node_modules/require-hacker/babel-transpiled-modules/require hacker.js:403:34)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (!./../../node_modules/isomorphic-style-loader/lib/insertCss.js.webpack-module:4:15)
    at Module._compile (module.js:435:26)
    at Object._module3.default._extensions.(anonymous function) [as .webpack-module] (/__redacted__/node_modules/webpack-isomorphic-tools/node_modules/require-hacker/babel-transpiled-modules/require hacker.js:264:11)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/__redacted__/src/sass/LoginSignupForm.scss.webpack-module:4:21)
    at Module._compile (module.js:435:26)
    at Object._module3.default._extensions.(anonymous function) [as .webpack-module] (/__redacted__/node_modules/webpack-isomorphic-tools/node_modules/require-hacker/babel-transpiled-modules/require hacker.js:264:11)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at populate_assets (/__redacted__/node_modules/webpack-isomorphic-tools/babel-transpiled-modules/plugin/write assets.js:395:31)
    at Object.write_assets [as default] (/__redacted__/node_modules/webpack-isomorphic-tools/babel-transpiled-modules/plugin/write assets.js:63:2)
    at Compiler.<anonymous> (/__redacted__/node_modules/webpack-isomorphic-tools/babel-transpiled-modules/plugin/plugin.js:175:27)
    at Compiler.applyPlugins (/__redacted__/node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
    at Compiler.<anonymous> (/__redacted__/node_modules/webpack/lib/Compiler.js:193:12)
    at Compiler.emitRecords (/__redacted__/node_modules/webpack/lib/Compiler.js:282:37)
    at Compiler.<anonymous> (/__redacted__/node_modules/webpack/lib/Compiler.js:187:11)
    at /__redacted__/node_modules/webpack/lib/Compiler.js:275:11

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:39 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
sompylasarcommented, Mar 28, 2016

I tried to use target: 'node' and failed miserably, so I had to revert to webpack-isomorphic-tools.

Below are my results after having resolved the issue and successfully integrated with https://github.com/kriasoft/isomorphic-style-loader

@halt-hammerzeit you might be interested in adding a manual for isomorphic-style-loader next to the one for style-loader.

// ---------
// The `withStyles` decorator is the main benefit of `isomorphic-style-loader`
// compared to `style-loader` -- it enables critical-path style extraction and
// partial loading of styles.
// We use `webpack-isomorphic-tools` that does not build using `webpack` on the
// server-side, so we can't use the `isomorphic-style-loader` on the server-side
// as it is designed.
// We could just use the `withStyles` architecture plus `style-loader` for style insertion,
// but `style-loader` does not expose a `removeCss` function that would rollback the `insertCss`,
// and that function is required to make `withStyles` complete -- thus, we don't.
// -- sompylasar
//
// webpack-isomorphic-tools config, the part responsible for styles (server-side)

    style_modules: {
      // ---------
      // The CSS Modules on the server-side should export objects with classnames and the CSS text.
      // The `extensions` defines the regular expression to match the module names (it is constructed under the hood).
      // The `filter` function finds the modules that are CSS Modules.
      // The `path` function converts module full names into asset paths.
      // The `parser` function transforms the module source code to export
      // objects that are expected from `require('*.scss')` on the server-side.
      // -- sompylasar
      //
      extensions: [
        'less',
        'scss',
      ],

      filter: function (module, regex, options, log) {
        // ---------
        // The `isomorphic-style-loader`, like `style-loader`, is a pitching loader, and during the `pitch`
        // it changes the module so that the remaining part of the module request starts with `css-loader` (the next one to the right).
        // @see https://github.com/kriasoft/isomorphic-style-loader/blob/5e4b0627fcde383a20b53f66d8f3c47d05062722/src/index.js#L14
        // @see https://github.com/kriasoft/isomorphic-style-loader/blob/5e4b0627fcde383a20b53f66d8f3c47d05062722/src/index.js#L21
        // @see https://webpack.github.io/docs/loaders.html#pitching-loader
        // @see https://github.com/webpack/webpack/issues/360#issuecomment-49028914
        // -- sompylasar
        //
        var ret = WebpackIsomorphicToolsPlugin.style_loader_filter(module, regex, options, log);
        if (ret) {
          log.debug('style_modules.filter ' + module.name + ' -> ' + ret);
        }
        return ret;
      },
      path: function (module, options, log) {
        // ---------
        // `isomorphic-style-loader` is similar to `style-loader`,
        // see detailed comment in `filter` above.
        // Here we strip the loaders to return the asset path.
        // The asset path value will become the key in the `webpack-assets.json`.
        // -- sompylasar
        //
        var ret = WebpackIsomorphicToolsPlugin.style_loader_path_extractor(module, options, log);
        log.debug('style_modules.name ' + module.name + ' -> ' + ret);
        return ret;
      },
      parser: function (module, options, log) {
        // ---------
        // `webpack-isomorphic-tools` does not use `webpack` loaders,
        // it uses its own way to convert assets to JS, called parsers.
        // The parser results are collected and cached in the `webpack-assets.json` file.
        // Usually, we would imitate behavior of loaders for known asset types
        // to provide proper `exports` objects on the server-side.
        // But `isomorphic-style-loader`'s `exports` object exports
        // functions `_getCss` and `_insertCss` which for some reason cannot be
        // serialized into `webpack-assets.json` although in `require-hacker`
        // which is responsible for serialization the CommonJS modules are handled specifically.
        // @see https://github.com/halt-hammerzeit/require-hacker/blob/ccd584d68fb8fee8a117b7ddfe0b2bcaeed309e8/source/require%20hacker.js#L280-L297
        // @see https://github.com/halt-hammerzeit/require-hacker/blob/ccd584d68fb8fee8a117b7ddfe0b2bcaeed309e8/source/require%20hacker.js#L451-L456
        // So we reuse the CSS Modules converter from `webpack-isomorphic-tools`
        // that builds a module that exports the CSS Modules classnames
        // and an additional `_style` string property with raw CSS text.
        // This structure gets serialized properly.
        // @see https://github.com/halt-hammerzeit/webpack-isomorphic-tools/blob/5e468729fe0a59eaed4f8a0f9da5ba92a4a7e3c5/source/plugin/plugin.js#L194-L199
        // -- sompylasar
        //
        var ret = WebpackIsomorphicToolsPlugin.css_modules_loader_parser(module, options, log);
        log.debug('style_modules.parser \n' + module.source + '\n\n -----------> \n\n' + ret + '\n');
        return ret;
      }
    }
// webpack config, the part responsible for style loaders (browser-side)

  const cssLoaderQuery = {
    modules: true,
    importLoaders: 2,  // `postcss-loader` + ( `sass-loader` or `less-loader` ).
    sourceMap: SOURCE_MAP_ENABLED,
    localIdentName: (__DEVELOPMENT__ ? '[local]___[hash:base64:5]' : undefined),
  };
  const lessSassLoaderQuery = {
    outputStyle: 'expanded',
    sourceMap: SOURCE_MAP_ENABLED,
  };
  const styleLoaders = [
    'isomorphic-style-loader',
    'css-loader?' + JSON.stringify(cssLoaderQuery),
    'postcss-loader',
  ];
  const styleLoadersWithTest = [
    {
      test: /\.less$/,
      loaders: [
        ...styleLoaders,
        'less-loader?' + JSON.stringify(lessSassLoaderQuery),
      ],
    },
    {
      test: /\.scss$/,
      loaders: [
        ...styleLoaders,
        'sass-loader?' + JSON.stringify(lessSassLoaderQuery),
      ],
    },
  ];
// collect styles on the rendering critical path (server-side)

        // CSS for all rendered React components.
        const cssTexts = [];
        function insertCss(styles) {
          // ---------
          // Although `styles` is expected to have `_getCss()` function on the server-side,
          // it won't, because on the server-side we use `webpack-isomorphic-tools`
          // to convert the modules to JS, not `webpack` loaders.
          // It has `_style` string which is generated by the
          // `WebpackIsomorphicToolsPlugin.css_modules_loader_parser`.
          // See `webpackIsomorphicToolsConfig` for more details.
          // -- sompylasar
          //
          cssTexts.push( styles._style );
        }
// collect styles on the rendering critical path (browser-side)

function insertCss(styles) {
  // ---------
  // On the browser-side we use `webpack` loaders to convert the modules to JS,
  // so here we have `_insertCss()` function generated by `isomorphic-style-loader`.
  // -- sompylasar
  //
  styles._insertCss();
}
/**
 * Provides `insertCss` function via React context to the `withStyles`-decorated components.
 *
 * Usage: <InsertCssProvider insertCss={insertCss}>{contentDOM}</InsertCssProvider>
 */
export default class InsertCssProvider extends Component {
  static propTypes = {
    insertCss: PropTypes.func.isRequired,
    children: PropTypes.node,
  }

  static childContextTypes = {
    insertCss: PropTypes.func,
  }

  getChildContext() {
    return {
      insertCss: (styles) => {
        const { insertCss } = this.props;
        // We may get an array of styles here if `withStyles` is used more than once.
        // TODO(sompylasar): Get to know when exactly this array happens.
        if (Array.isArray(styles)) {
          styles.forEach(insertCss);
        }
        else {
          insertCss(styles);
        }
      },
    };
  }

  render() {
    const { children } = this.props;
    return React.Children.only(children);
  }
}

1reaction
sergeylukincommented, Mar 31, 2016

Hi,

I think I was getting that error (More than a single candidate module was found) too because I had 2 components with same structure:

componentA/
componentA/index.js
componentA/styles.css

and

componentB/
componentB/index.js
componentB/styles.css

where both components required styles.css relatively (i.e. import styles from './style.css').

I think I fixed that by renaming each styles.css to their corresponding component name respectively. My setup was pretty full of stuff so I will test that again with minimal setup and will let you know once I have more info.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test Procedure Manual for Voting Systems - State of Michigan
The conduct of Pre-election Logic and Accuracy Testing of all tabulators and voter assist terminals. (VAT) prior to each election is the responsibility...
Read more >
52 USC 30101: Definitions - U.S. Code
(5) The term "principal campaign committee" means a political committee designated and authorized by a candidate under section 30102(e)(1) of this title. (6) ......
Read more >
ELECTION CODE CHAPTER 61. CONDUCT OF VOTING ...
OPENING AND CLOSING POLLING PLACE FOR VOTING. (a) Immediately before opening the polls for voting on the first day of early voting and...
Read more >
Ranked Choice Voting Information - FairVote
This includes 2 states, 2 counties, and 59 cities. Military and overseas voters cast RCV ballots in federal runoff elections in 6 states....
Read more >
NIST SP 1500-10x NIST Election Glossary Draft Version 1.0
A ballot that contains contest selections that require adjudication. adminstrator. A voting system user with the highest level of access. Synonyms: admin , ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found