alibaba / alibaba/rax

[BUG] rax-app

Open
#2,408 1 comment 0 reactions 0 assignees 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?

Rax Core

### Minimal code and steps to reproduce the bug

1: 有类似上面这种小组件,,我单独把它发布成npm包,比如叫他“@ali/Icon-Comp”
```js @ali/Icon-Comp
import { createElement } from 'rax';
import cssModule from './index.module.css';
import View from 'rax-view';

const Icon = (props) => {
return (




);
};
export default Icon;
```
2: 然后再rax应用里进行使用:

import Icon from '@ali/Icon-Comp'

页面的build.json见下方:

### Current and expected behavior

本来应给是个cssmodule的类名,结果打包出来不对。

然而,如果组件写在项目里,是可以的。 但是抽出来,搞成npm包,再引入,就不行

![image](https://user-images.githubusercontent.com/14048126/233576646-b51b7f9d-f932-4304-b67a-b64833849377.png)

### Environment

"rax-app": "^3.8.7",

### build.json

{
"targets": [
"web",
"weex-v2"
],
"web": {
"mpa": true,
"pha": false
},
"weex": {
"mpa": true,
"mode": "dom"
},
"swc": false,
"plugins": [
"@ali/build-plugin-rax-app-def",
"@ali/plugin-rax-weex-v2"
],
"webpack5": true,
"inlineStyle": {
"forceEnableCSS": true
}
}

### Possible solution

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the supplied build.json, the rax-app environment, and the minimal external @ali/Icon-Comp package example. Compare the generated CSS module class names when the component is imported from npm versus defined in the project; done means the external component receives the expected CSS module classes for the web and weex-v2 targets.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.