neocotic / qrious

Pure JavaScript library for QR code generation using canvas

Home Page:https://neocotic.com/qrious

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webpack - need to manually install qrious-core

gabrielstuff opened this issue · comments

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.

@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.

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.

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.

@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.