@@ -5,7 +5,8 @@ export type { ImportString }
55export type { ImportStringList }
66export type { ImportStringParsed }
77
8- import { assert } from '../utils.js'
8+ import pc from '@brillout/picocolors'
9+ import { assert , assertWarning } from '../utils.js'
910
1011const IMPORT = 'import'
1112const SEP = ':'
@@ -36,14 +37,16 @@ function parseImportString(
3637 importString : string ,
3738 { legacy = false } : { legacy ?: boolean } = { } ,
3839) : null | ImportStringParsed {
39- if ( ! isImportString ( importString ) ) return null
40+ if ( ! importString . startsWith ( ` ${ IMPORT } ${ SEP } ` ) ) return null
4041 const parts = importString . split ( SEP )
4142 assert ( parts [ 0 ] === IMPORT )
4243
4344 if ( legacy && parts . length === 2 ) {
44- /* TODO
45- assertWarning(false, 'To-Do', { onlyOnce: true, showStackTrace: true })
46- */
45+ assertWarning (
46+ false ,
47+ `Replace ${ pc . cyan ( importString ) } with ${ pc . cyan ( importString ) } ${ pc . cyan ( ':default' ) } (import strings must include the export name)` ,
48+ { onlyOnce : true } ,
49+ )
4750 const exportName = 'default'
4851 const importPath = parts [ 1 ]
4952 assert ( importPath )
@@ -68,7 +71,7 @@ function parseImportString(
6871 * // => false
6972 */
7073function isImportString ( str : string ) : str is ImportString {
71- return str . startsWith ( ` ${ IMPORT } ${ SEP } ` )
74+ return ! ! parseImportString ( str , { legacy : true } )
7275}
7376
7477/**
0 commit comments