Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

How to export bundle.js from a projectA [webpack5] to a projectB [webpack4] #17894

Closed
necik11 opened this issue Apr 5, 2024 · 0 comments
Closed

Comments

@necik11
Copy link

necik11 commented Apr 5, 2024

How to export bundle.js from a projectA [webpack5] to a projectB [webpack4]

Configuration:

  • Web browser and its version: Chrome
  • Operating system and its version: Windows 11
  • PDF.js version: 4.0.379 {latest)
  • Is a browser extension: No

I created a code in which I tried this functionality:
https://github.com/necik11/pdfJsPlayGround

Steps to reproduce the problem:

  1. Create projectA-simple JS project(sample-pdf-js)
  • download pdf.mjs
  • create silly main.js which render page
  • install latest webpack (5.91.0)
  • npm run build and make bundle.js in my case prod.js and dev.js
  1. Create projectB - older JS/Vue/React project which using webpack v4.x.x(simple_webpack_boilerplate-master)
  1. Create project C - project which using webpack 5
  • import bundle and everything is working

What is the expected behavior?

I want this bundle work even in older projects.
I tried unsuccessfully even legacy mode and downgrade somehow my version...

For sample i want use in SPFX and vue projects which using webpack4.
what help me when i directly import pdf.js into those projects was:
#13200 (comment)

but when i use webpack for bundle and then load production mode i have this pdf:
https://pdftron.s3.amazonaws.com/downloads/pl/Chart_.Vector.pdf
without colors:

image
vs
dev mode:
image

I will be glad for all the advice and tips, thank you

@necik11 necik11 changed the title The issue is, that in some version after 2.5 some lines with the optional chaining operator were added. This operator is not supported by webpack by default in its current version (as far as I know). Vue uses webpack (@sairamsunkara673M is using Vue and therefore webpack). So you may need an addiotional loader for the pdfjs-dist files. You could configure your webpack as follows: How to export bundle.js from a projectA [webpack5] to a projectB [webpack4] Apr 5, 2024
@mozilla mozilla locked and limited conversation to collaborators Apr 6, 2024
@Snuffleupagus Snuffleupagus converted this issue into discussion #17896 Apr 6, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant