# RequireJS tips

## require timeout error

> The paths config was used to set two module IDs to the same file, and that file only has one anonymous module in it. If module IDs "something" and "lib/something" are both configured to point to the same "scripts/libs/something.js" file, and something.js only has one anonymous module in it, this kind of timeout error can occur. The fix is to make sure all module ID references use the same ID (either choose "something" or "lib/something" for all references), or use map config.

<http://requirejs.org/docs/errors.html#timeout>

简而言之，出现这种错误可能是对同一模块配置两个相同的 ID

## 不解析 RequireJs

涉及到 `geo.js` 里面的 `require(['googlemap'], function() { })`

这里 `require` 和 `commonJs` 里的 `require` 不同，推荐在使用 `requireJs` 的语义下，使用 `requirejs` 方法代替 `require`。

然后，在 `webpack` 配置中，我们应该忽略 `requireJs` 的解析，参考：[Rule.parser](https://webpack.js.org/configuration/module/#rule-parser) ，like this:

```javascript
{
    test: /\.jsx?$/,
    parser: {
        requireJs: false
    },
    loader: 'babel-loader'
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://edge.gitbook.io/edge/skill/require-tips.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
