Refactor(json schema): Optimize import map json schema
This commit is contained in:
@@ -125,13 +125,13 @@ class Compiler {
|
||||
}
|
||||
}
|
||||
|
||||
let path = importMap.imports[args.path]
|
||||
let path = importMap[args.path]
|
||||
let tempPath = args.path
|
||||
while (!path && tempPath.includes('/')) {
|
||||
tempPath = tempPath.substring(0, tempPath.lastIndexOf('/'))
|
||||
if (importMap.imports[tempPath]) {
|
||||
if (importMap[tempPath]) {
|
||||
const suffix = args.path.replace(tempPath, '')
|
||||
const importUrl = new URL(importMap.imports[tempPath])
|
||||
const importUrl = new URL(importMap[tempPath])
|
||||
path = `${importUrl.origin}${importUrl.pathname}${suffix}${importUrl.search}`
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class Compiler {
|
||||
}
|
||||
const pathUrl = new URL(path)
|
||||
const externals = pathUrl.searchParams.get('external')?.split(',') ?? []
|
||||
Object.keys(importMap.imports).forEach((item) => {
|
||||
Object.keys(importMap).forEach((item) => {
|
||||
if (!(item in externals)) {
|
||||
externals.push(item)
|
||||
}
|
||||
|
||||
@@ -126,18 +126,12 @@ export const tsconfigJsonDiagnosticsOptions: DiagnosticsOptions = {
|
||||
{
|
||||
uri: 'tsconfig.json',
|
||||
fileMatch: ['tsconfig.json'],
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: tsconfigSchema
|
||||
}
|
||||
schema: tsconfigSchema
|
||||
},
|
||||
{
|
||||
uri: 'import-map.json',
|
||||
fileMatch: ['import-map.json'],
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: importMapSchema
|
||||
}
|
||||
schema: importMapSchema
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{
|
||||
"imports": {
|
||||
"type": "object",
|
||||
"description": "Import map"
|
||||
}
|
||||
"additionalProperties": {"type": "string"}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ const Playground = ({
|
||||
try {
|
||||
setImportMap(JSON.parse(importMapRaw) as IImportMap)
|
||||
} catch (e) {
|
||||
setImportMap({ imports: {} })
|
||||
setImportMap({})
|
||||
}
|
||||
}
|
||||
if (!tsconfig) {
|
||||
|
||||
@@ -14,9 +14,7 @@ export interface IFiles {
|
||||
[key: string]: IFile
|
||||
}
|
||||
|
||||
export interface IImportMap {
|
||||
imports: Record<string, string>
|
||||
}
|
||||
export type IImportMap = Record<string, string>
|
||||
|
||||
export interface ITsconfig {
|
||||
compilerOptions: CompilerOptions
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user