antvis / antvis/util

[Bug]: SyntaxError: Named export 'deepMix' not found.

Open
#126 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
72
Forks
28
PR merge metrics
No merged PRs in 30d

Description

当在 `vite.config.ts` 中使用 `import { deepMix } from '@antv/util';` 时报错

```bash
$ cross-env TZ=Asia/Shanghai vite
failed to load config from /home/ian/osc/G2/vite.config.ts
error when starting dev server:
file:///home/ian/osc/G2/node_modules/.vite-temp/vite.config.ts.timestamp-1746363346287-276b6ca8bed88.mjs:2
import { deepMix } from "file:///home/ian/osc/G2/node_modules/@antv/util/lib/index.js";
^^^^^^^
SyntaxError: Named export 'deepMix' not found. The requested module 'file:///home/ian/osc/G2/node_modules/@antv/util/lib/index.js' 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 'file:///home/ian/osc/G2/node_modules/@antv/util/lib/index.js';
const { deepMix } = pkg;

at ModuleJob._instantiate (node:internal/modules/esm/module_job:182:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:266:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
at async loadConfigFromBundledFile (file:///home/ian/osc/G2/node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:49416:15)
at async bundleAndLoadConfigFile (file:///home/ian/osc/G2/node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:49259:22)
at async loadConfigFromFile (file:///home/ian/osc/G2/node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:49222:44)
at async resolveConfig (file:///home/ian/osc/G2/node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:48718:24)
at async _createServer (file:///home/ian/osc/G2/node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:38329:18)
at async CAC. (file:///home/ian/osc/G2/node_modules/vite/dist/node/cli.js:753:20)
error: script "dev" exited with code 1
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the failure from vite.config.ts with the reported cross-env TZ=Asia/Shanghai vite command. Then inspect how @antv/util/lib/index.js exposes deepMix and how Vite loads the configuration. Done means the Vite development server starts without the named-export SyntaxError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.