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(vite): apply normalizePath to default entry file outside of project directory #8057

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Nov 19, 2023

Closes: #7722 (comment) (follow up of #7913)

I think this issue is because of the lack of normalizePath.


In https://github.com/hi-ogawa/remix/pull/1/files, I'm trying to verify this works on Windows, but it seems there is still something wrong.
I see SyntaxError: Unexpected token '<' in https://github.com/hi-ogawa/remix/actions/runs/6919035654/job/18821929935#step:7:328 which indicates transform not being run for client entry.

Copy link

changeset-bot bot commented Nov 19, 2023

🦋 Changeset detected

Latest commit: 02f7588

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@remix-run/dev Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/node Patch
@remix-run/react Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hi-ogawa hi-ogawa changed the title fix(vite): add normalizePath for out-of-tree client entry file url fix(vite): apply normalizePath to out-of-tree client entry file url Nov 19, 2023
@@ -91,7 +91,7 @@ const resolveFileUrl = (
// Vite will prevent serving files outside of the workspace
// unless user explictly opts in with `server.fs.allow`
// https://vitejs.dev/config/server-options.html#server-fs-allow
if (!isWithinRoot) return `/@fs` + filePath;
if (!isWithinRoot) return path.posix.join(`/@fs`, normalizePath(filePath));
Copy link
Contributor Author

@hi-ogawa hi-ogawa Nov 19, 2023

Choose a reason for hiding this comment

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

The idea is to just mimic what vite does here

https://github.com/vitejs/vite/blob/b93dfe3e08f56cafe2e549efd80285a12a3dc2f0/packages/vite/src/node/config.ts#L506

path.posix.join(FS_PREFIX, normalizePath(ENV_ENTRY))

@hi-ogawa
Copy link
Contributor Author

I'm not really familiar with Window quirks, so it's not likely I can figure this out myself.
Let me close this PR for now, but if anyone can help with this, I would appreciate it.

@alindsay55661
Copy link

This patch does, in fact, solve the issue described here: #7722 (comment)

@hi-ogawa
Copy link
Contributor Author

@alindsay55661 Thanks for testing! I had a feeling that there might be still something wrong, but if it works, then remix team might consider merging this PR without verifying on CI. I'll re-open this and wait for remix team's response.

@hi-ogawa hi-ogawa reopened this Nov 20, 2023
@hi-ogawa hi-ogawa marked this pull request as ready for review November 20, 2023 23:52
@hi-ogawa hi-ogawa changed the title fix(vite): apply normalizePath to out-of-tree client entry file url fix(vite): apply normalizePath to default entry file outside of project directory Nov 20, 2023
@pcattori pcattori force-pushed the fix-vite-resolveFileUrl-normalizePath-out-of-tree branch from 5fd9b74 to 63aa9f7 Compare November 21, 2023 19:43
@pcattori pcattori force-pushed the fix-vite-resolveFileUrl-normalizePath-out-of-tree branch from 63aa9f7 to 02f7588 Compare November 21, 2023 19:58
@pcattori pcattori merged commit acee744 into remix-run:dev Nov 21, 2023
9 checks passed
@hi-ogawa hi-ogawa deleted the fix-vite-resolveFileUrl-normalizePath-out-of-tree branch November 21, 2023 22:51
@alindsay55661
Copy link

@pcattori @brophdawg11 @hi-ogawa This did not merge correctly.

The change is absent from @remix-run/[email protected]:

if (!isWithinRoot) return `/@fs` + filePath;

As I am following this closely, I installed the pre-release and noticed the same error occured.

@pcattori
Copy link
Contributor

@alindsay55661 our GitHub bot gets a bit confused when changes land in dev right around the same time that our release branch gets cut, so it says this is part of 2.3.1 when it really isn't. Should be available in nightly and in next release.

Copy link
Contributor

github-actions bot commented Dec 5, 2023

🤖 Hello there,

We just published version 2.4.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@alindsay55661
Copy link

Confirmed, looks great, really looking forward to the 2.4.0 release.

Copy link
Contributor

🤖 Hello there,

We just published version 2.4.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants