Skip to content

Commit a6fcdd9

Browse files
authored
fix(cdn): change default value of baseUrl to empty string (#423)
`cdnBaseUrl` is settable via the project.json or via attribute/property. The property takes precedence over the project.json, and if neither is defined it defaults to unpkg.com. By having a default value for the property, then in order to take a value from the config, then the user would need to explicitly set the property / attribute to `''`. Confirmed this works by setting the cdnBaseUrl in project/project.json in the configurator
1 parent c08d9b0 commit a6fcdd9

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ All-in-one project, editor, file switcher, and preview with a horizontal side-by
682682
| -------------------- | -------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
683683
| `projectSrc` | `string` | `undefined` | URL of the [project manifest](#project-manifest) to load |
684684
| `config` | `ProjectManifest` | `undefined` | Get or set the project configuration and files, ([details](#option-3-config-property)). |
685-
| `cdnBaseUrl` | `string` | `https://unpkg.com` | Change the underlying npm CDN base url. Confirmed tested are `htts://unpkg.com` and `https://cdn.jsdelivr.net/npm` |
685+
| `cdnBaseUrl` | `string` | `""` | Change the underlying npm CDN base url. Confirmed tested are `htts://unpkg.com` and `https://cdn.jsdelivr.net/npm`. Note: Default `""` resolves to `https://unpkg.com` |
686686
| `lineNumbers` | `boolean` | `false` | Render a gutter with line numbers in the editor |
687687
| `lineWrapping` | `boolean` | `false` | If `true`, long lines are wrapped, otherwise the editor will scroll. |
688688
| `editableFileSystem` | `boolean` | `false` | Allow adding, removing, and renaming files |
@@ -713,7 +713,7 @@ project element.
713713
| ---------------- | ----------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
714714
| `projectSrc` | `string` | `undefined` | URL of a [project files manifest](#option-2-json-manifest) to load. |
715715
| `config` | `ProjectManifest` | `undefined` | Get or set the project configuration and files, ([details](#option-3-config-property)). |
716-
| `cdnBaseUrl` | `string` | `https://unpkg.com` | Change the underlying npm CDN base url. Confirmed tested are `htts://unpkg.com` and `https://cdn.jsdelivr.net/npm` |
716+
| `cdnBaseUrl` | `string` | `""` | Change the underlying npm CDN base url. Confirmed tested are `htts://unpkg.com` and `https://cdn.jsdelivr.net/npm`. Note: Default `""` resolves to `https://unpkg.com` |
717717
| `sandboxScope` | `string` | `"playground-elements"` | The service worker scope to register on. |
718718
| `sandboxBaseUrl` | `string` | _module parent directory_ | Base URL for untrusted JavaScript execution (⚠️ use with caution, see [sandbox security](#sandbox-security)). Resolved relative to the module containing the definition of `<playground-project>`. |
719719
| `diagnostics` | `Map<string, lsp.Diagnostic>` | `undefined` | Map from filename to array of Language Server Protocol diagnostics resulting from the latest compilation. |

src/configurator/knobs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ export const knobs = [
136136
id: 'cdnBaseUrl',
137137
label: 'CDN Base URL',
138138
section: 'features',
139-
default: 'https://unpkg.com',
139+
default: '',
140+
placeholder: 'Resolves to https://unpkg.com',
140141
htmlAttribute: 'cdn-base-url',
141142
inputType: 'text',
142143
}),

src/playground-ide.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,12 @@ export class PlaygroundIde extends LitElement {
221221
* Base URL for the CDN used to resolve bare module specifiers.
222222
*
223223
* Examples:
224-
* - "https://unpkg.com" (default)
224+
* - "" (default, but resolves to "https://unpkg.com")
225+
* - "https://unpkg.com"
225226
* - "https://cdn.jsdelivr.net/npm"
226227
*/
227228
@property({attribute: 'cdn-base-url'})
228-
cdnBaseUrl = 'https://unpkg.com';
229+
cdnBaseUrl = '';
229230

230231
/**
231232
* Allow the user to add, remove, and rename files in the project's virtual

src/playground-project.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,12 @@ export class PlaygroundProject extends LitElement {
178178
* Base URL for the CDN used to resolve bare module specifiers.
179179
*
180180
* Examples:
181+
* - "" (default, but resolves to "https://unpkg.com")
181182
* - "https://unpkg.com" (default)
182183
* - "https://cdn.jsdelivr.net/npm"
183184
*/
184185
@property({attribute: 'cdn-base-url'})
185-
cdnBaseUrl = 'https://unpkg.com';
186+
cdnBaseUrl = '';
186187

187188
/**
188189
* The service worker scope to register on

0 commit comments

Comments
 (0)