Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

[BUG] remax 1.0.17 在 [email protected] 版本下打包结果无法正常运行 #238

Closed
hellohejinyu opened this issue Sep 18, 2019 · 4 comments · Fixed by #239
Closed
Labels
bug Something isn't working

Comments

@hellohejinyu
Copy link
Contributor

bug 描述
remax和remax-cli在升级到1.0.17版本时,如果node的版本为10.x.x,dist目录下生成的文件无法正常运行。
image
根据提示信息看是缺少wxml文件。

复现步骤
附有最小复现demo链接,请将Node环境设置为10.x.x(例:10.16.2)进行测试(目前已知Node版本在12.x.x时正常)

复现代码
https://github.com/elowes/remax-update-repro

版本信息:

  • remax 版本: 1.0.17
  • 小程序端 微信小程序
  • 开发环境 macOS
@hellohejinyu hellohejinyu added the bug Something isn't working label Sep 18, 2019
@Darmody
Copy link
Contributor

Darmody commented Sep 18, 2019

npm 的版本呢

@AEPKILL
Copy link
Contributor

AEPKILL commented Sep 18, 2019

似乎是 packages/remax-cli/src/build/plugins/template.ts 第 172 行的问题,没有等异步完成就执行后面的语句了。

node: 10.16.1
remax: 1.0.17
npm: 6.9.0

await Promise.all([
                files.map(async (file) => {
                    const chunk = bundle[file];
                    if (isRemaxEntry(chunk)) {
                        const filePath = Object.keys(chunk.modules)[0];
                        const page = pages.find(p => p.file === filePath);
                        if (page) {
                            console.log(`page:`, page);
                            const template = await createTemplate(file, adapter);
                            console.log(`tempalte:`, template);
                            templateAssets.push(template);
                            const config = await createPageManifest(options, file, adapter.name, page, context);
                            console.log(`config:`, config);
                            if (config) {
                                templateAssets.push(config);
                            }
                        }
                    }
                }),
            ]);
            console.log(`assets`);
            templateAssets.forEach(file => {
                this.emitFile(Object.assign({ type: 'asset' }, file));
            });

输出

🚀 启动 watch
🚚 编译...
100% (76): /Users/aepkill.h.hou/workspace/mohurd-jzgr/BuildingWorkerApplet/node_modules/scheduler/cjs/scheduler-tracing.development.jpage: { path: 'pages/index/index',
  file:
   '/Users/aepkill.h.hou/workspace/mohurd-jzgr/BuildingWorkerApplet/src/pages/index/index.tsx' }
assets  <--- !!!!注意这里!!!!
tempalte: { fileName: 'pages/index/index.axml',
  source:
   '<import-sjs name="helper" from="../../helper.sjs" />\n<import src="../../base.axml" />\n<template is="REMAX_TPL" data="{{tree: helper.reduce(action)}}" />' }
config: undefined
💡 完成

@Darmody
Copy link
Contributor

Darmody commented Sep 18, 2019

@newset 你看能不能排查一下这个问题

@AEPKILL
Copy link
Contributor

AEPKILL commented Sep 18, 2019

改成:

await Promise.all(files.map(async (file) => {
                    const chunk = bundle[file];
                    if (isRemaxEntry(chunk)) {
                        const filePath = Object.keys(chunk.modules)[0];
                        const page = pages.find(p => p.file === filePath);
                        if (page) {
                            console.log(`page:`, page);
                            const template = await createTemplate(file, adapter);
                            console.log(`tempalte:`, template);
                            templateAssets.push(template);
                            const config = await createPageManifest(options, file, adapter.name, page, context);
                            console.log(`config:`, config);
                            if (config) {
                                templateAssets.push(config);
                            }
                        }
                    }
                }));

就可以了

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants