Skip to content

Commit

Permalink
docs(module-tools): add faq about build (#5326)
Browse files Browse the repository at this point in the history
  • Loading branch information
10Derozan authored Jan 30, 2024
1 parent b9425b1 commit 1e70099
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/document/module-doc/docs/en/guide/faq/build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export const libs = {

In this case `babel-plugin-import` may also cause `Comps` to become `undefined`. So you need to remove the corresponding `babel-plugin-import` as well.

### Cannot find module http

If the output reports an error like `Cannot find module 'http'` at browser runtime, it means that your output has bundled node modules.
This may occur if some of your dependencies support both browser and node, such as `axios`, in which case you only need to set the [platform](/api/config/build-config.html/#platform) to `browser`.
If some third-party packages don't support the browser, you may need to manually inject [node polyfill](/plugins/official-list/plugin-node-polyfill).

## Exceptions FAQ

import BuildExceptionFAQ from '@site-docs-en/components/faq-build-exception';
Expand Down
6 changes: 6 additions & 0 deletions packages/document/module-doc/docs/zh/guide/faq/build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export const libs = {

此时 `babel-plugin-import` 也可能会导致 `Comps` 变为 `undefined`。因此也需要移除对应的 `babel-plugin-import`

### Cannot find module http

如果产物在浏览器运行时报了类似 `Cannot find module 'http'` 的错误,说明你的产物打包进了 node 模块。
这可能会发生于你的依赖里有一些同时支持 browser 和 node 的三方包,例如 `axios`,此时只需要将 [platform](/api/config/build-config.html/#platform) 设置为 `browser` 即可。
如果一些三方包不支持 browser, 你可能需要手动注入 [node polyfill](/plugins/official-list/plugin-node-polyfill)

## 异常类问题

import BuildExceptionFAQ from '@site-docs/components/faq-build-exception';
Expand Down

0 comments on commit 1e70099

Please sign in to comment.