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

fix(scripts/build): use correct asset-copy paths on Windows #712

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

DarianM
Copy link
Member

@DarianM DarianM commented Nov 13, 2024

Context

The copy plugin should be able to copy all the files correctly, regardless of the operating system (Windows, Linux, or macOS).

Closes #711 .

Changes proposed in this pull request

Convert the backslashes to forward slashes in the from and to paths passed to the copy plugin.

@DarianM DarianM linked an issue Nov 13, 2024 that may be closed by this pull request
@DarianM DarianM changed the title fix:normalize paths to use forward slashes fix: extension build windows environment Nov 13, 2024
Copy link
Contributor

github-actions bot commented Nov 13, 2024

Extension builds preview

Name Link
Latest commit 421b623
Latest job logs Run #11835264046
BadgeDownload
BadgeDownload

@DarianM DarianM self-assigned this Nov 13, 2024
Copy link
Member

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can directly use path.posix.join() instead to force forward slashes everywhere.

@DarianM
Copy link
Member Author

DarianM commented Nov 14, 2024

@sidvishnoi
we can, but the issue is that path.posix.join() assumes all input paths are using forward slashes, but the input paths (SRC_DIR, DEV_DIR, DIST_DIR ) are actually provided by the operating system and nodejs, which means on windows they will contain backslashes.

// if we use path.posix.join():
path.posix.join(SRC_DIR, 'popup', 'index.html')
// results in: 'D:\\web-monetization-extension\\src/popup/index.html'
//  it doesn't convert the existing backslashes in the input paths

we can use path.posix directly, would first need to convert all input paths to use forward slashes from esbuild/config.ts like
export const SRC_DIR = path.resolve(ROOT_DIR, 'src').replaceAll(path.sep, path.posix.sep)

esbuild/config.ts Outdated Show resolved Hide resolved
Copy link
Member

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cleanest would be adding a util (say toPosix) and just call it to replace all windows separators to posix type, only for the copy plugin.

esbuild/plugins.ts Outdated Show resolved Hide resolved
@sidvishnoi sidvishnoi changed the title fix: extension build windows environment fix(scripts/build): use correct asset-copy paths on Windows Nov 14, 2024
Copy link
Member

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thanks @DarianM and congrats on your first PR here 🎉

@sidvishnoi sidvishnoi added the area: scripts Improvements or additions to custom scripts label Nov 14, 2024
@sidvishnoi sidvishnoi merged commit 9148bf3 into main Nov 14, 2024
9 checks passed
@sidvishnoi sidvishnoi deleted the 711-bug-fix-extension-build-windows-environment branch November 14, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: scripts Improvements or additions to custom scripts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Fix extension build windows environment
2 participants