Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking whether require is defined, interpretted as require('.') #5889

Closed
jshbrntt opened this issue Oct 27, 2017 · 0 comments
Closed

Checking whether require is defined, interpretted as require('.') #5889

jshbrntt opened this issue Oct 27, 2017 · 0 comments
Assignees

Comments

@jshbrntt
Copy link

jshbrntt commented Oct 27, 2017

What is the current behavior?

Webpack compiles the following

var _nodeRequire = (AMDLoader.global.require || require);

Into the following:

var _nodeRequire = (AMDLoader.global.require || !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()));

Presumably resolving require to require('.') incorrectly.

If the current behavior is a bug, please provide the steps to reproduce.

Attempt to import the following module.

// module.js
if (require && true) {
  console.log('test')
}

module.exports = true

You should end up with this error.

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

What is the expected behavior?

I would expect webpack to ignore everything except a call of require.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

  • Node.js 8.1.0
  • Webpack 2.6.1
@jshbrntt jshbrntt changed the title Check whether require is defined, interpretted as require('.') Checking whether require is defined, interpretted as require('.') Oct 27, 2017
ooflorent added a commit that referenced this issue Jun 5, 2018
@ooflorent ooflorent self-assigned this Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants