|
@ -1,8 +1,13 @@ |
|
|
|
|
|
import np from 'path' |
|
|
|
|
|
import nfs from 'fs' |
|
|
import { imba } from 'vite-plugin-imba'; |
|
|
import { imba } from 'vite-plugin-imba'; |
|
|
import { resolve } from 'path' |
|
|
import { resolve } from 'path' |
|
|
import { defineConfig } from 'vite'; |
|
|
import { defineConfig } from 'vite'; |
|
|
import { name } from './package.json' |
|
|
import { name } from './package.json' |
|
|
|
|
|
|
|
|
|
|
|
function file() { return np.join(__dirname, './src/views.json') } |
|
|
|
|
|
|
|
|
|
|
|
let viewsList = [] |
|
|
let viewPaths = {} // view: [path]
|
|
|
let viewPaths = {} // view: [path]
|
|
|
let pathViews = {} // path: [view]
|
|
|
let pathViews = {} // path: [view]
|
|
|
function duplicate(obj){ return JSON.parse(JSON.stringify(obj)) } |
|
|
function duplicate(obj){ return JSON.parse(JSON.stringify(obj)) } |
|
@ -19,6 +24,7 @@ function proRouterViews() { |
|
|
order: 'pre', |
|
|
order: 'pre', |
|
|
handler(src, id) { |
|
|
handler(src, id) { |
|
|
if (/\.imba$/.test(id)) { |
|
|
if (/\.imba$/.test(id)) { |
|
|
|
|
|
let modified = false |
|
|
let viewRegExp = /tag view-((\w|\S)+)( |\n)/g |
|
|
let viewRegExp = /tag view-((\w|\S)+)( |\n)/g |
|
|
let result = null |
|
|
let result = null |
|
|
let views_str = "" |
|
|
let views_str = "" |
|
@ -36,23 +42,28 @@ function proRouterViews() { |
|
|
paths.push(id) |
|
|
paths.push(id) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(paths[0] == id){ |
|
|
if((paths[0] == id) && !viewsList.includes(view)){ |
|
|
views_str += "Views.push(\""+ view +"\");" |
|
|
viewsList.push(view) |
|
|
|
|
|
modified = true |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
missingDeclarations.forEach(function(view){ |
|
|
missingDeclarations.forEach(function(view){ |
|
|
let paths = viewPaths[view] ||= [] |
|
|
let paths = viewPaths[view] ||= [] |
|
|
if((paths[0] == id) && (paths.length > 1)){ |
|
|
if(!((paths[0] == id) && (paths.length > 1))){ |
|
|
views_str += "Views.push(\""+ view +"\");" |
|
|
console.log(2) |
|
|
} else { |
|
|
|
|
|
paths = without(id, paths) |
|
|
paths = without(id, paths) |
|
|
views = without(view, views) |
|
|
views = without(view, views) |
|
|
|
|
|
viewsList = without(view, viewsList) |
|
|
|
|
|
modified = true |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
return { code: views_str+src, map: null } |
|
|
if(modified) |
|
|
|
|
|
nfs.writeFileSync(file(), JSON.stringify(viewsList)) |
|
|
|
|
|
|
|
|
|
|
|
return { moduleSideEffects: modified } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|