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

fixed require issue #769

Closed
wants to merge 3 commits into from
Closed

fixed require issue #769

wants to merge 3 commits into from

Conversation

daemonchen
Copy link

fixed require issue

@daemonchen
Copy link
Author

fixed some dependencies bug

@fb55
Copy link
Member

fb55 commented Oct 19, 2015

Which platform requires this?

@jugglinmike
Copy link
Member

We'll need more information before we can consider this for inclusion in master. Since we haven't heard back in over a month, I'm going to close this. We can re-open if the information comes to light!

@ItsCosmo
Copy link

ItsCosmo commented Apr 2, 2016

I am not the author of this PR, but please consider re-examining the "fixed require issue". I can explain why this fix is helpful. In my webpack configuration, I am using the "resolve" configuration as follows:

resolve {
  root: "./src"
  extension: ['', 'js', 'jsx', 'scss']
}

This is quite useful because is makes imports/requires simpler in the source code.

With the original line in cheerio/index.js:

exports.version = require('./package').version

The package.json file is not found, giving the error:

Error: Cannot find module './package' from 'index.js'

I believe that's because the empty extension is causing webpack to look in the "./src" folder for this file. Changing the line to:

exports.version = require('./package.json').version

The file is no longer matched to the resolve.extension, and so it loads properly. I have not been able to find a workaround for this issue. In the interest of making the integration of cheerio as seamless and trouble free as possible in a variety of environments and configurations, this change is warranted. After all, require("./package") is just a shorthand for require("./package.json")

@luanmuniz
Copy link
Contributor

I think the extension addition can go in. It look like this is causing problems and its a really simple change. I cant see any down-side.

The only problem with this PR is the changes in the package.json file. The owner of the PR add a few dependences for no reason.

fb55 added a commit that referenced this pull request Apr 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants