-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
234 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
[feat] `$env/static/*` are now virtual to prevent writing sensitive values to disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Lazy load Svelte components to reenable no-ssr use cases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// in `vite dev` and `vite preview`, we use a fake asset path so that we can | ||
// serve local assets while verifying that requests are correctly prefixed | ||
export const SVELTE_KIT_ASSETS = '/_svelte_kit_assets'; | ||
|
||
export const GENERATED_COMMENT = '// this file is generated — do not edit it\n'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { GENERATED_COMMENT } from './constants.js'; | ||
|
||
/** | ||
* @param {string} id | ||
* @param {Record<string, string>} env | ||
* @returns {string} | ||
*/ | ||
export function create_module(id, env) { | ||
/** @type {string[]} */ | ||
const declarations = []; | ||
|
||
for (const key in env) { | ||
if (!valid_identifier.test(key) || reserved.has(key)) { | ||
continue; | ||
} | ||
|
||
const comment = `/** @type {import('${id}').${key}} */`; | ||
const declaration = `export const ${key} = ${JSON.stringify(env[key])};`; | ||
|
||
declarations.push(`${comment}\n${declaration}`); | ||
} | ||
|
||
return GENERATED_COMMENT + declarations.join('\n\n'); | ||
} | ||
|
||
/** | ||
* @param {string} id | ||
* @param {Record<string, string>} env | ||
* @returns {string} | ||
*/ | ||
export function create_types(id, env) { | ||
const declarations = Object.keys(env) | ||
.filter((k) => valid_identifier.test(k)) | ||
.map((k) => `\texport const ${k}: string;`) | ||
.join('\n'); | ||
|
||
return `declare module '${id}' {\n${declarations}\n}`; | ||
} | ||
|
||
export const reserved = new Set([ | ||
'do', | ||
'if', | ||
'in', | ||
'for', | ||
'let', | ||
'new', | ||
'try', | ||
'var', | ||
'case', | ||
'else', | ||
'enum', | ||
'eval', | ||
'null', | ||
'this', | ||
'true', | ||
'void', | ||
'with', | ||
'await', | ||
'break', | ||
'catch', | ||
'class', | ||
'const', | ||
'false', | ||
'super', | ||
'throw', | ||
'while', | ||
'yield', | ||
'delete', | ||
'export', | ||
'import', | ||
'public', | ||
'return', | ||
'static', | ||
'switch', | ||
'typeof', | ||
'default', | ||
'extends', | ||
'finally', | ||
'package', | ||
'private', | ||
'continue', | ||
'debugger', | ||
'function', | ||
'arguments', | ||
'interface', | ||
'protected', | ||
'implements', | ||
'instanceof' | ||
]); | ||
|
||
export const valid_identifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.