diff --git a/eslint.config.js b/eslint.config.js index 19dd6bb34c..afafffce9f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -20,7 +20,7 @@ export default vuepress( '@typescript-eslint/no-non-null-assertion': 'off', 'no-underscore-dangle': [ 'warn', - { allow: ['_context', '_registeredComponents'] }, + { allow: ['_context', '_pageChunk', '_registeredComponents'] }, ], }, }, diff --git a/packages/client/src/setupGlobalComponents.ts b/packages/client/src/setupGlobalComponents.ts index 6c513cc98a..684f9d5b8a 100644 --- a/packages/client/src/setupGlobalComponents.ts +++ b/packages/client/src/setupGlobalComponents.ts @@ -5,9 +5,7 @@ import { ClientOnly, Content, RouteLink } from './components/index.js' * Register global built-in components */ export const setupGlobalComponents = (app: App): void => { - /* eslint-disable vue/match-component-file-name, vue/no-reserved-component-names */ app.component('ClientOnly', ClientOnly) app.component('Content', Content) app.component('RouteLink', RouteLink) - /* eslint-enable vue/match-component-file-name, vue/no-reserved-component-names */ } diff --git a/packages/client/src/setupGlobalComputed.ts b/packages/client/src/setupGlobalComputed.ts index 57197148a6..e258cb7673 100644 --- a/packages/client/src/setupGlobalComputed.ts +++ b/packages/client/src/setupGlobalComputed.ts @@ -48,7 +48,7 @@ export const setupGlobalComputed = ( __VUE_HMR_RUNTIME__.updatePageData = async (newPageData: PageData) => { const oldPageChunk = await routes.value[newPageData.path].loader() const newPageChunk = { comp: oldPageChunk.comp, data: newPageData } - routes.value[newPageData.path].loader = () => + routes.value[newPageData.path].loader = async () => Promise.resolve(newPageChunk) if ( newPageData.path === diff --git a/packages/client/src/types/clientConfig.ts b/packages/client/src/types/clientConfig.ts index 9b0a490bd9..ad2a73eca9 100644 --- a/packages/client/src/types/clientConfig.ts +++ b/packages/client/src/types/clientConfig.ts @@ -14,7 +14,7 @@ export interface ClientConfig { app: App router: Router siteData: SiteDataRef - }) => void | Promise + }) => Promise | void /** * A function to be called inside the setup function of vue app diff --git a/packages/core/src/app/createBuildApp.ts b/packages/core/src/app/createBuildApp.ts index 3be1e3e8e9..36830cbdf8 100644 --- a/packages/core/src/app/createBuildApp.ts +++ b/packages/core/src/app/createBuildApp.ts @@ -6,6 +6,6 @@ import { createBaseApp } from './createBaseApp.js' */ export const createBuildApp = (config: AppConfig): BuildApp => { const app = createBaseApp(config, true) as BuildApp - app.build = () => app.options.bundler.build(app) + app.build = async () => app.options.bundler.build(app) return app } diff --git a/packages/core/src/app/createDevApp.ts b/packages/core/src/app/createDevApp.ts index c611560e3e..59fe0f2ea0 100644 --- a/packages/core/src/app/createDevApp.ts +++ b/packages/core/src/app/createDevApp.ts @@ -6,6 +6,6 @@ import { createBaseApp } from './createBaseApp.js' */ export const createDevApp = (config: AppConfig): DevApp => { const app = createBaseApp(config, false) as DevApp - app.dev = () => app.options.bundler.dev(app) + app.dev = async () => app.options.bundler.dev(app) return app } diff --git a/packages/core/src/page/resolvePageLang.ts b/packages/core/src/page/resolvePageLang.ts index 1f3f49136a..3f2f243256 100644 --- a/packages/core/src/page/resolvePageLang.ts +++ b/packages/core/src/page/resolvePageLang.ts @@ -16,5 +16,6 @@ export const resolvePageLang = ({ if (isString(frontmatter.lang) && frontmatter.lang) { return frontmatter.lang } + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- unsafe indexed access return app.siteData.locales[pathLocale]?.lang ?? app.siteData.lang } diff --git a/packages/core/tests/app/resolveAppEnv.spec.ts b/packages/core/tests/app/resolveAppEnv.spec.ts index 13926aaa5d..6ba685baa6 100644 --- a/packages/core/tests/app/resolveAppEnv.spec.ts +++ b/packages/core/tests/app/resolveAppEnv.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import type { Bundler, Theme } from '../../src/index.js' +import type { Bundler } from '../../src/index.js' import { resolveAppEnv, resolveAppOptions } from '../../src/index.js' const TEST_CASES: [ @@ -10,7 +10,7 @@ const TEST_CASES: [ [ resolveAppOptions({ source: '/foo', - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }), false, @@ -25,7 +25,7 @@ const TEST_CASES: [ [ resolveAppOptions({ source: '/foo', - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, debug: true, }), @@ -41,7 +41,7 @@ const TEST_CASES: [ [ resolveAppOptions({ source: '/foo', - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }), true, diff --git a/packages/core/tests/app/resolveAppOptions.spec.ts b/packages/core/tests/app/resolveAppOptions.spec.ts index a79cec1d5a..442737587d 100644 --- a/packages/core/tests/app/resolveAppOptions.spec.ts +++ b/packages/core/tests/app/resolveAppOptions.spec.ts @@ -1,6 +1,6 @@ import { path, templateRenderer } from '@vuepress/utils' import { describe, expect, it } from 'vitest' -import type { Bundler, Theme } from '../../src/index.js' +import type { Bundler } from '../../src/index.js' import { resolveAppOptions } from '../../src/index.js' describe('core > app > resolveAppOptions', () => { @@ -10,7 +10,7 @@ describe('core > app > resolveAppOptions', () => { expect( resolveAppOptions({ source, - theme: { name: 'theme' } as Theme, + theme: { name: 'theme' }, bundler: { name: 'bundler' } as Bundler, }), ).toEqual({ diff --git a/packages/core/tests/app/resolveAppPages.spec.ts b/packages/core/tests/app/resolveAppPages.spec.ts index 877d910819..f394888238 100644 --- a/packages/core/tests/app/resolveAppPages.spec.ts +++ b/packages/core/tests/app/resolveAppPages.spec.ts @@ -1,14 +1,14 @@ import { createMarkdown } from '@vuepress/markdown' import { path } from '@vuepress/utils' import { describe, expect, it } from 'vitest' -import type { Bundler, Theme } from '../../src/index.js' +import type { Bundler } from '../../src/index.js' import { createBaseApp, resolveAppPages } from '../../src/index.js' describe('core > app > resolveAppPages', () => { it('should create two pages with default 404 page', async () => { const app = createBaseApp({ source: path.resolve(__dirname, '../__fixtures__/pages'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) app.markdown = createMarkdown() @@ -28,7 +28,7 @@ describe('core > app > resolveAppPages', () => { it('should create two pages with custom 404 page', async () => { const app = createBaseApp({ source: path.resolve(__dirname, '../__fixtures__/pages-with-404'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) app.markdown = createMarkdown() @@ -47,7 +47,7 @@ describe('core > app > resolveAppPages', () => { it('should process extendsPageOptions hook correctly', async () => { const app = createBaseApp({ source: path.resolve(__dirname, '../__fixtures__/pages-with-404'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) @@ -71,7 +71,7 @@ describe('core > app > resolveAppPages', () => { it('should process extendsPage hook correctly', async () => { const app = createBaseApp({ source: path.resolve(__dirname, '../__fixtures__/pages-with-404'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) diff --git a/packages/core/tests/app/resolveThemeInfo.spec.ts b/packages/core/tests/app/resolveThemeInfo.spec.ts index cc331816d6..631deb2e6a 100644 --- a/packages/core/tests/app/resolveThemeInfo.spec.ts +++ b/packages/core/tests/app/resolveThemeInfo.spec.ts @@ -1,55 +1,59 @@ import { importFileDefault, path } from '@vuepress/utils' import { describe, expect, it } from 'vitest' +import type { App, Bundler, Theme, ThemeObject } from '../../src/index.js' import { createBaseApp, resolveThemeInfo } from '../../src/index.js' -const fixtures = (...args: string[]) => +const fixtures = (...args: string[]): string => path.resolve(__dirname, '../__fixtures__/', ...args) -const createTestApp = async (themePath: string) => +const createTestApp = async (themePath: string): Promise => createBaseApp({ source: path.resolve(__dirname, 'fake-source'), theme: await importFileDefault(themePath), - bundler: {} as any, + bundler: {} as Bundler, }) -const themeEntryTypes = ['func', 'obj'] as const +const THEME_ENTRY_TYPES = ['func', 'obj'] as const -const getThemePlugin = async (themePath: string) => { - const theme = await importFileDefault(themePath) - return typeof theme === 'function' ? theme() : theme +const getThemePlugin = async ( + themePath: string, + app: App, +): Promise => { + const theme = await importFileDefault(themePath) + return typeof theme === 'function' ? theme(app) : theme } describe('core > app > resolveThemeInfo', () => { describe('plugins', () => { describe('should resolve theme info without plugins correctly', () => { - themeEntryTypes.forEach((item) => + THEME_ENTRY_TYPES.forEach((item) => { it(item, async () => { const themePath = fixtures(`themes/${item}-empty.js`) const app = await createTestApp(themePath) expect(resolveThemeInfo(app, app.options.theme).plugins).toEqual([ - await getThemePlugin(themePath), + await getThemePlugin(themePath, app), ]) - }), - ) + }) + }) }) describe('should resolve theme info with plugins correctly', () => { - themeEntryTypes.forEach((item) => + THEME_ENTRY_TYPES.forEach((item) => { it(item, async () => { const themePath = fixtures(`themes/${item}.js`) const app = await createTestApp(themePath) expect(resolveThemeInfo(app, app.options.theme).plugins).toEqual([ await importFileDefault(fixtures('plugins/obj.js')), - await getThemePlugin(themePath), + await getThemePlugin(themePath, app), ]) - }), - ) + }) + }) }) }) describe('extends', () => { describe('should resolve theme info with parent theme correctly', () => { - themeEntryTypes.forEach((item) => + THEME_ENTRY_TYPES.forEach((item) => { it(item, async () => { const themePath = fixtures(`themes/${item}-extends-parent.js`) const parentThemePath = fixtures(`themes/${item}.js`) @@ -58,19 +62,19 @@ describe('core > app > resolveThemeInfo', () => { expect(resolveThemeInfo(app, app.options.theme)).toEqual({ plugins: [ await importFileDefault(fixtures('plugins/obj.js')), - await getThemePlugin(parentThemePath), + await getThemePlugin(parentThemePath, app), await importFileDefault(fixtures('plugins/obj-foo.js')), - await getThemePlugin(themePath), + await getThemePlugin(themePath, app), ], templateBuild: `theme-${item}-extends-parent-template-build`, templateDev: `theme-${item}-template-dev`, }) - }), - ) + }) + }) }) describe('should resolve theme info with grandparent theme correctly', () => { - themeEntryTypes.forEach((item) => + THEME_ENTRY_TYPES.forEach((item) => { it(item, async () => { const themePath = fixtures(`themes/${item}-extends-grandparent.js`) const parentThemePath = fixtures(`themes/${item}-extends-parent.js`) @@ -80,17 +84,17 @@ describe('core > app > resolveThemeInfo', () => { expect(resolveThemeInfo(app, app.options.theme)).toEqual({ plugins: [ await importFileDefault(fixtures('plugins/obj.js')), - await getThemePlugin(grandparentThemePath), + await getThemePlugin(grandparentThemePath, app), await importFileDefault(fixtures('plugins/obj-foo.js')), - await getThemePlugin(parentThemePath), + await getThemePlugin(parentThemePath, app), await importFileDefault(fixtures('plugins/obj-bar.js')), - await getThemePlugin(themePath), + await getThemePlugin(themePath, app), ], templateBuild: `theme-${item}-extends-parent-template-build`, templateDev: `theme-${item}-extends-grandparent-template-dev`, }) - }), - ) + }) + }) }) }) }) diff --git a/packages/core/tests/page/inferPagePath.spec.ts b/packages/core/tests/page/inferPagePath.spec.ts index 887fb496c5..42eef99279 100644 --- a/packages/core/tests/page/inferPagePath.spec.ts +++ b/packages/core/tests/page/inferPagePath.spec.ts @@ -1,11 +1,11 @@ import { path } from '@vuepress/utils' import { describe, expect, it } from 'vitest' -import type { Bundler, Theme } from '../../src/index.js' +import type { Bundler } from '../../src/index.js' import { createBaseApp, inferPagePath } from '../../src/index.js' const app = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, locales: { '/': {}, @@ -16,7 +16,7 @@ const app = createBaseApp({ }) const appWithoutLocales = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) diff --git a/packages/core/tests/page/resolvePageChunkInfo.spec.ts b/packages/core/tests/page/resolvePageChunkInfo.spec.ts index e152bda7f5..19ec02eb03 100644 --- a/packages/core/tests/page/resolvePageChunkInfo.spec.ts +++ b/packages/core/tests/page/resolvePageChunkInfo.spec.ts @@ -1,11 +1,12 @@ import { path, sanitizeFileName } from '@vuepress/utils' import { describe, expect, it } from 'vitest' +import type { Bundler } from '../../src/index.js' import { createBaseApp, resolvePageChunkInfo } from '../../src/index.js' const app = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), theme: { name: 'test' }, - bundler: {} as any, + bundler: {} as Bundler, }) describe('core > page > resolvePageChunkInfo', () => { diff --git a/packages/core/tests/page/resolvePageHtmlInfo.spec.ts b/packages/core/tests/page/resolvePageHtmlInfo.spec.ts index 498fe9b717..61f04d5813 100644 --- a/packages/core/tests/page/resolvePageHtmlInfo.spec.ts +++ b/packages/core/tests/page/resolvePageHtmlInfo.spec.ts @@ -1,11 +1,11 @@ import { path } from '@vuepress/utils' import { describe, expect, it } from 'vitest' -import type { Bundler, Theme } from '../../src/index.js' +import type { Bundler } from '../../src/index.js' import { createBaseApp, resolvePageHtmlInfo } from '../../src/index.js' const app = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) diff --git a/packages/core/tests/page/resolvePageLang.spec.ts b/packages/core/tests/page/resolvePageLang.spec.ts index ebf5f19e29..8b50e3e096 100644 --- a/packages/core/tests/page/resolvePageLang.spec.ts +++ b/packages/core/tests/page/resolvePageLang.spec.ts @@ -1,11 +1,11 @@ import { path } from '@vuepress/utils' import { describe, expect, it } from 'vitest' -import type { Bundler, Theme } from '../../src/index.js' +import type { Bundler } from '../../src/index.js' import { createBaseApp, resolvePageLang } from '../../src/index.js' const app = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, lang: 'site-lang', locales: { diff --git a/packages/core/tests/pluginApi/createPluginApi.spec.ts b/packages/core/tests/pluginApi/createPluginApi.spec.ts index c1f8aa2e38..d7d68e7dec 100644 --- a/packages/core/tests/pluginApi/createPluginApi.spec.ts +++ b/packages/core/tests/pluginApi/createPluginApi.spec.ts @@ -1,11 +1,11 @@ import { path } from '@vuepress/utils' import { describe, expect, it, vi } from 'vitest' -import type { Bundler, HooksName, Theme } from '../../src/index.js' +import type { Bundler, HooksName } from '../../src/index.js' import { createBaseApp, createPluginApi } from '../../src/index.js' const app = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) diff --git a/packages/core/tests/pluginApi/normalizeAliasDefineHook.spec.ts b/packages/core/tests/pluginApi/normalizeAliasDefineHook.spec.ts index cb6b62f164..c7c9d05e80 100644 --- a/packages/core/tests/pluginApi/normalizeAliasDefineHook.spec.ts +++ b/packages/core/tests/pluginApi/normalizeAliasDefineHook.spec.ts @@ -1,11 +1,11 @@ import { path } from '@vuepress/utils' import { describe, expect, it, vi } from 'vitest' -import type { AliasDefineHook, Bundler, Theme } from '../../src/index.js' +import type { AliasDefineHook, Bundler } from '../../src/index.js' import { createBaseApp, normalizeAliasDefineHook } from '../../src/index.js' const app = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) diff --git a/packages/core/tests/pluginApi/normalizeClientFilesHook.spec.ts b/packages/core/tests/pluginApi/normalizeClientFilesHook.spec.ts index 9a4141b1c0..44cd647bc8 100644 --- a/packages/core/tests/pluginApi/normalizeClientFilesHook.spec.ts +++ b/packages/core/tests/pluginApi/normalizeClientFilesHook.spec.ts @@ -1,6 +1,6 @@ import { path } from '@vuepress/utils' import { describe, expect, it, vi } from 'vitest' -import type { Bundler, ClientConfigFileHook, Theme } from '../../src/index.js' +import type { Bundler, ClientConfigFileHook } from '../../src/index.js' import { createBaseApp, normalizeClientConfigFileHook, @@ -8,7 +8,7 @@ import { const app = createBaseApp({ source: path.resolve(__dirname, 'fake-source'), - theme: { name: 'test' } as Theme, + theme: { name: 'test' }, bundler: {} as Bundler, }) const CLIENT_CONFIG_FILE = path.resolve( diff --git a/packages/markdown/src/markdown.ts b/packages/markdown/src/markdown.ts index 88aeb05e83..bc2c0968b5 100644 --- a/packages/markdown/src/markdown.ts +++ b/packages/markdown/src/markdown.ts @@ -1,6 +1,18 @@ import { slugify as defaultSlugify } from '@mdit-vue/shared' import { logger } from '@vuepress/utils' import MarkdownIt from 'markdown-it' +import type { + AnchorPluginOptions, + AssetsPluginOptions, + EmojiPluginOptions, + FrontmatterPluginOptions, + HeadersPluginOptions, + ImportCodePluginOptions, + LinksPluginOptions, + SfcPluginOptions, + TocPluginOptions, + VPrePluginOptions, +} from './plugins.js' import { anchorPlugin, assetsPlugin, @@ -15,18 +27,6 @@ import { tocPlugin, vPrePlugin, } from './plugins.js' -import type { - AnchorPluginOptions, - AssetsPluginOptions, - EmojiPluginOptions, - FrontmatterPluginOptions, - HeadersPluginOptions, - ImportCodePluginOptions, - LinksPluginOptions, - SfcPluginOptions, - TocPluginOptions, - VPrePluginOptions, -} from './plugins.js' import type { Markdown, MarkdownOptions } from './types.js' /** @@ -83,7 +83,7 @@ export const createMarkdown = ({ md.use(assetsPlugin, assets) } - // process code fence + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- deprecation warning if (code) { logger.warn( `\`markdown.code\` option has been removed, please use '@vuepress/plugin-shiki' or '@vuepress/plugin-prismjs' instead.\n See https://v2.vuepress.vuejs.org/reference/config.html#markdown-code`, diff --git a/packages/markdown/src/plugins/importCodePlugin/importCodePlugin.ts b/packages/markdown/src/plugins/importCodePlugin/importCodePlugin.ts index 8196e0ee70..32ba3e2154 100644 --- a/packages/markdown/src/plugins/importCodePlugin/importCodePlugin.ts +++ b/packages/markdown/src/plugins/importCodePlugin/importCodePlugin.ts @@ -2,6 +2,7 @@ import type { PluginWithOptions } from 'markdown-it' import type { MarkdownEnv } from '../../types.js' import { createImportCodeBlockRule } from './createImportCodeBlockRule.js' import { resolveImportCode } from './resolveImportCode.js' +import type { ImportCodeTokenMeta } from './types.js' export interface ImportCodePluginOptions { /** @@ -28,14 +29,17 @@ export const importCodePlugin: PluginWithOptions = ( md.renderer.rules.import_code = ( tokens, idx, - options, + opts, env: MarkdownEnv, slf, ) => { const token = tokens[idx] // use imported code as token content - const { importFilePath, importCode } = resolveImportCode(token.meta, env) + const { importFilePath, importCode } = resolveImportCode( + token.meta as ImportCodeTokenMeta, + env, + ) token.content = importCode // extract imported files to env @@ -44,6 +48,6 @@ export const importCodePlugin: PluginWithOptions = ( } // render the import_code token as a fence token - return md.renderer.rules.fence!(tokens, idx, options, env, slf) + return md.renderer.rules.fence!(tokens, idx, opts, env, slf) } } diff --git a/packages/markdown/src/plugins/linksPlugin/linksPlugin.ts b/packages/markdown/src/plugins/linksPlugin/linksPlugin.ts index 5fb407656a..6da9f97fdc 100644 --- a/packages/markdown/src/plugins/linksPlugin/linksPlugin.ts +++ b/packages/markdown/src/plugins/linksPlugin/linksPlugin.ts @@ -75,9 +75,9 @@ export const linksPlugin: PluginWithOptions = ( // check if a link is an external link if (isLinkExternal(hrefLink, base)) { // set `externalAttrs` to current token - Object.entries(externalAttrs).forEach(([key, val]) => - token.attrSet(key, val), - ) + Object.entries(externalAttrs).forEach(([key, val]) => { + token.attrSet(key, val) + }) return } @@ -137,17 +137,17 @@ export const linksPlugin: PluginWithOptions = ( }) } - md.renderer.rules.link_open = (tokens, idx, options, env, self) => { + md.renderer.rules.link_open = (tokens, idx, opts, env: MarkdownEnv, self) => { handleLinkOpen(tokens, idx, env) - return self.renderToken(tokens, idx, options) + return self.renderToken(tokens, idx, opts) } - md.renderer.rules.link_close = (tokens, idx, options, _env, self) => { + md.renderer.rules.link_close = (tokens, idx, opts, _env, self) => { // convert ending tag of internal link if (hasOpenInternalLink) { hasOpenInternalLink = false tokens[idx].tag = internalTag } - return self.renderToken(tokens, idx, options) + return self.renderToken(tokens, idx, opts) } } diff --git a/packages/markdown/src/plugins/linksPlugin/resolvePaths.ts b/packages/markdown/src/plugins/linksPlugin/resolvePaths.ts index 0fe64373b9..d63b3a98e6 100644 --- a/packages/markdown/src/plugins/linksPlugin/resolvePaths.ts +++ b/packages/markdown/src/plugins/linksPlugin/resolvePaths.ts @@ -31,25 +31,23 @@ export const resolvePaths = ( } } // if raw path is relative + // if `filePathRelative` is available + else if (filePathRelative) { + // resolve relative path according to `filePathRelative` + relativePath = path.join( + // file path may contain non-ASCII characters + path.dirname(encodeURI(filePathRelative)), + rawPath, + ) + // resolve absolute path according to `base` + absolutePath = path.join(base, relativePath) + } + // if `filePathRelative` is not available else { - // if `filePathRelative` is available - if (filePathRelative) { - // resolve relative path according to `filePathRelative` - relativePath = path.join( - // file path may contain non-ASCII characters - path.dirname(encodeURI(filePathRelative)), - rawPath, - ) - // resolve absolute path according to `base` - absolutePath = path.join(base, relativePath) - } - // if `filePathRelative` is not available - else { - // remove leading './' - relativePath = rawPath.replace(/^(?:\.\/)?(.*)$/, '$1') - // just take relative link as absolute link - absolutePath = null - } + // remove leading './' + relativePath = rawPath.replace(/^(?:\.\/)?(.*)$/, '$1') + // just take relative link as absolute link + absolutePath = null } return {