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

Make import.meta.url be the file URL in SSR #3472

Merged
merged 2 commits into from Jun 22, 2021
Merged

Make import.meta.url be the file URL in SSR #3472

merged 2 commits into from Jun 22, 2021

Conversation

matthewp
Copy link
Contributor

Changes

This fixes SSR which previously was the mounted path to the file (just the path, so not a valid URL). It is now the actual file as a URL. This allows you to do relative lookups.

This also adds support for importing via the node: prefix.

Testing

A test was added, but had to be skipped because Jest runs your code with the vm module and that module has a bug that prevents usage of import(), which this code relies on.

Docs

N/A

This fixes SSR which previously was the mounted path to the file (just the path, so not a valid URL). It is now the actual file as a URL. This allows you to do relative lookups.

This also adds support for importing via the `node:` prefix.
@matthewp matthewp requested a review from a team as a code owner June 22, 2021 12:56
@vercel
Copy link

vercel bot commented Jun 22, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/HW3SVWpRyC5dJUYQRqJRyFFxgKUw
✅ Preview: https://snowpack-git-import-node-pikapkg.vercel.app

Copy link
Collaborator

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

LGTM. Nice test!

@matthewp matthewp merged commit 8cff033 into main Jun 22, 2021
@matthewp matthewp deleted the import-node branch June 22, 2021 16:17
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.

None yet

2 participants