Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0.0-rc.4、v3.0.0-rc.5 ,使用 require.context 加载指定目录模块时编译失败 #6720

Closed
digiaries opened this issue Jun 17, 2020 · 0 comments
Assignees
Milestone

Comments

@digiaries
Copy link
Contributor

digiaries commented Jun 17, 2020

问题描述

Taro v3.0.0-rc.4、Taro v3.0.0-rc.5 ,使用 require.context 加载模块时编译失败。

复现步骤

  1. 无论 Taro v3.0.0-rc.4、Taro v3.0.0-rc.5 都会有这个问题,Taro v3.0.0-beta.6 正常
  2. 使用 require.context 指定目录下的所有模块
var configResolers = require.context("./", true, /config\.\w+\.js$/);

期望行为

可以正常使用 require.context

报错信息

🙅   编译失败.

./src/config/index.js
Module not found: Can't resolve './' in '/Users/Edwin/codes/taro/src/config'

./src/config/index.js
Module not found: Error: Can't resolve './' in '/Users/Edwin/codes/taro/src/config'
resolve './' in '/Users/Edwin/codes/taro/src/config'
  Parsed request is a directory
  using description file: /Users/Edwin/codes/taro/package.json (relative path: ./src/config)
    resolve multi platform file path
      using description file: /Users/Edwin/codes/taro/package.json (relative path: ./src/config)
        using description file: /Users/Edwin/codes/taro/package.json (relative path: ./src/config/index.js)
          as directory
            /Users/Edwin/codes/taro/src/config/index.js is not a directory

系统信息

  Taro CLI 3.0.0-rc.5 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
      npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    npmPackages:
      @tarojs/cli: 3.0.0-rc.5 => 3.0.0-rc.5
      @tarojs/components: 3.0.0-rc.5 => 3.0.0-rc.5
      @tarojs/taro: 3.0.0-rc.5 => 3.0.0-rc.5
      @tarojs/webpack-runner: 3.0.0-rc.5 => 3.0.0-rc.5
      eslint-config-taro: 3.0.0-rc.5 => 3.0.0-rc.5
      react: 16.13.1 => 16.13.1

补充信息

看看 MultiPlatformPlugin 及关联上下游的解析逻辑

@digiaries digiaries added the CLI label Jun 17, 2020
@yuche yuche added this to the 3.0.0-rc.6 milestone Jun 22, 2020
Chen-jj added a commit that referenced this issue Jun 23, 2020
require.context 的情况下不使用多端文件判断逻辑
yuche pushed a commit that referenced this issue Jun 23, 2020
require.context 的情况下不使用多端文件判断逻辑
@yuche yuche closed this as completed Jun 23, 2020
yuche pushed a commit that referenced this issue Jun 23, 2020
require.context 的情况下不使用多端文件判断逻辑
yuche added a commit that referenced this issue Jun 23, 2020
* chore(release): publish v3.0.0-rc.6

* fix(runner-utils): 修复 resolve 插件,fix #6720 (#6782)

require.context 的情况下不使用多端文件判断逻辑

Co-authored-by: chenjiajian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants