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.

Cannot import sinon-chrome with webpack

See original GitHub issue

When I try to require the new version 1.0.0 with webpack I get the following error.

TypeError: 'undefined' is not an object (evaluating 'modules[moduleId].call')

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
acvetkovcommented, Nov 14, 2015

Hi, @sk- .

It’s legendary problem =). Check out this issue in webpack repo https://github.com/webpack/webpack/issues/304

This problem is related with incorrect sinon exports module interface, you should load sinon “manually” to solve it.

0reactions
michalczaplinskicommented, Dec 20, 2016

@acvetkov Your config almost worked for me - I had to make 2 modifications:

  1. Use the unbundled version of sinon that is inside node_modules/sinon/libinstead ofnode_modules/sinon/pkg`
  2. Add the $ to the noParse rule. Otherwise it would also eagerly cover the sinon-chrome package itself!
var path = require('path');

// ...

resolve: {
   alias: {
      sinon: path.resolve(__dirname, 'node_modules/sinon/lib/sinon.js') // require dist version instead
   }
},
module: {
   noParse: [
      /node_modules\/sinon$/ // ignore sinon module
   ]   
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack: cannot reach my imported module - Stack Overflow
I import a .js module in my entry file. It is included in the bundle.js. It is still undefined and cannot figure out...
Read more >
TypeScript - webpack
To make imports do this by default and keep import _ from 'lodash'; syntax in TypeScript, set "allowSyntheticDefaultImports" : true and "esModuleInterop" ...
Read more >
Module Methods - webpack
A normal import statement cannot be used dynamically within other logic or contain variables. See the spec for more information and import() below...
Read more >
less-loader | webpack - JS.ORG
less-loader applies a Less plugin that passes all queries to the webpack resolver if less could not resolve @import . Thus you can...
Read more >
Resolve | webpack
For example, when calling import 'lodash' in ES2015, the resolve options can change where webpack goes to look for 'lodash' (see modules )....
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