diff --git a/babel.config.js b/babel.config.js index 87edd47c65..fa59afb6b9 100644 --- a/babel.config.js +++ b/babel.config.js @@ -3,6 +3,9 @@ module.exports = { 'test': { 'presets': [ ['@babel/preset-env', { 'targets': { 'node': 'current' }}] + ], + 'plugins': [ + '@babel/plugin-syntax-dynamic-import' ] } } diff --git a/package.json b/package.json index b7a5120cd3..ca677c54c0 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "remote-version": "node scripts/remote-version.js", "dev": "yarn tsc && yarn workspace docs dev", "build": "yarn tsc && yarn workspace docs build", + "view-info": "yarn tsc && yarn workspace docs view-info", "show-help": "yarn workspace docs show-help", "dev:blog": "yarn tsc && yarn workspace blog dev", "build:blog": "yarn tsc && yarn workspace blog build", diff --git a/packages/@vuepress/core/lib/build.js b/packages/@vuepress/core/lib/build.js deleted file mode 100644 index 23e49bbc96..0000000000 --- a/packages/@vuepress/core/lib/build.js +++ /dev/null @@ -1,197 +0,0 @@ -'use strict' - -module.exports = async function build (sourceDir, cliOptions = {}) { - process.env.NODE_ENV = 'production' - - const webpack = require('webpack') - const readline = require('readline') - const escape = require('escape-html') - - const { chalk, fs, path, logger, env, performance } = require('@vuepress/shared-utils') - const prepare = require('./prepare/index') - const createClientConfig = require('./webpack/createClientConfig') - const createServerConfig = require('./webpack/createServerConfig') - const { createBundleRenderer } = require('vue-server-renderer') - const { normalizeHeadTag, applyUserWebpackConfig } = require('./util/index') - - logger.wait('Extracting site metadata...') - const ctx = await prepare(sourceDir, cliOptions, true /* isProd */) - - const { outDir, cwd } = ctx - if (cwd === outDir) { - return console.error(logger.error(chalk.red('Unexpected option: outDir cannot be set to the current working directory.\n'), false)) - } - - await fs.emptyDir(outDir) - logger.debug('Dist directory: ' + chalk.gray(outDir)) - - let clientConfig = createClientConfig(ctx, cliOptions).toConfig() - let serverConfig = createServerConfig(ctx, cliOptions).toConfig() - - // apply user config... - const userConfig = ctx.siteConfig.configureWebpack - if (userConfig) { - clientConfig = applyUserWebpackConfig(userConfig, clientConfig, false) - serverConfig = applyUserWebpackConfig(userConfig, serverConfig, true) - } - - // compile! - const stats = await compile([clientConfig, serverConfig]) - - const serverBundle = require(path.resolve(outDir, 'manifest/server.json')) - const clientManifest = require(path.resolve(outDir, 'manifest/client.json')) - - // remove manifests after loading them. - await fs.remove(path.resolve(outDir, 'manifest')) - - // find and remove empty style chunk caused by - // https://github.com/webpack-contrib/mini-css-extract-plugin/issues/85 - // TODO remove when it's fixed - if (!clientConfig.devtool && (!clientConfig.plugins || - !clientConfig.plugins.some(p => - p instanceof webpack.SourceMapDevToolPlugin || - p instanceof webpack.EvalSourceMapDevToolPlugin - ))) { - await workaroundEmptyStyleChunk() - } - - // create server renderer using built manifests - const renderer = createBundleRenderer(serverBundle, { - clientManifest, - runInNewContext: false, - inject: false, - shouldPrefetch: ctx.siteConfig.shouldPrefetch || (() => true), - template: await fs.readFile(ctx.ssrTemplate, 'utf-8') - }) - - // pre-render head tags from user config - const userHeadTags = (ctx.siteConfig.head || []) - .map(renderHeadTag) - .join('\n ') - - // if the user does not have a custom 404.md, generate the theme's default - if (!ctx.pages.some(p => p.path === '/404.html')) { - ctx.addPage({ path: '/404.html' }) - } - - // render pages - logger.wait('Rendering static HTML...') - - const pagePaths = [] - for (const page of ctx.pages) { - pagePaths.push(await renderPage(page)) - } - - readline.clearLine(process.stdout, 0) - readline.cursorTo(process.stdout, 0) - - await ctx.pluginAPI.options.generated.apply(pagePaths) - - // DONE. - const relativeDir = path.relative(cwd, outDir) - logger.success(`Generated static files in ${chalk.cyan(relativeDir)}.`) - const { duration } = performance.stop() - logger.developer(`It took a total of ${chalk.cyan(`${duration}ms`)} to run the ${chalk.cyan('vuepress build')}.`) - console.log() - - // --- helpers --- - - function compile (config) { - return new Promise((resolve, reject) => { - webpack(config, (err, stats) => { - if (err) { - return reject(err) - } - if (stats.hasErrors()) { - stats.toJson().errors.forEach(err => { - console.error(err) - }) - reject(new Error(`Failed to compile with errors.`)) - return - } - if (env.isDebug && stats.hasWarnings()) { - stats.toJson().warnings.forEach(warning => { - console.warn(warning) - }) - } - resolve(stats.toJson({ modules: false })) - }) - }) - } - - function renderHeadTag (tag) { - const { tagName, attributes, innerHTML, closeTag } = normalizeHeadTag(tag) - return `<${tagName}${renderAttrs(attributes)}>${innerHTML}${closeTag ? `` : ``}` - } - - function renderAttrs (attrs = {}) { - const keys = Object.keys(attrs) - if (keys.length) { - return ' ' + keys.map(name => `${name}="${escape(attrs[name])}"`).join(' ') - } else { - return '' - } - } - - async function renderPage (page) { - const pagePath = page.path - readline.clearLine(process.stdout, 0) - readline.cursorTo(process.stdout, 0) - process.stdout.write(`Rendering page: ${pagePath}`) - - // #565 Avoid duplicate description meta at SSR. - const meta = (page.frontmatter && page.frontmatter.meta || []).filter(item => item.name !== 'description') - const pageMeta = renderPageMeta(meta) - - const context = { - url: pagePath, - userHeadTags, - pageMeta, - title: 'VuePress', - lang: 'en', - description: '' - } - - let html - try { - html = await renderer.renderToString(context) - } catch (e) { - console.error(logger.error(chalk.red(`Error rendering ${pagePath}:`), false)) - throw e - } - const filename = decodeURIComponent(pagePath.replace(/\/$/, '/index.html').replace(/^\//, '')) - const filePath = path.resolve(outDir, filename) - await fs.ensureDir(path.dirname(filePath)) - await fs.writeFile(filePath, html) - return filePath - } - - function renderPageMeta (meta) { - if (!meta) return '' - return meta.map(m => { - let res = ` { - res += ` ${key}="${escape(m[key])}"` - }) - return res + `>` - }).join('') - } - - async function workaroundEmptyStyleChunk () { - const styleChunk = stats.children[0].assets.find(a => { - return /styles\.\w{8}\.js$/.test(a.name) - }) - if (!styleChunk) return - const styleChunkPath = path.resolve(outDir, styleChunk.name) - const styleChunkContent = await fs.readFile(styleChunkPath, 'utf-8') - await fs.remove(styleChunkPath) - // prepend it to app.js. - // this is necessary for the webpack runtime to work properly. - const appChunk = stats.children[0].assets.find(a => { - return /app\.\w{8}\.js$/.test(a.name) - }) - const appChunkPath = path.resolve(outDir, appChunk.name) - const appChunkContent = await fs.readFile(appChunkPath, 'utf-8') - await fs.writeFile(appChunkPath, styleChunkContent + appChunkContent) - } -} diff --git a/packages/@vuepress/core/lib/app/app.js b/packages/@vuepress/core/lib/client/app.js similarity index 100% rename from packages/@vuepress/core/lib/app/app.js rename to packages/@vuepress/core/lib/client/app.js diff --git a/packages/@vuepress/core/lib/app/clientEntry.js b/packages/@vuepress/core/lib/client/clientEntry.js similarity index 100% rename from packages/@vuepress/core/lib/app/clientEntry.js rename to packages/@vuepress/core/lib/client/clientEntry.js diff --git a/packages/@vuepress/core/lib/app/components/ClientOnly.js b/packages/@vuepress/core/lib/client/components/ClientOnly.js similarity index 100% rename from packages/@vuepress/core/lib/app/components/ClientOnly.js rename to packages/@vuepress/core/lib/client/components/ClientOnly.js diff --git a/packages/@vuepress/core/lib/app/components/Content.js b/packages/@vuepress/core/lib/client/components/Content.js similarity index 100% rename from packages/@vuepress/core/lib/app/components/Content.js rename to packages/@vuepress/core/lib/client/components/Content.js diff --git a/packages/@vuepress/core/lib/app/components/ContentSlotsDistributor.js b/packages/@vuepress/core/lib/client/components/ContentSlotsDistributor.js similarity index 100% rename from packages/@vuepress/core/lib/app/components/ContentSlotsDistributor.js rename to packages/@vuepress/core/lib/client/components/ContentSlotsDistributor.js diff --git a/packages/@vuepress/core/lib/app/components/GlobalLayout.vue b/packages/@vuepress/core/lib/client/components/GlobalLayout.vue similarity index 100% rename from packages/@vuepress/core/lib/app/components/GlobalLayout.vue rename to packages/@vuepress/core/lib/client/components/GlobalLayout.vue diff --git a/packages/@vuepress/core/lib/app/components/HeaderList.vue b/packages/@vuepress/core/lib/client/components/HeaderList.vue similarity index 100% rename from packages/@vuepress/core/lib/app/components/HeaderList.vue rename to packages/@vuepress/core/lib/client/components/HeaderList.vue diff --git a/packages/@vuepress/core/lib/app/components/NotFound.vue b/packages/@vuepress/core/lib/client/components/NotFound.vue similarity index 100% rename from packages/@vuepress/core/lib/app/components/NotFound.vue rename to packages/@vuepress/core/lib/client/components/NotFound.vue diff --git a/packages/@vuepress/core/lib/app/components/OutboundLink.vue b/packages/@vuepress/core/lib/client/components/OutboundLink.vue similarity index 100% rename from packages/@vuepress/core/lib/app/components/OutboundLink.vue rename to packages/@vuepress/core/lib/client/components/OutboundLink.vue diff --git a/packages/@vuepress/core/lib/app/components/TOC.vue b/packages/@vuepress/core/lib/client/components/TOC.vue similarity index 100% rename from packages/@vuepress/core/lib/app/components/TOC.vue rename to packages/@vuepress/core/lib/client/components/TOC.vue diff --git a/packages/@vuepress/core/lib/app/dataMixin.js b/packages/@vuepress/core/lib/client/dataMixin.js similarity index 89% rename from packages/@vuepress/core/lib/app/dataMixin.js rename to packages/@vuepress/core/lib/client/dataMixin.js index 7e0acc5a45..8082156ec1 100644 --- a/packages/@vuepress/core/lib/app/dataMixin.js +++ b/packages/@vuepress/core/lib/client/dataMixin.js @@ -1,8 +1,8 @@ /* global VUEPRESS_TEMP_PATH */ -import Vue from 'vue' +import GLobalVue from 'vue' -export default function dataMixin (I18n, siteData) { +export default function dataMixin (I18n, siteData, Vue = GLobalVue) { prepare(siteData) Vue.$vuepress.$set('siteData', siteData) diff --git a/packages/@vuepress/core/lib/app/index.dev.html b/packages/@vuepress/core/lib/client/index.dev.html similarity index 100% rename from packages/@vuepress/core/lib/app/index.dev.html rename to packages/@vuepress/core/lib/client/index.dev.html diff --git a/packages/@vuepress/core/lib/app/index.ssr.html b/packages/@vuepress/core/lib/client/index.ssr.html similarity index 100% rename from packages/@vuepress/core/lib/app/index.ssr.html rename to packages/@vuepress/core/lib/client/index.ssr.html diff --git a/packages/@vuepress/core/lib/app/plugins/Store.d.ts b/packages/@vuepress/core/lib/client/plugins/Store.d.ts similarity index 100% rename from packages/@vuepress/core/lib/app/plugins/Store.d.ts rename to packages/@vuepress/core/lib/client/plugins/Store.d.ts diff --git a/packages/@vuepress/core/lib/app/plugins/Store.js b/packages/@vuepress/core/lib/client/plugins/Store.js similarity index 100% rename from packages/@vuepress/core/lib/app/plugins/Store.js rename to packages/@vuepress/core/lib/client/plugins/Store.js diff --git a/packages/@vuepress/core/lib/app/plugins/VuePress.d.ts b/packages/@vuepress/core/lib/client/plugins/VuePress.d.ts similarity index 100% rename from packages/@vuepress/core/lib/app/plugins/VuePress.d.ts rename to packages/@vuepress/core/lib/client/plugins/VuePress.d.ts diff --git a/packages/@vuepress/core/lib/app/plugins/VuePress.js b/packages/@vuepress/core/lib/client/plugins/VuePress.js similarity index 100% rename from packages/@vuepress/core/lib/app/plugins/VuePress.js rename to packages/@vuepress/core/lib/client/plugins/VuePress.js diff --git a/packages/@vuepress/core/lib/app/redirect.js b/packages/@vuepress/core/lib/client/redirect.js similarity index 100% rename from packages/@vuepress/core/lib/app/redirect.js rename to packages/@vuepress/core/lib/client/redirect.js diff --git a/packages/@vuepress/core/lib/app/root-mixins/updateMeta.js b/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js similarity index 100% rename from packages/@vuepress/core/lib/app/root-mixins/updateMeta.js rename to packages/@vuepress/core/lib/client/root-mixins/updateMeta.js diff --git a/packages/@vuepress/core/lib/app/serverEntry.js b/packages/@vuepress/core/lib/client/serverEntry.js similarity index 100% rename from packages/@vuepress/core/lib/app/serverEntry.js rename to packages/@vuepress/core/lib/client/serverEntry.js diff --git a/packages/@vuepress/core/lib/app/style/config.styl b/packages/@vuepress/core/lib/client/style/config.styl similarity index 100% rename from packages/@vuepress/core/lib/app/style/config.styl rename to packages/@vuepress/core/lib/client/style/config.styl diff --git a/packages/@vuepress/core/lib/app/util.js b/packages/@vuepress/core/lib/client/util.js similarity index 100% rename from packages/@vuepress/core/lib/app/util.js rename to packages/@vuepress/core/lib/client/util.js diff --git a/packages/@vuepress/core/lib/dev.js b/packages/@vuepress/core/lib/dev.js deleted file mode 100644 index c0b728c0e9..0000000000 --- a/packages/@vuepress/core/lib/dev.js +++ /dev/null @@ -1,207 +0,0 @@ -'use strict' - -module.exports = async (sourceDir, cliOptions = {}, ctx) => { - const { server, host, port } = await prepareServer(sourceDir, cliOptions, ctx) - server.listen(port, host, err => { - if (err) { - console.log(err) - } - }) -} - -module.exports.prepare = prepareServer - -async function prepareServer (sourceDir, cliOptions = {}, context) { - const WebpackDevServer = require('webpack-dev-server') - const { path } = require('@vuepress/shared-utils') - const webpack = require('webpack') - const chokidar = require('chokidar') - - const prepare = require('./prepare/index') - const { chalk, fs, logger } = require('@vuepress/shared-utils') - const HeadPlugin = require('./webpack/HeadPlugin') - const DevLogPlugin = require('./webpack/DevLogPlugin') - const createClientConfig = require('./webpack/createClientConfig') - const { applyUserWebpackConfig } = require('./util/index') - const { frontmatterEmitter } = require('@vuepress/markdown-loader') - - const ctx = context || await prepare(sourceDir, cliOptions, false /* isProd */) - - // setup watchers to update options and dynamically generated files - const update = (reason) => { - console.log(`Reload due to ${reason}`) - ctx.pluginAPI.options.updated.syncApply() - prepare(sourceDir, cliOptions, false /* isProd */).catch(err => { - console.error(logger.error(chalk.red(err.stack), false)) - }) - } - - // Curry update handler by update type - const spawnUpdate = updateType => file => { - const target = path.join(sourceDir, file) - // Bust cache. - delete require.cache[target] - update(`${chalk.red(updateType)} ${chalk.cyan(file)}`) - } - - // watch add/remove of files - const pagesWatcher = chokidar.watch([ - '**/*.md', - '.vuepress/components/**/*.vue' - ], { - cwd: sourceDir, - ignored: ['.vuepress/**/*.md', 'node_modules'], - ignoreInitial: true - }) - pagesWatcher.on('add', spawnUpdate('add')) - pagesWatcher.on('unlink', spawnUpdate('unlink')) - pagesWatcher.on('addDir', spawnUpdate('addDir')) - pagesWatcher.on('unlinkDir', spawnUpdate('unlinkDir')) - - const watchFiles = [ - '.vuepress/config.js', - '.vuepress/config.yml', - '.vuepress/config.toml' - ].concat( - ( - ctx.siteConfig.extraWatchFiles || [] - ).map(file => normalizeWatchFilePath(file, ctx.sourceDir)) - ) - - logger.debug('watchFiles', watchFiles) - - // watch config file - const configWatcher = chokidar.watch(watchFiles, { - cwd: sourceDir, - ignoreInitial: true - }) - configWatcher.on('change', spawnUpdate('change')) - - // also listen for frontmatter changes from markdown files - frontmatterEmitter.on('update', () => update('frontmatter or headers change')) - - // resolve webpack config - let config = createClientConfig(ctx) - - config - .plugin('html') - // using a fork of html-webpack-plugin to avoid it requiring webpack - // internals from an incompatible version. - .use(require('vuepress-html-webpack-plugin'), [{ - template: ctx.devTemplate - }]) - - config - .plugin('site-data') - .use(HeadPlugin, [{ - tags: ctx.siteConfig.head || [] - }]) - - const port = await resolvePort(cliOptions.port || ctx.siteConfig.port) - const { host, displayHost } = await resolveHost(cliOptions.host || ctx.siteConfig.host) - - // debug in a running dev process. - process.stdin - && process.stdin.on('data', chunk => { - const parsed = chunk.toString('utf-8').trim() - if (parsed === '*') { - console.log(Object.keys(ctx)) - } - if (ctx[parsed]) { - console.log(ctx[parsed]) - } - }) - - config - .plugin('vuepress-log') - .use(DevLogPlugin, [{ - port, - displayHost, - publicPath: ctx.base - }]) - - config = config.toConfig() - const userConfig = ctx.siteConfig.configureWebpack - if (userConfig) { - config = applyUserWebpackConfig(userConfig, config, false /* isServer */) - } - - const contentBase = path.resolve(sourceDir, '.vuepress/public') - - const serverConfig = Object.assign({ - disableHostCheck: true, - compress: true, - clientLogLevel: 'error', - hot: true, - quiet: true, - headers: { - 'access-control-allow-origin': '*' - }, - open: cliOptions.open, - publicPath: ctx.base, - watchOptions: { - ignored: [ - /node_modules/, - `!${ctx.tempPath}/**` - ] - }, - historyApiFallback: { - disableDotRule: true, - rewrites: [ - { from: /./, to: path.posix.join(ctx.base, 'index.html') } - ] - }, - overlay: false, - host, - contentBase, - before (app, server) { - if (fs.existsSync(contentBase)) { - app.use(ctx.base, require('express').static(contentBase)) - } - - ctx.pluginAPI.options.beforeDevServer.syncApply(app, server) - }, - after (app, server) { - ctx.pluginAPI.options.afterDevServer.syncApply(app, server) - } - }, ctx.siteConfig.devServer || {}) - - WebpackDevServer.addDevServerEntrypoints(config, serverConfig) - - const compiler = webpack(config) - const server = new WebpackDevServer(compiler, serverConfig) - - return { - server, - host, - port, - ctx - } -} - -function resolveHost (host) { - const defaultHost = 'localhost' - host = host || defaultHost - const displayHost = host === defaultHost - ? 'localhost' - : host - return { - displayHost, - host - } -} - -async function resolvePort (port) { - const portfinder = require('portfinder') - portfinder.basePort = parseInt(port) || 8080 - port = await portfinder.getPortPromise() - return port -} - -function normalizeWatchFilePath (filepath, baseDir) { - const { isAbsolute, relative } = require('path') - if (isAbsolute(filepath)) { - return relative(baseDir, filepath) - } - return filepath -} diff --git a/packages/@vuepress/core/lib/index.js b/packages/@vuepress/core/lib/index.js index 43a6d0124b..9051524575 100644 --- a/packages/@vuepress/core/lib/index.js +++ b/packages/@vuepress/core/lib/index.js @@ -1,5 +1,26 @@ 'use strict' -exports.dev = require('./dev') -exports.build = require('./build') +const App = require('./node/App') +const { logger } = require('@vuepress/shared-utils') + +function createApp (options) { + logger.wait('Extracting site metadata...') + return new App(options) +} + +async function dev (options) { + const app = createApp(options) + await app.process() + await app.dev() +} + +async function build (options) { + const app = createApp(options) + await app.process() + await app.build() +} + +exports.createApp = createApp +exports.dev = dev +exports.build = build exports.eject = require('./eject') diff --git a/packages/@vuepress/core/lib/prepare/AppContext.js b/packages/@vuepress/core/lib/node/App.js similarity index 73% rename from packages/@vuepress/core/lib/prepare/AppContext.js rename to packages/@vuepress/core/lib/node/App.js index e7d71bb51a..906316f2ef 100755 --- a/packages/@vuepress/core/lib/prepare/AppContext.js +++ b/packages/@vuepress/core/lib/node/App.js @@ -16,18 +16,21 @@ const { const Page = require('./Page') const ClientComputedMixin = require('./ClientComputedMixin') -const PluginAPI = require('../plugin-api/index') +const PluginAPI = require('./plugin-api') +const DevProcess = require('./dev') +const BuildProcess = require('./build') +const createTemp = require('./createTemp') /** - * Expose AppContext. + * Expose VuePressApp. */ -module.exports = class AppContext { +module.exports = class App { static getInstance (...args) { - if (!AppContext._instance) { - AppContext._instance = new AppContext(...args) + if (!App._instance) { + App._instance = new App(...args) } - return AppContext._instance + return App._instance } /** @@ -35,24 +38,23 @@ module.exports = class AppContext { * * @param {string} sourceDir * @param {{ - * isProd: boolean, * plugins: pluginsConfig, * theme: themeNameConfig * temp: string * }} options */ - constructor (sourceDir, cliOptions = {}, isProd) { - logger.debug('sourceDir', sourceDir) - this.sourceDir = sourceDir - this.cliOptions = cliOptions - this.isProd = isProd + constructor (options = {}) { + this.options = options + this.sourceDir = this.options.sourceDir || path.join(__dirname, 'docs.fallback') + logger.debug('sourceDir', this.sourceDir) - const { tempPath, writeTemp } = createTemp(cliOptions.temp) + const { tempPath, writeTemp } = createTemp(options.temp) this.tempPath = tempPath this.writeTemp = writeTemp - this.vuepressDir = path.resolve(sourceDir, '.vuepress') + this.vuepressDir = path.resolve(this.sourceDir, '.vuepress') + this.libDir = path.join(__dirname, '../') } /** @@ -63,9 +65,14 @@ module.exports = class AppContext { */ resolveConfigAndInitialize () { - this.siteConfig = loadConfig(this.vuepressDir) - if (isFunction(this.siteConfig)) { - this.siteConfig = this.siteConfig(this) + if (this.options.siteConfig) { + this.siteConfig = this.options.siteConfig + } else { + let siteConfig = loadConfig(this.vuepressDir) + if (isFunction(siteConfig)) { + siteConfig = siteConfig(this) + } + this.siteConfig = siteConfig } // TODO custom cwd. @@ -74,7 +81,7 @@ module.exports = class AppContext { this.base = this.siteConfig.base || '/' this.themeConfig = this.siteConfig.themeConfig || {} - const rawOutDir = this.cliOptions.dest || this.siteConfig.dest + const rawOutDir = this.options.dest || this.siteConfig.dest this.outDir = rawOutDir ? require('path').resolve(this.cwd, rawOutDir) : require('path').resolve(this.sourceDir, '.vuepress/dist') @@ -92,7 +99,6 @@ module.exports = class AppContext { async process () { this.resolveConfigAndInitialize() - this.resolveCacheLoaderOptions() this.normalizeHeadTagUrls() this.themeAPI = loadTheme(this) this.resolveTemplates() @@ -105,18 +111,18 @@ module.exports = class AppContext { this.markdown = createMarkdown(this) await this.resolvePages() - await this.pluginAPI.options.additionalPages.apply(this) + + await this.pluginAPI.applyAsyncOption('additionalPages', this) await Promise.all( - this.pluginAPI.options.additionalPages.appliedValues.map(async (options) => { + this.pluginAPI.getOption('additionalPages').appliedValues.map(async (options) => { await this.addPage(options) }) ) - - await this.pluginAPI.options.ready.apply() + await this.pluginAPI.applyAsyncOption('ready') await Promise.all([ - this.pluginAPI.options.clientDynamicModules.apply(this), - this.pluginAPI.options.enhanceAppFiles.apply(this), - this.pluginAPI.options.globalUIComponents.apply(this) + this.pluginAPI.applyAsyncOption('clientDynamicModules', this), + this.pluginAPI.applyAsyncOption('enhanceAppFiles', this), + this.pluginAPI.applyAsyncOption('globalUIComponents', this) ]) } @@ -138,17 +144,17 @@ module.exports = class AppContext { this.pluginAPI // internl core plugins - .use(require('../internal-plugins/siteData')) - .use(require('../internal-plugins/routes')) - .use(require('../internal-plugins/rootMixins')) - .use(require('../internal-plugins/enhanceApp')) - .use(require('../internal-plugins/palette')) - .use(require('../internal-plugins/style')) - .use(require('../internal-plugins/layoutComponents')) - .use(require('../internal-plugins/pageComponents')) - .use(require('../internal-plugins/transformModule')) - .use(require('../internal-plugins/dataBlock')) - .use(require('../internal-plugins/frontmatterBlock')) + .use(require('./internal-plugins/siteData')) + .use(require('./internal-plugins/routes')) + .use(require('./internal-plugins/rootMixins')) + .use(require('./internal-plugins/enhanceApp')) + .use(require('./internal-plugins/palette')) + .use(require('./internal-plugins/style')) + .use(require('./internal-plugins/layoutComponents')) + .use(require('./internal-plugins/pageComponents')) + .use(require('./internal-plugins/transformModule')) + .use(require('./internal-plugins/dataBlock')) + .use(require('./internal-plugins/frontmatterBlock')) .use('@vuepress/container', { type: 'slot', before: info => `