-
Notifications
You must be signed in to change notification settings - Fork 65
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
Building client with rollup and typescript results in incorrect call to qrcode module #170
Comments
I think it might indeed be related. Some older modules seem to export The patch in my rollup.config.js modifies Line 15 in 551ec84
qrcode.default() rather than just qrcode() per what I found at kazuhikoarase/qrcode-generator#62
|
I just released 2.2.2-beta.0 which has some changes in the build script: #171 Can you try it out and see if it works? |
Sadly it did not work. I'll give it another try. |
@fredcy could you resolve it somehow? @AndreasGassmann any updates? |
@souljorje I don't think I ever got it to work with Rollup, other than with the patch that I described. Even today when I build with Vite I see a message about "Cannot call a namespace ('qrcode')" in the build output -- but the app runs OK. |
Looking at my old rollup.config.js, I would do this in the plugins section:
|
@fredcy yep, app runs fine but without opportunity to pair wallet via qr-code. Eventually I did something kinda you suggested, valid for beacon-sdk@3. // vite.config.js
import replace from 'rollup-plugin-re';
export default export default (ctx) => {
const isBuild = ctx.command === 'build';
return {
plugins: [
{
...replace({
include: ['node_modules/@airgap/**'],
replaces: {
/**
* qr doesn't work on dev, but at least the whole wallet works
*/
...isBuild
? {
"import * as qrcode from 'qrcode-generator';": "import qrcode from 'qrcode-generator';",
}
: {
'var libsodium_wrappers_1 = require("libsodium-wrappers")': 'var libsodium_wrappers_1 = require("libsodium-wrappers").default',
},
},
}),
enforce: 'pre',
},
],
}
};
|
@souljorje sadly, this does not work for me using version 3.1.4 of @airgap/beacon-dapp, and the QR code is shown in dev, but not prod - which is the same situation as when not using the workaround. Do you know if there is anything I can do to remedy this? This is my current import { defineConfig } from "vite";
import path from "path";
import vue from "@vitejs/plugin-vue";
import replace from "rollup-plugin-re";
// https://vitejs.dev/config/
export default ({ command }) => {
const isBuild = command === "build";
return defineConfig({
base: "./",
plugins: [
vue(),
{
...replace({
include: ["node_modules/@airgap/**"],
replaces: {
"import * as qrcode from 'qrcode-generator';": "import qrcode from 'qrcode-generator';",
},
}),
apply: "build",
enforce: "pre",
},
],
build: {
target: "esnext",
commonjsOptions: {
transformMixedEsModules: true,
},
},
resolve: {
alias: {
// dedupe @airgap/beacon-dapp
// I almost have no idea why it needs `cjs` on dev and `esm` on build, but this is how it works 🤷♂️
"@airgap/beacon-dapp": path.resolve(path.resolve(), `./node_modules/@airgap/beacon-dapp/dist/${isBuild ? "esm" : "cjs"}/index.js`),
// polyfills
"readable-stream": "vite-compatible-readable-stream",
stream: "vite-compatible-readable-stream",
},
},
});
}; |
@PureSpider currently this works for me: {
...replace({
include: ['node_modules/@airgap/**'],
replaces: {
/**
* damn circus with this beacon-sdk...
* qr doesn't work on dev, but at least the whole wallet works
*/
...isBuild
? {
"import * as qrcode from 'qrcode-generator';": "import qrcode from 'qrcode-generator';",
}
: {
'var libsodium_wrappers_1 = require("libsodium-wrappers")': 'var libsodium_wrappers_1 = require("libsodium-wrappers").default',
},
},
}),
enforce: 'pre',
}, updated original comment |
Yup, also an issue here. Above mentioned workarounds seem to work, in production at least. |
@AndreasGassmann what's the argument against using
Let me make a PR. Builds and tests run. |
@852Kerfunkle I already made it long time ago: #397 |
Ah, I see. Wasn't mentioned here. What is the argument against |
The UI package has changed a lot recently with the release of the new UI. Feel free to re-open this issue if it's still a problem. |
Describe the bug (current behavior)
When I build a BeaconSDK client using the Rollup bundler and Typescript, I get an warning during compilation and a blocking error when I run the client application.
To Reproduce
Steps to reproduce the behavior:
Clone the repo at https://gitlab.com/fredcy/beacon-issue-1.git
Build the application:
Expected (correct) behavior
I expect the app to compile cleanly.
I expect the app to execute the Beacon permissionRequest flow, including the wallet chooser and permission-request in the wallet.
Actual behavior
The output during compilation reports a problem:
And when I run the app in the browser, it hangs at the client.requestPermission() call. No wallet chooser appears, possibly because the QR code can't be created.
Environment
Additional context
The rollup.config.js has a section commented out that if applied patches the Beacon code so that it works.
The text was updated successfully, but these errors were encountered: