-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
Angular 6 support #322
Comments
You have to work harder man, we just released Angular 5 version days ago, now it comes Angular 6. 😜 |
I'm just some guy off the internet, but. The first one The second one That said, |
I can confirm what @rsheptolut said. The warning is annoying but has nothing to do with this library, and it seems to work just as well with Angular 6. |
did you guys manage any solution for this warning ? |
@shariqshahzad Mostly anger management for now. Trying to cope with it. The way to remove the warning is to first find out which part of the whoole Angular 6 update introduced it, and file an issue in the Angular repo, or maybe in a webpack repo, or maybe these guys will tell you that pdf.js guys must now somehow code this differently... I don't have enough know-how to get to the bottom of this to at least file the issue to the right place. |
Greetings!! ok to start this is something to do with Webpack as I believe, since Webpack 4 is written from the ground up, now it parse the whole file before it extracts required code. Since PDFjs code needed zlib only if we run it on server side. But the problem is PDFjs includes the browser needed logic and server needed logic in the same js file. I would say to start we can file a request to modulerized the PDFjs logic to seperate files so that any library that uses it can import correct required file. pdfjs.browser.js
pdfjs.browser.min.js
pdfjs.server.js
pdfjs.server.min.js |
i have managed to get rid of this warning but the solution is not a proper one if someone needs to know i can share |
@shariqshahzad please do :) this warning is annoying! |
I'm sorry that is not working :'( |
EDIT: If you don't need Hi everyone,
As @rsheptolut mentioned, most of you do not need {
"name": "zlib",
"version": "1.0.0"
} You must also include an empty file structure:
If you actually require Then we have to alias {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"zlib": ["../node_modules/browserify-zlib/lib/index.js"]
}
}
} For IDEs to recognize this alias, under {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"zlib": ["./node_modules/browserify-zlib/lib/index.js"]
}
}
} and make sure that you extend this file from {
"extends": "../tsconfig.json"
} file structure:
Once we can modify the webpack config again we can add the alias there instead for a cleaner solution: {
"resolve": {
"alias": {
"zlib": "browserify-zlib"
}
}
} Thanks to @fengerzh and @Shay12tg for pointing out corrections in this solution. |
@ColinT I tried add
|
Thanks @ColinT |
@fengerzh sorry I missed a step. You are right, it will not work with just
I will update my previous post accordingly. Thanks! @Shay12tg Awesome. I did not realize it was under I will update my previous post accordingly. Thanks for the heads up! |
@ColinT Thank you, after adding an empty |
Waiting for the proper issue. Creating blind node module is nothing else but a hack. This is something it has to be updated in the module itself. Its a stricter warning and can be fixed. 👍 |
Seems like everyone is saying the warning won't stop the component from working, but I'm having issues as I test this for a new application.
I've tried with the example PDF and one put in my Angular app's Am I missing something? EDIT: Looks like it was the config issue, actually. I was able to get things to render now. Thanks! |
I used this in the package.json "browser": {
"fs": false,
"path": false,
"os": false,
"stream": false,
"zlib": false
} To ignore the libs |
@enyachoke Thank you, its works now |
@enyachoke Which package.json is that? I tried adding it to my package.json but still get the zlib warning! Does it need to be in node_modules/ng2-pdf-viewer/package.json or in node_modules/pdfjsdist/package.json? In those cases it is no go for me, as I cannot touch any files in node_modules, that folder is not checked in to version handling, I would in that case have to automatically write to the files in a post-install script and that gets hairy really fast! |
Had exactly the same issue. If this should update the package.json from the module itself its not a proper update. |
@Ristaaf am using angular cli so I add that to my angular cli project package.json. |
@enyachoke Ok, I also use angular cli, but I still get the zlib warning when even when adding the browser field to my package.json, I read up on it a bit and it should definitely work as you describe, so I will have to check what the problem for me is... |
@enyachoke can you paste your entire package.json here so we can try with the same dependency versions etc? |
@enyachoke |
@VadimDez |
As this project is an open source project, that means everyone can fork a copy of the code and fix the issue before raising a PR. |
@chiragsenjaliya I added the browser entry to the package.json, made sure no instances of Node.exe were running, deleted package-lock.json, uninstalled and reinstalled ng2-pdf-viewer, and I still get the warning. More details would be beneficial. |
@chiragsenjaliya I did this: Using gitbash on Windows 10
And I get the zlib warning |
@Ristaaf @sharppc add this in your root folder package.json: |
If it helps: you can easily propagate @ColinT solution to other devs in your team using a postinstall script: in your package.json
Then write a postinstall.js file in your project root
"Works" like a charm. No more zlib. |
@enyachoke thank you, your proposed solution worked like a charm for me. |
I am really glad it helps! Cheers!
…On Thu, Jul 19, 2018, 7:44 PM Mauricio Quiroga ***@***.***> wrote:
@enyachoke <https://github.com/enyachoke> thank you, your proposed
solution worked like a charm for me.
I only added :
"browser": { "zlib": false } to my Angular project's package.json,
stopped the running application and started it again with ng serve. I
also tried building it with ng build and i didn't get that warning
anymore.
I'm using npm v 6.2.0 and Node v8.11.3 if that helps.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#322 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AS8BQ2fc1unkttzgNXA5nyvzcUlTgnoWks5uIJQ4gaJpZM4TyTzE>
.
|
Added NB: I'm using |
Some IDEs like Visual Studio deletes a fake package (like the proposed zlib hack here) and throws the same error again. It is better to do it in other ways mentioned here. |
@Ristaaf @sharppc I had the same problem, then removed Edit: this is in addition to the |
The Any advise? |
Will be fixed on Mozilla's side of things in pdf.js version 2: |
@andrewjsaid Interesting, however we have edited baseUrl ourselves and are dependent on our new value in parts of our build system, so that is unfortunately not an option, but thanks for clearing out why the package.json browser thing did not work in my case. For now I am going with the fake zlib package created with a post-install script. |
This is irritating :( the browser in package.json suggestion also didnt work for me (using 7 beta5 currently) |
Thanks man! It worked for me. |
@joaoyuki WARNING in ./node_modules/pdfjs-dist/build/pdf.js Can I ignore this message? |
Again in "ng2-pdf-viewer": "5.2.0" not yet solved. When will it be fixed? |
Fix is up for
I issued a PR for this: #409 |
Same error in Angular 7.0.3 |
(I don't know why they just don't fix this) |
Released in |
Bug Report or Feature Request (mark with an
x
)When updating to angular 6 (and angular-cli 6.0) i get the following errors when starting up the application with
ng serve
:WARNING in ./node_modules/pdfjs-dist/build/pdf.js
Module not found: Error: Can't resolve 'zlib' in '/Users/timmeissner/coyo/coyo-frontend/ngx/node_modules/pdfjs-dist/build'
ERROR in ../node_modules/reserved-words/lib/reserved-words.js
Module not found: Error: Can't resolve 'assert' in '/Users/timmeissner/coyo/coyo-frontend/node_modules/reserved-words/lib'
ℹ 「wdm」: Failed to compile.
The text was updated successfully, but these errors were encountered: