mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Support define API (PR #3181)
This commit is contained in:
parent
76cf6ff76e
commit
04a6b1da6c
@ -1,6 +1,7 @@
|
||||
import * as component from './component'
|
||||
import * as userComponent from './user-component'
|
||||
import * as styledComponent from './styled-component'
|
||||
import * as define from './define'
|
||||
import * as description from './description'
|
||||
import * as feedsApis from './feeds/api'
|
||||
import BangumiCard from './feeds/BangumiCard.vue'
|
||||
@ -32,6 +33,7 @@ export const componentApis = {
|
||||
component,
|
||||
userComponent,
|
||||
styledComponent,
|
||||
define,
|
||||
description,
|
||||
switchOptions,
|
||||
launchBar: {
|
||||
|
||||
@ -5,7 +5,7 @@ module.exports = function (babel) {
|
||||
const { types } = babel
|
||||
return {
|
||||
visitor: {
|
||||
ExportNamedDeclaration(path, state) {
|
||||
ExportNamedDeclaration (path, state) {
|
||||
const { filename } = state.file.opts
|
||||
const isFromRegistry = filename.startsWith(nodePath.resolve('./registry'))
|
||||
const isEntryFile = nodePath.basename(filename) === 'index.ts'
|
||||
@ -17,11 +17,14 @@ module.exports = function (babel) {
|
||||
if (!['component', 'plugin'].includes(d.id?.name)) {
|
||||
return
|
||||
}
|
||||
if (d.init.type !== 'ObjectExpression') {
|
||||
const targetExpression = d.init.type === 'CallExpression' ? d.init.arguments[0] : d.init
|
||||
if (targetExpression.type !== 'ObjectExpression') {
|
||||
return
|
||||
}
|
||||
d.init.properties.push(types.objectProperty(types.identifier('commitHash'), types.stringLiteral(compilationInfo.commitHash)))
|
||||
d.init.properties.push(types.objectProperty(types.identifier('coreVersion'), types.stringLiteral(compilationInfo.version)))
|
||||
targetExpression.properties.push(...[
|
||||
types.objectProperty(types.identifier('commitHash'), types.stringLiteral(compilationInfo.commitHash)),
|
||||
types.objectProperty(types.identifier('coreVersion'), types.stringLiteral(compilationInfo.version)),
|
||||
])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user