alibaba / alibaba/rax

[BUG] driver-universal es module contains `require` syntax

Open
#2,349 0 comments 0 reactions 1 assignee Claimed by @SoloJiang View on GitHub
Bug
Dominant language
JavaScript
Stars
8k
Forks
611
PR merge metrics
No merged PRs in 30d

Description

### ⌨️

- [ ] Would you like to work on a fix?

### Where is the bug from?

I don't know

### Minimal code and steps to reproduce the bug

This is the source code from `driver-universal` npm package

```js
// node_modules/driver-universal/es/index.js

import { isWeex, isWeb, isMiniApp, isWeChatMiniProgram, isByteDanceMicroApp, isBaiduSmartProgram, isKuaiShouMiniProgram } from 'universal-env';
var currentDriver;

if (isWeex) {
currentDriver = require('./weex')["default"];
} else if (isWeb) {
currentDriver = require('./web')["default"];
} else if (isMiniApp || isWeChatMiniProgram || isByteDanceMicroApp || isBaiduSmartProgram || isKuaiShouMiniProgram) {
currentDriver = require('./miniapp')["default"];
}

export default currentDriver;
```

package.json#module should target at ESM standard entry

This file contains require() which break my build

### Current and expected behavior

expect `es/index.js` does not contain any `require` syntax

### Environment

- OS: mac
- Node: Node 14
- Browser: chrome

### build.json

_No response_

### Possible solution

fix your build script

build and publish again

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.