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

feat(asset): allow non-existent url #7306

Merged
merged 2 commits into from
Mar 13, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Mar 13, 2022

Description

Fixes #4308

Allow non-existent urls in new URL(..., import.meta.url) if it needs to be resolved in runtime.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 13, 2022
@patak-dev
Copy link
Member

The issue I see is that we are no longer going to inform the user of typos when building the app. How usual it is to have URL that aren't known during build time? I think that we should allow them, but maybe we could log a message for them? Something like:

{nonExistentUrl} doesn't exist at build time, it will remain unchanged to be resolved at runtime

@bluwy
Copy link
Member Author

bluwy commented Mar 13, 2022

That's sounds like a fair thing to do. If someone wants to turn that off, we could explore vite-ignore in the future too.

@bluwy
Copy link
Member Author

bluwy commented Mar 13, 2022

Added a log. It doesn't look that great:

vite v2.9.0-beta.0 building for production...
transforming (1) index.htmlnew URL('non-existent', import.meta.url) doesn't exist at build time, it will remain unchanged to be resolved at runtime
✓ 20 modules transformed.
dist/foo/assets/asset.b9f46fb3.png            12.47 KiB
dist/foo/assets/fragment.d2571ff2.svg         1.11 KiB
dist/foo/assets/Inter-Italic.bab4e808.woff2   105.64 KiB
dist/foo/assets/fragment-bg.c8ba701c.svg      1.13 KiB
dist/foo/assets/Inter-Italic.7b187d57.woff    140.11 KiB
dist/foo/index.html                           20.05 KiB
dist/foo/manifest.json                        0.38 KiB
dist/foo/assets/index.70c90341.js             12.41 KiB / gzip: 4.92 KiB
dist/foo/assets/index.69eb903c.css            19.58 KiB / gzip: 3.90 KiB

It doesn't go in a new line, and I don't think there's a pattern like this too in the codebase (?). Perhaps this is still acceptable.

@patak-dev patak-dev merged commit 6bc45a2 into vitejs:main Mar 13, 2022
@patak-dev
Copy link
Member

Uh, merged before seeing your comment, we should later fix the new line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asset-import-meta-url cant resolve non existing paths
2 participants