Incorrect build with vite + Fresh plugin with browser package.json

Open
#3,546 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
deno, typescript, vite

Research direction

Start by reading Fresh's module resolution plugin and how it handles the browser field in package.json; the issue does not name the relevant files or tests. Reproduce the Vite build with an island importing object-inspect and compare dev and production behavior. Done means the browser mapping prevents util.inspect.js from entering the bundle and the runtime errors are resolved.

Written by the indexing model from the issue text.

Description

upstream

I have a project that I have been migrating to Fresh 2 using vite as the build system and encountered an error that I think has to do with Fresh's module resolution plugin and how vite works. Admittedly the package is using some rather esoteric package.json configuration.

Basically object-inspect uses the following in the package.json:

{
  "browser": {
    "./util.inspect.js": false
  },
}

But when building an island that imports the package, the util.inspect.js module is imported into the bundle (though it ends up being dead code) but it causes slightly different run-time errors between the dev and production builds.

There is this old issue with vite by itself which appears to have fixed the issue.

Dominant language
TypeScript
Stars
13.8k
Forks
757
Avg merge
3m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from freshframework/fresh

All issues in freshframework/fresh

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.