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

Latest commit to loadProjectConfig.js causes windows config file name to be converted to a url twice #1107

Closed
DaveWelling opened this issue Mar 24, 2025 · 3 comments · Fixed by #1113
Assignees
Labels
status:confirmed The issue has been reviewed and all necessary information is provided. type:bug A bug report.

Comments

@DaveWelling
Copy link
Contributor

Describe the bug

This contains a call to _nodeUrl.default.pathToFileURL(configFilePath) which duplicates a call in discoverConfigFilePath line 19 for windows machines.
https://github.com/callstack/repack/blame/main/packages/repack/src/commands/common/config/loadProjectConfig.ts

This results in the config file path being converted to a URL twice.

System Info

System:
  OS: Windows 10 10.0.19045
  CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
  Memory: 31.27 GB / 63.92 GB
Binaries:
  Node:
    version: 23.6.0
    path: C:\nvm4w\nodejs\node.EXE
  Yarn:
    version: 1.22.5
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 10.9.2
    path: C:\nvm4w\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found
Languages:
  Java: 17.0.13
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.78.1
    wanted: 0.78.1
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Re.Pack Version

5.0.5

Reproduction

https://github.com/callstack/repack/issues

Steps to reproduce

Just try to build with any windows machine and an es module config file (.mjs)

@DaveWelling DaveWelling added status:new New issue, not reviewed by the team yet. type:bug A bug report. labels Mar 24, 2025
@DaveWelling
Copy link
Contributor Author

DaveWelling commented Mar 31, 2025

I think you could just delete lines 18-20 and that would solve the problem:

function discoverConfigFilePath(root: string, candidates: string[]) {
  for (const candidate of candidates) {
    const filename = path.isAbsolute(candidate)
      ? candidate
      : path.join(root, candidate);

    if (fs.existsSync(filename)) {
// DELETE THESE 3 LINES👇
      if (path.extname(filename) === '.mjs' && os.platform() === 'win32') {
        return url.pathToFileURL(filename).href;
      }
      return filename;
    }
  }

  throw new CLIError('Cannot find configuration file');
}

@jbroma jbroma added status:confirmed The issue has been reviewed and all necessary information is provided. and removed status:new New issue, not reviewed by the team yet. labels Apr 3, 2025
@jbroma jbroma self-assigned this Apr 3, 2025
@jbroma
Copy link
Member

jbroma commented Apr 3, 2025

@DaveWelling thank you for reporting this bug,

Sorry for the delayed response - I've confirmed the bug and tested the solution you mentioned above (nice find!) - should be available in the next patch release

@jbroma
Copy link
Member

jbroma commented Apr 3, 2025

Fix available in Re.Pack 5.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:confirmed The issue has been reviewed and all necessary information is provided. type:bug A bug report.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants