Skip to content

fix(ssr): make import.meta.url be the filesystem URL#5268

Merged
patak-cat merged 1 commit intovitejs:mainfrom
matthewp:import-meta-url
Oct 12, 2021
Merged

fix(ssr): make import.meta.url be the filesystem URL#5268
patak-cat merged 1 commit intovitejs:mainfrom
matthewp:import-meta-url

Conversation

@matthewp
Copy link
Contributor

Description

This makes import.meta.url be the file URL, the same as in Node ESM, Deno, Webpack, etc.

Additional context

This is a spinoff from #5252


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.

@patak-cat
Copy link
Member

See #5252 (comment) for reference, from @matthewp:

I deployed a test project in Cloudflare and import.meta.url is undefined. If you use their webpack template then it's the local filesystem URL as expected (because webpack is building to commonjs).

If it is undefined, it may be that they haven't yet implemented support in webworkers. We should keep an eye on this, as we may need to update the handling depending on ssr.target later.

@patak-cat patak-cat assigned antfu and unassigned antfu Oct 12, 2021
@patak-cat patak-cat requested a review from antfu October 12, 2021 15:23
@patak-cat patak-cat merged commit 7674cf2 into vitejs:main Oct 12, 2021
@matthewp matthewp deleted the import-meta-url branch October 12, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants