Cannot Build files on Windows with absolute, or relative paths
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
### Our goal:
- We are taking 2 .ts files and building them with ```tsup```
- We output the build in another directory for later use
- This process is working flawlessly on Unix based OS (Mac, Linux, WSL)
- We would like to expand our library to support users running Windows
### Problem:
- Once files are located via Glob, we verify their existence with ```fs.existsSync()``` which return true
- We then pass an array of the file paths to ```build``` as seen below:
``` TS
export async function compileWalletSetupFunctions(
walletSetupDir: string,
debug: boolean
) {
const outDir = path.join(ensureCacheDirExists(), OUT_DIR_NAME);
// Use a normalized glob pattern
const globPattern = path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}');
// Use glob to find files, ensuring proper path handling
const fileList = await glob(globPattern, { absolute: true, windowsPathsNoEscape: true });
if (debug) {
console.log('[DEBUG] Found the following wallet setup files:');
console.log(fileList, '\n');
}
// TODO: This error message is copied over from another function. Refactor this.
if (!fileList.length) {
throw new Error(
[
`No wallet setup files found at ${walletSetupDir}`,
'Remember that all wallet setup files must end with `.setup.{ts,js,mjs}` extension!'
].join('\n')
);
}
try {
await build({
name: 'cli-build',
silent: true,
entry: fileList,
clean: true,
outDir,
format: 'esm',
splitting: true,
sourcemap: false,
config: false,
// TODO: Make this list configurable.
external: ['@synthetixio/synpress', '@playwright/test', 'playwright-core', 'esbuild', 'tsup'],
banner: {
js: FIXES_BANNER
},
esbuildOptions(options) {
// TODO: In this step, if the debug file is present, we should modify `console.log` so it prints from which file the log is coming from.
// We're dropping `console.log` and `debugger` statements because they do not play nicely with the Playwright Test Runner.
options.drop = debug ? [] : ['console', 'debugger']
}
})
} catch (e) {
console.log(e)
}
return outDir
}
```
- An error occurs at ```ts normalizeOptions()```:
```error Error within compile PrettyError file: Cannot find C:\Users\**\**\**\reponame\filepath\filename.ts```
- I've tried to convert to url and passed ```file:\\C:\Users\**\**\**\reponame\filepath\filename.ts``` and there I'd get another issue:
```ERR_UNSUPPORTED_ESM_URL_SCHEME```
- I've also tried non absolute paths, with no luck.
At my whits end as I've read most of the issues in the repo, maybe I'm missing something super obvious but any help would be appreciated.
### Resources:
- [404 Link for API Docs](https://paka.dev/npm/tsup)
- [Pull Request detailing changes made](https://github.com/Synthetixio/synpress/pull/1161/files#diff-60a2832f31ee8955f9d8295ca771ebf3203092839e5fe855d7a720cf8cd6895b)
Contributor guide
Research direction
Start at compileWalletSetupFunctions and trace how glob returns the Windows paths passed to tsup's build and normalizeOptions. Reproduce with the absolute and relative path variants described in the issue, then inspect the resulting Cannot find and ERR_UNSUPPORTED_ESM_URL_SCHEME errors. Done means the listed TypeScript files build into outDir on Windows without those path errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100