Skip to content
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

Can't run latest build in production #72

Open
slauzinho opened this issue Nov 17, 2022 · 4 comments
Open

Can't run latest build in production #72

slauzinho opened this issue Nov 17, 2022 · 4 comments
Assignees
Labels
Bug Something isn't working

Comments

@slauzinho
Copy link

I'm trying to build the Svelt example in production but I get the following error:

Error: 'isNode' is not exported by node_modules/@walletconnect/environment/dist/cjs/index.js, imported by node_modules/@walletconnect/jsonrpc-utils/dist/esm/env.js

This is my rollup.config.js:

// this file will not afect the sandbox but will
// afect the deployment and dowload

import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import json from '@rollup/plugin-json';

const production = !process.env.ROLLUP_WATCH;

export default {
  input: 'index.js',
  output: {
    sourcemap: true,
    format: 'iife',
    name: 'app',
    file: 'public/bundle.js',
  },
  plugins: [
    svelte({
      // enable run-time checks when not in production
      dev: !production,
      // we'll extract any component CSS out into
      // a separate file — better for performance
      css: (css) => {
        css.write('public/bundle.css');
      },
    }),
    json(),

    // If you have external dependencies installed from
    // npm, you'll most likely need these plugins. In
    // some cases you'll need additional configuration —
    // consult the documentation for details:
    // https://github.com/rollup/rollup-plugin-commonjs
    resolve(),
    commonjs(),

    // If we're building for production (npm run build
    // instead of npm run dev), minify
    production && terser(),
  ],
};
@yigiterdev
Copy link
Contributor

Hey @slauzinho,
Thank you for informing us. Can you try with this rollup.config.js

// this file will not afect the sandbox but will
// afect the deployment and dowload

import svelte from "rollup-plugin-svelte";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import {terser} from "rollup-plugin-terser";
import json from "@rollup/plugin-json";

const production = !process.env.ROLLUP_WATCH;

export default {
  input: "index.js",
  output: {
    sourcemap: true,
    format: "iife",
    name: "app",
    file: "public/bundle.js"
  },
  external: [
    "buffer",
    "tslib",
    "crypto",
    "@walletconnect/client",
    "@walletconnect/types",
    "@json-rpc-tools/utils/dist/cjs/format"
  ],
  plugins: [
    svelte({
      // enable run-time checks when not in production
      dev: !production,
      // we'll extract any component CSS out into
      // a separate file — better for performance
      css: (css) => {
        css.write("public/bundle.css");
      }
    }),
    json(),

    // If you have external dependencies installed from
    // npm, you'll most likely need these plugins. In
    // some cases you'll need additional configuration —
    // consult the documentation for details:
    // https://github.com/rollup/rollup-plugin-commonjs
    resolve(),
    commonjs(),

    // If we're building for production (npm run build
    // instead of npm run dev), minify
    production && terser()
  ]
};

@slauzinho
Copy link
Author

slauzinho commented Nov 18, 2022

I'm able to build but when I try to serve it I get the error:

Uncaught ReferenceError: client is not defined at index.js:4:20

Just to add, if I use Vite (which uses rollup) I get the same issue where running in dev works but building for prod fails.

Im able to repro in Svelte and Vue

@slauzinho
Copy link
Author

slauzinho commented Nov 18, 2022

I created a repro project for Vite + Vue 3:
https://github.com/slauzinho/pera-wallet-vue-repro

Application runs fine if you do yarn dev.
But if you try to build for prod with yarn build + yarn serve you get this:

CleanShot 2022-11-18 at 12 49 36

@yigiterdev
Copy link
Contributor

I'm checking this. Thank you for your support. I will back to you.

@mucahit mucahit added Bug Something isn't working and removed help wanted labels Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants