Vite/ESM import for protected-eval

Open
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript, vite

Research direction

Start by inspecting the package's published export and build configuration, then reproduce the documented import in a Vite/TypeScript project. Done means the documented import can be passed directly to Formio.use without manually unwrapping default, with the package build or relevant checks confirming the export behavior.

Written by the indexing model from the issue text.

Description

Hi :)

When using version 2.0.0 in a Vite/TypeScript project, the documented usage:

import ProtectedEval from "@formio/protected-eval";

Formio.use(ProtectedEval);

does not work because the imported value is exposed as:

{
  default: {
    evaluator: ...
  }
}

We currently need to unwrap it before registration:

const protectedEval = (
  ProtectedEval as unknown as { default: typeof ProtectedEval }
).default;

Formio.use(protectedEval);

Is this the recommended way to use the Protected Eval plugin in Vite projects, or would it be possible to provide an ESM-compatible export/build in a future release?

Thanks!

Dominant language
TypeScript
Stars
1
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.