-
Notifications
You must be signed in to change notification settings - Fork 202
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
Fix webpack usage #59
Comments
Hey @trodrigues I'm having this problem now. How did you end up resolving this issue? |
Hi there, yes, I did fix this at the time, can't remember on which specific version for sure. Which version are you using at the moment? |
Running the latest contentful (3.3.6) in a webpack + babel project. It appears that even though the lib require is in a error handler that is never called, webpack still tries to resolve the require. I forked and removed these lines and all is well. https://github.com/contentful/contentful.js/blob/master/index.js#L7-L9 |
Ah yes, that part of the code is there for development mode. The thing is, webpack should honor the "browser" key on package.json and use the browser.js file instead of index.js. Could this be an issue with your webpack configuration? If you'd like to check an example of an app we have that is currently using this, you can have a look at https://github.com/contentful/discovery-app-react/blob/master/webpack.config.js |
Support building for a server-side target #59
I think this is still a problem (only for serverside nodejs). I'm just starting to use the contentful library and it's taking too long to make it work with webpack and node. The initial problem was the one outlined in this ticket:
The quick fix for this is the solution that @zamiang outlined in https://github.com/contentful/contentful.js/blob/master/index.js#L7-L9 You can fix it with webpack, but the solution doesn't reflect the changes from Webpack 1 to version 2. Specially, to tell webpage to use
so the This is a bit funny anyway as you are telling node to use
https://github.com/contentful/contentful.js/blob/master/package.json#L43 When you get this working, you then need to get webpack to rewrite the reference to the browser version of axios (something like - this isn't working for me yet):
All of this is a little longwinded. Given that I just want to use the contentful service, it feels like this should be a bit easier, and the easy thing to do is to fix |
Hi @Koded, |
Thanks for the quick response @Khaledgarbaya - good to hear you're going to look into the problem. |
@Koded Just make sure to switch to the branches for contentful.js and content-sdk-core |
I've just checked out that PR branch and built and run it on my app and it all works as expected! |
@Koded Thanks a lot, I will do more testing and release it, maybe under beta for a while as it will be a major release |
@Koded I hope also you bundle size is a bit smaller now right ? |
What exactly is necessary to be able to work with these PRs? I tried Help with this is highly appreciated! |
@irisSchaffer, make sure to change the branch to the PR branch also clone the contentful-sdk-core repo and switch to the branch that is used in this PR on contentful.js directory run |
The npm package only bundles the built files under dist, but webpack doesn't like the fact that there is a require for a
lib
dir that doesn't exist.This can be fixed by including
lib
but there should be a better way to make webpack not worry about this.The text was updated successfully, but these errors were encountered: