-
Notifications
You must be signed in to change notification settings - Fork 921
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
bugfix: Allow baseUrl to be remote #531
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pikapkg/snowpack/okkch6346 |
a8749b3
to
2b8aeca
Compare
2b8aeca
to
cf9bb0e
Compare
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="https://cdn.pika.dev/favicon.ico" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👆 proof it’s working. That would have been https:/cdn.pika.dev
otherwise
@@ -0,0 +1,3 @@ | |||
import {flatten} from "https://cdn.pika.dev/web_modules/array-flatten.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👆 here, too
cf9bb0e
to
0f0f820
Compare
0f0f820
to
0a1efb4
Compare
@@ -4,7 +4,7 @@ import {SnowpackConfig} from '../config'; | |||
import {findMatchingMountScript, ImportMap} from '../util'; | |||
import srcFileExtensionMapping from './src-file-extension-mapping'; | |||
const cwd = process.cwd(); | |||
const URL_HAS_PROTOCOL_REGEX = /^\w:\/\./; | |||
const URL_HAS_PROTOCOL_REGEX = /^(\w+:)?\/\//; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized there was a bug in this RegEx. \w
matches a word character, not a word. So \w+
is needed.
I also removed the character trailing the //
(the .
). I think that’s OK, because this was only used in a .test()
below? I needed to remove that to strip just the protocol, not the protocol + 1 trailing char below.
@@ -77,13 +77,18 @@ export function createImportResolver({ | |||
return spec; | |||
} | |||
if (dependencyImportMap && dependencyImportMap.imports[spec]) { | |||
// if baseURL is remote, handle that outside of path.posix.join() | |||
const protocolMatch = config.buildOptions.baseUrl.match(URL_HAS_PROTOCOL_REGEX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn’t notice the existing RegEx here. Reused what was here, with the bugfix (above)
0a1efb4
to
4af6c0b
Compare
If a user has a remote URL (
https://cdn.pika.dev
) as either theirhomepage
or theirbuildOptions.baseUrl
, we accidentally ruin that import withpath.posix.join()
(https://cdn.pika.dev
becomeshttps:/cdn.pika.dev
). This fixes that.