-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Unable to use in Nest.js #379
Comments
Do you have |
The original configuration of the project is "type": "module". I want to use it in both browser and Node.js environments simultaneously. I cannot change it to "type": "commonjs". |
I modified the original configuration as follows, so it can be used simultaneously in both browser and Node.js environments.
|
Could you do this Pull Request |
Fixed in v2.4.0 |
create node in MathNode.ts
import { defineNode, NodeInterface } from "@baklavajs/core"; import { NumberInterface, SelectInterface } from "@baklavajs/renderer-vue"; export default defineNode({ type: "Math", inputs: { number1: () => new NumberInterface("Number", 1), number2: () => new NumberInterface("Number", 10), operation: () => new SelectInterface("Operation", "Add", ["Add", "Subtract"]).setPort(false), }, outputs: { output: () => new NodeInterface("Output", 0), }, calculate({ number1, number2, operation }) { let output: number; if (operation === "Add") { output = Number(number1) + Number(number2); } else if (operation === "Subtract") { output = Number(number1) - Number(number2); } else { throw new Error(
Unknown operation: ${operation}); } return new Promise((resolve, reject) => { setTimeout(() => { resolve({ output }) ; }, 3000); }) }, });
import this file
import MathNode from "./MathNode";
register this node
const editor = new Editor(); editor.registerNodeType(MathNode, { category: "A-Base" });
4.Then, the console reported an error.
require() of ES Module .\node_modules.pnpm@baklavajs+renderer-vue@2.3.0\node_modules@baklavajs\renderer-vue\dist\renderer-vust\renderer-vue.umd.js from .\dist\modules\auth\MathNode.js not supported.
renderer-vue.umd.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package that package scope as ES modules.
Instead either rename renderer-vue.umd.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "moduletype": "module" to "type": "commonjs" in D:\Programs\SDMS\eims-task\node_modules.pnpm@baklavajs+renderer-vue@2.3.0\node_modules@baklavajs\renderer-vue\package.jll .js files ason to treat all .js files as CommonJS (using .mjs for all ES modules instead).
The text was updated successfully, but these errors were encountered: