retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

process is not defined in rete-vue-render-plugin #562

Closed SArpnt closed 2 years ago

SArpnt commented 2 years ago

i've been trying for a while now to get rete in a website using esm modules. the esm modules on jsdelivr have multiple issues (plugins try to import rete which doesn't exist, regeneratorRuntime is not defined), so i switched to using rollup. When i import rete-vue-render-plugin i get the error process is not defined.

rollup.config.js

import { nodeResolve } from "@rollup/plugin-node-resolve";

export default {
    input: "./rollup.mjs",
    output: {
        file: "../scripts/bundle.min.mjs", // not minifying right now to test
        format: "es",
    },
    plugins: [
        nodeResolve(),
    ],
};

rollup.mjs

import "regenerator-runtime/runtime";
import "rete-vue-render-plugin";

issue happens at this code

const EMPTY_OBJ = (process.env.NODE_ENV !== 'production')
    ? Object.freeze({})
    : {};
const EMPTY_ARR = (process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
const NOOP = () => { };

i know that the issue is because process is part of node.js, but i'm not sure how i'm supposed to fix this.

i feel like the installation section needs to be documented somewhat better, for example it said to use babel/polyfill, which has been deprecated and replaced by regenerator runtime

Ni55aN commented 2 years ago

https://github.com/rollup/rollup/issues/487

jeremybradbury commented 2 years ago

I think this was prematurely closed.

I tried all of the things in https://github.com/rollup/rollup/issues/487 and they don't work for Svelte.

process is always undefined even when using the replace methods.

You may assume this is an old issue, but I think it's a new one without a universal workaround.

as of now I have no way to pass any env variables to my Svelte app during the build.