最近在研究前端工程化,涉及到 rollup,组件库,多包管理器,尝试使用多包管理工具控制 UI 库,但遇到了问题。
单独的 ui 库工程是能正常运行的,但一旦使用多包管理器,无论是 pnpm workspace(这个确实更友好),还是 yarn workspace,都会报下面这个错
```
./components/index.ts → lib/index.main.js, lib/index.module.js...
[!] Error: 'default' is not exported by ../../node_modules/classnames/index.js, imported by ../../node_modules/antd/es/empty/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module../../node_modules/antd/es/empty/index.js (18:7)
16:
17: import * as React from 'react';
18: import classNames from 'classnames';
^
19: import { ConfigContext } from '../config-provider';
20: import LocaleReceiver from '../locale-provider/LocaleReceiver';
Error: 'default' is not exported by ../../node_modules/classnames/index.js, imported by ../../node_modules/antd/es/empty/index.js
at error (/Users/kilims/Documents/playground/personal/lerna_projects/node_modules/rollup/dist/shared/rollup.js:158:30)
```
看起来是 rollup 在 monorepo 的架构下,symlink 某些配置不起效,导致 commonjs 规范没法正确引入包
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module 这个网站已经试过了,nameExportedOption 已经废弃,且也尝试了 symlink 的一些参数,始终无法获得正解(目的:正常在 monorepo 架构下跑起来)
但头疼的是没有思绪看源码进行修改,有没有 v 友有类似经验,求个解决思路