-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(svelte5): add support for Svelte 5 modules
- Loading branch information
Showing
2 changed files
with
28 additions
and
5 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
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,8 +1,17 @@ | ||
import { pathToFileURL } from 'url' | ||
import { VERSION } from 'svelte/compiler' | ||
import * as SvelteCompiler from 'svelte/compiler' | ||
|
||
export const dynamicImport = async (filename) => import(pathToFileURL(filename).toString()) | ||
|
||
export const IS_COMMON_JS = typeof module !== 'undefined' | ||
|
||
export const isSvelte3 = (version = VERSION) => version.startsWith('3') | ||
export const isSvelte3 = (version = SvelteCompiler.VERSION) => version.startsWith('3') | ||
|
||
export const DEFAULT_SVELTE_MODULE_INFIX = ['.svelte.'] | ||
|
||
export const DEFAULT_SVELTE_MODULE_EXT = ['.js', '.ts'] | ||
|
||
export const isSvelteModule = (filename) => | ||
typeof SvelteCompiler.compileModule === 'function' && | ||
DEFAULT_SVELTE_MODULE_INFIX.some((infix) => filename.includes(infix)) && | ||
DEFAULT_SVELTE_MODULE_EXT.some((ext) => filename.endsWith(ext)); |