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(remix-react): avoid dynamic import of relative file #5007

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

MatthieuCoelho
Copy link

Problem :

  • Setting a relative "publicPath" in remix.config produce error on Safari.
    image

Cause :

Solution :

  • Create the full path instead of letting the "import"

I tested it successfully on safari and safari mobile.

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2023

⚠️ No Changeset found

Latest commit: 92e0a74

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 5, 2023

Hi @MatthieuCoelho,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 5, 2023

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@MichaelDeBoey
Copy link
Member

Hi @MatthieuCoelho!

Are you still interested in getting this one merged?

If so, please rebase onto latest dev & resolve conflicts

@MatthieuCoelho
Copy link
Author

Hi @MatthieuCoelho!

Are you still interested in getting this one merged?

If so, please rebase onto latest dev & resolve conflicts

Yes absolutely, it should be good :)

@brophdawg11
Copy link
Contributor

Could you provide an example application demonstrating the bug that this fixes?

@brophdawg11 brophdawg11 added the needs-response We need a response from the original author about this issue/PR label Aug 22, 2023
@MatthieuCoelho
Copy link
Author

@brophdawg11
With this change in default sandbox :
In remix.config.js
publicPath: "../build/",

In root.tsx
<base href="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/" />

If you build and start this sandbox : https://codesandbox.io/p/sandbox/quirky-frost-9h2wwv

  • Imports on chrome are working (See in developers tools)
  • But failed on safari with : [Error] Failed to load resource: the server responded with a status of 404 (Not Found) (chunk-P2YRTDNV.js, line 0),
    due to this import import {c as e, e as p} from "../build/_shared/chunk-P2YRTDNV.js";

@github-actions github-actions bot removed the needs-response We need a response from the original author about this issue/PR label Aug 23, 2023
@brophdawg11 brophdawg11 self-assigned this Aug 23, 2023
@brophdawg11
Copy link
Contributor

Can you explain why you need a publicPath that goes up a directory? Public paths are usually to tell the browser where to find the scripts and indicate a root level path such as /build/ (which resolves to https://{yourdomain}.com/build/) or an absolute URL such as https://cdn.example.com/ to host assets on an external CDN domain.

publicPath: "../build" seems like an odd/invalid use case to me since it sort of tells the browser to load from something like https://{yourdomain}.com/../build/ which is invalid.

Can you use a root-relative or absolute path for your juse-case?

@MatthieuCoelho
Copy link
Author

MatthieuCoelho commented Aug 29, 2023

We want to ‘build once, run everywhere’, since the public path is dynamically generated at runtime we can’t use root-relative or absolute paths . Using a relative path is the only way.

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.

None yet

4 participants