valtio: Error while building valtio within Next.js

(node:9173) UnhandledPromiseRejectionWarning: file:///Users/pablosz/Repositories/___/node_modules/.pnpm/valtio@1.2.0_react@17.0.2/node_modules/valtio/esm/vanilla.js:1
import { getUntracked, markToTrack } from 'proxy-compare';
                       ^^^^^^^^^^^
SyntaxError: Named export 'markToTrack' not found. The requested module 'proxy-compare' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'proxy-compare';
const { getUntracked, markToTrack } = pkg;

    at ModuleJob._instantiate (internal/modules/esm/module_job.js:121:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:166:5)
    at async Loader.import (internal/modules/esm/loader.js:178:24)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9173) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9173) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

> Build error occurred

I will add a reproduction repo soon

Very quick reproduction repo: https://github.com/PabloSzx/valtio-esm-build-error

Node.js version: v14.17.4

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (16 by maintainers)

Most upvoted comments

As a workaround, please use this for now:

yarn add https://pkg.csb.dev/pmndrs/valtio/commit/ecc61a06/valtio
npm i https://pkg.csb.dev/pmndrs/valtio/commit/ecc61a06/valtio

We will make releases once figuring out best configs.

Interesting. I wasn’t aware this use case. Then, we need the glob pattern.

Typescript and Parcel sandboxes are where I tested that. Yeah, will update the PR post work for the glob pattern on zustand

yay!!! 🎉