airyland / airyland/vux

[Bug Report] @vux/loader 对 workspace 的支持

Offen
#3,474 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Vue
Sterne
17.5k
Forks
3.6k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### VUX version
2.9.4

### OS/Browsers version
yarn workspace

### Vue version
2.6.10

### Code

```html
@vux\loader\src\index.js:326:18
mapPath 拼接出错

if (hasPlugin('vux-ui', vuxConfig.plugins)) {
let mapPath = path.resolve(vuxConfig.options.projectRoot, 'node_modules/vux/src/components/map.json')
if (vuxConfig.options.vuxDev) {
mapPath = path.resolve(vuxConfig.options.projectRoot, 'src/components/map.json')
}
const maps = require(mapPath)
if (isWebpack2) {
config.plugins.push(new webpack.LoaderOptionsPlugin({
vuxMaps: maps
}))
} else {
config = merge(config, {
vuxMaps: maps
})
}
}
```

### Steps to reproduce
lerna init
修改 package.json, 使用yarn workspace
lerna create compiler
lerna create playground

在compiler中添加 @vux/loader merge相关代码

在 playground中调用 compiler中代码

运行报错:

(node:17816) UnhandledPromiseRejectionWarning: Error: Cannot find module 'F:\paas-subtree\scoffalds\design-time\node_modules\vux\src\components\map.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.module.exports.merge (F:\paas-subtree\node_modules\@vux\loader\src\index.js:326:18)
at webpackConfig.addConfigFn.config (F:\paas-subtree\packages\paas-compiler\build\chain-config\vux.chain.js:6:30)
at webpackRawConfigFns.forEach.fn (F:\paas-subtree\packages\paas-compiler\build\chainable-config.js:28:21)
at Array.forEach ()
at module.exports.applyConfig (F:\paas-subtree\packages\paas-compiler\build\chainable-config.js:25:25)
at main (F:\paas-subtree\packages\paas-compiler\server\dev-server.js:63:57)

### What is Expected?

**更改 mapPath 拼接方式为 path.resolve(require.resolve('vux/package.json'), '..', 'src/components/map.json')**

从而得到 "F:\paas-subtree\node_modules\vux\src\components\map.json", 而且能减少 if

### What is actually happening?
其中 vux 位于 'F:\paas-subtree\'
而 vuxConfig.options.projectRoot 取值为 ‘F:\paas-subtree\scoffalds\design-time’

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.