-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
wikijs cannot be bundled in #16
Comments
I will look into this. Thanks. |
I am not seeing any conditional requires in my code at all... @Pomax If you can dig in and find the exact line of code it cannot compile, that would be great. In the meantime, I will work on updating the babel version in hopes that a new version will compile it without bundling issues. |
I updated the compiler, please try to use the master branch for your project |
let me give that a try |
Hm, this is very odd. If I add a package entry for master, using:
then a
despite the fact that there is a |
ah hang on, I know why - master does not have a
|
Ah right, you might have to run 'npm run build' manually in that directory
|
yeah, did that, which generated the |
Okay. Many of those errors are webpack errors related to not having loaders for those file types. |
Hmm, that may be, but without the |
These are the dependencies: "babel-polyfill": "^6.9.0",
"isomorphic-fetch": "^2.2.1",
"underscore": "^1.8.3" Those should all be browser compatible... |
yeah those shouldn't really be a problem... alright, I created an mcve for webpack (without babel, eslint, etc) that shows this off as minimal as I can figure. package.json:
With a simple
And a pretty simple webpack config:
creating these three files, running |
Okay thanks for the test, I will do the same
|
I should have seen this before, the issue is not with wikijs. The issue is that you are trying to import a module that cannot run on in the browser. You will have the same issue with many other server-side only modules. I may be able to make a client-side version of this library. Would that suffice? |
that would be perfect - curious though, what does wikijs rely on that that prevents browser bundling? (Most of the things it'd need to do like net-fetching, parsing, etc. have universal packages available) |
Good question! That is actually exactly why I just started using I thought that library would be fine in both browser and node, but apparently, it is not... I guess when webpack tried to compile it, it sees So, maybe we should take it up with them?? Because I would love to get this working without having to create another module... |
hm, if it's https://www.npmjs.com/package/isomorphic-fetch then it looks like it's optimized for browserify. Webpack failing on system-specific APIs makes sense, but maybe if the contract for If that works, then I guess a simple addition to the README explaining what to do when using webpack would be the entire solution. I'll see if the three example files work with that in place. |
Looks like even with isomorphic-fetch externalised (which itself works without a problem), something's still trying to resulting bundle:
Looking at where that |
Hmm.. do you think using either https://github.com/github/fetch or https://github.com/bitinn/node-fetch instead of https://github.com/matthew-andrews/isomorphic-fetch would fix the issue? |
no, those won't solve the |
OHH!!! I forgot about the parser.... Dang... |
I can get rid of that... My bad. I only need a small part of that library. |
Okay. Can you try test branch for me? #22 |
yup, let me test that right now |
No bundling errors on the test files! Checking whether the codebase I was trying to use it in now also works... |
Hm, although I do see this now:
leads to the following error in the browser:
(the "utils.js" seems a red herring, that's just the file that performs the console log) |
ah, looks like the build system generates |
Excellent, so what changes do I need to make, if any?
|
probably just a small section in the README.md that explains that if you're using webpack, and you're experiencing problems, you probably want to use:
Although with the parser fix that might not even be necessary anymore (not tested that and currently not in a position to quickly test) |
Thanks!
|
and you, too! |
trying to add this to some code that gets bundled complains that "3:15-22 require function is used in a way in which dependencies cannot be statically extracted" meaning your code's probably doing something like this:
instead of this:
While it might look less clean, this actually makes the code far easier to both bundle and debug, as all requirements are static, and thus traceable.
The text was updated successfully, but these errors were encountered: