neocotic / qrious

Pure JavaScript library for QR code generation using canvas
https://neocotic.com/qrious
Other
1.55k stars 215 forks source link

webpack - need to manually install qrious-core #90

Closed gabrielstuff closed 7 years ago

gabrielstuff commented 7 years ago

While using the lib with webpack@2, I encounter:

ERROR in ./~/qrious/dist/qrious.js
  Module not found: Error: Can't resolve 'qrious-core'

After doing: yarn add qrious-core, all the problem were gone.

neocotic commented 7 years ago

@gabrielstuff I'm sorry to hear you've had issues. I'm a bit confused about what webpack is doing. I've explicitly marked qrious-core as a devDependency as it's bundled with qrious.

I'm lost as to why webpack is trying to require anything. Perhaps the "main" entry in package.json should be the source file that uses CommonJS and then move qrious-core to "dependencies" with a new "browser" entry pointing at dist/qrious.js. However, I'm still worried about what webpack might do in that situation, I don't want it to attempt to bundle qrious-core twice, as that would double the bundle size from QRious perspective.

gabrielstuff commented 7 years ago

Hello,

I'll try to figure it out later. What I think, is that the bundling of the qrious.min.js is not correct and webpack thinks that he can require "core". If you look at the min.js file, it is explicitly written. From what I understand, qrious-core is not a dev-dependencies but a depencies, isn't ?

neocotic commented 7 years ago

I can't look at the code until later, but I'll look into what's causing this. Core is definetly bundled within the distribution files, I can see the code the, so I'm not sure why there's a require in the UMD format output. That's why I've had it under devDependencies instead of dependencies. I'm worried that webpack will be bundling core again with your workaround, which is not ideal. Sounds like an issue with the build, as the distribution files are generated via rollup, so I'll take a look at what I can do to avoid it. I want it as it is now but with no require for core. I tested it locally (not webpack, but I'm general) and it worked, but I would have had core installed locally anyway, hiding this issue.

neocotic commented 7 years ago

This was down to a "Doh!" situation. I included the following in the rollup options:

external: [ 'qrious-core' ],

This was a simple mistake as I left it in while experimenting during the refactor and I can fix this issue by removing these options and get a patch release out tonight or tomorrow (hopefully the former).

However, I thought I understood what external did in rollup, but I guess I was wrong since the dependency is being required (expected) but the code for that dependency is still being bundled (unexpected).

No matter. I'll remove this so that the dependency is hidden entirely since the code is bundled, which should simplify everything.

neocotic commented 7 years ago

@gabrielstuff This should be fixed now. Can you please pull down the latest version (4.0.2) and test it out? Also, please uninstall qrious-core first to make sure that your previous workaround still has any influence.

gabrielstuff commented 7 years ago

Hello ! Thanks, I'll test that later this week.

On Mon, Jun 5, 2017 at 12:00 AM, Alasdair Mercer notifications@github.com wrote:

@gabrielstuff https://github.com/gabrielstuff This should be fixed now. Can you please pull down the latest version (4.0.2) and test it out? Also, please uninstall qrious-core first to make sure that your previous workaround still has any influence.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/neocotic/qrious/issues/90#issuecomment-306070109, or mute the thread https://github.com/notifications/unsubscribe-auth/AARZaZvBkYlZGFenz4NJm666HjM8eStPks5sAyjjgaJpZM4NvNQz .

--

--

Gabriel Delattre Fondateur associé

Soixante circuits Provocative experiences

31 rue Louis Blanc 75010 Paris

Mob. : + 33 6 16 38 10 80 <//+33616381080> Facebook : http://facebook.com/soixantecircuits Skype : applemind