mirror of https://github.com/vuejs/vitepress
close #645 Co-authored-by: Kia King Ishii <kia.king.08@gmail.com>pull/672/head
parent
bae47f7082
commit
a0f81c9f9d
@ -1,10 +0,0 @@
|
||||
import path from 'path'
|
||||
|
||||
export default {
|
||||
resolve: {
|
||||
alias: {
|
||||
node: path.resolve(__dirname, '../src/node'),
|
||||
client: path.resolve(__dirname, '../src/client')
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import { dirname, resolve } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
const dir = dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
node: resolve(dir, '../src/node'),
|
||||
client: resolve(dir, '../src/client')
|
||||
}
|
||||
},
|
||||
test: {
|
||||
globals: true
|
||||
}
|
||||
})
|
@ -1,53 +0,0 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
|
||||
"projectFolder": "./src/client",
|
||||
|
||||
"mainEntryPointFilePath": "./dist/temp/index.d.ts",
|
||||
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"publicTrimmedFilePath": "./dist/client/index.d.ts"
|
||||
},
|
||||
|
||||
"apiReport": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"docModel": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"tsdocMetadata": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"messages": {
|
||||
"compilerMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
}
|
||||
},
|
||||
|
||||
"extractorMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning",
|
||||
"addToApiReportFile": true
|
||||
},
|
||||
|
||||
"ae-missing-release-tag": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
},
|
||||
|
||||
"tsdocMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
},
|
||||
|
||||
"tsdoc-undefined-tag": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
|
||||
"projectFolder": "./src/node",
|
||||
|
||||
"mainEntryPointFilePath": "./dist/temp/index.d.ts",
|
||||
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"publicTrimmedFilePath": "./dist/node/index.d.ts"
|
||||
},
|
||||
|
||||
"apiReport": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"docModel": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"tsdocMetadata": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"messages": {
|
||||
"compilerMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
}
|
||||
},
|
||||
|
||||
"extractorMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning",
|
||||
"addToApiReportFile": true
|
||||
},
|
||||
|
||||
"ae-missing-release-tag": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
},
|
||||
|
||||
"tsdocMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
},
|
||||
|
||||
"tsdoc-undefined-tag": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('../dist/node/cli')
|
||||
import('../dist/node/cli.js')
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,109 @@
|
||||
import { RollupOptions, defineConfig } from 'rollup'
|
||||
import { promises as fs } from 'fs'
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import esbuild from 'rollup-plugin-esbuild'
|
||||
import json from '@rollup/plugin-json'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import dts from 'rollup-plugin-dts'
|
||||
import alias from '@rollup/plugin-alias'
|
||||
import { resolve } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import pkg from './package.json'
|
||||
|
||||
const DEV = !!process.env.DEV
|
||||
const PROD = !DEV
|
||||
|
||||
const ROOT = fileURLToPath(import.meta.url)
|
||||
const r = (p: string) => resolve(ROOT, '..', p)
|
||||
|
||||
const external = [...Object.keys(pkg.dependencies), 'buffer', 'punycode']
|
||||
|
||||
const plugins = [
|
||||
alias({
|
||||
entries: {
|
||||
'readable-stream': 'stream'
|
||||
}
|
||||
}),
|
||||
replace({
|
||||
// polyfill broken browser check from bundled deps
|
||||
'navigator.userAgentData': 'undefined',
|
||||
'navigator.userAgent': 'undefined',
|
||||
preventAssignment: true
|
||||
}),
|
||||
commonjs(),
|
||||
nodeResolve(),
|
||||
esbuild({ target: 'node14' }),
|
||||
json()
|
||||
]
|
||||
|
||||
const esmBuild: RollupOptions = {
|
||||
input: [r('src/node/index.ts'), r('src/node/cli.ts')],
|
||||
output: {
|
||||
format: 'esm',
|
||||
entryFileNames: `[name].js`,
|
||||
chunkFileNames: 'serve-[hash].js',
|
||||
dir: r('dist/node')
|
||||
},
|
||||
external,
|
||||
plugins,
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code !== 'EVAL') warn(warning)
|
||||
}
|
||||
}
|
||||
|
||||
const cjsBuild: RollupOptions = {
|
||||
input: [r('src/node/index.ts'), r('src/node/cli.ts')],
|
||||
output: {
|
||||
format: 'cjs',
|
||||
dir: r('dist/node-cjs'),
|
||||
entryFileNames: `[name].cjs`,
|
||||
chunkFileNames: 'serve-[hash].cjs'
|
||||
},
|
||||
external,
|
||||
plugins,
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code !== 'EVAL') warn(warning)
|
||||
}
|
||||
}
|
||||
|
||||
const nodeTypes: RollupOptions = {
|
||||
input: r('src/node/index.ts'),
|
||||
output: {
|
||||
format: 'esm',
|
||||
file: 'dist/node/index.d.ts'
|
||||
},
|
||||
plugins: [dts()]
|
||||
}
|
||||
|
||||
const clientTypes: RollupOptions = {
|
||||
input: r('dist/client-types/index.d.ts'),
|
||||
output: {
|
||||
format: 'esm',
|
||||
file: 'dist/client/index.d.ts'
|
||||
},
|
||||
plugins: [
|
||||
dts(),
|
||||
{
|
||||
name: 'cleanup',
|
||||
async closeBundle() {
|
||||
if (PROD) {
|
||||
await fs.rm(r('dist/client-types'), { recursive: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const config = defineConfig([])
|
||||
|
||||
config.push(esmBuild)
|
||||
|
||||
if (PROD) {
|
||||
config.push(cjsBuild)
|
||||
}
|
||||
|
||||
config.push(nodeTypes)
|
||||
config.push(clientTypes)
|
||||
|
||||
export default config
|
@ -1,11 +1,11 @@
|
||||
const fs = require('fs-extra')
|
||||
const glob = require('globby')
|
||||
import { copy } from 'fs-extra'
|
||||
import fg from 'fast-glob'
|
||||
|
||||
function toDest(file) {
|
||||
return file.replace(/^src\//, 'dist/')
|
||||
}
|
||||
|
||||
glob.sync('src/client/**').forEach((file) => {
|
||||
fg.sync('src/client/**').forEach((file) => {
|
||||
if (/(\.ts|tsconfig\.json)$/.test(file)) return
|
||||
fs.copy(file, toDest(file))
|
||||
copy(file, toDest(file))
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
const fs = require('fs-extra')
|
||||
const glob = require('globby')
|
||||
import { copy } from 'fs-extra'
|
||||
import fg from 'fast-glob'
|
||||
|
||||
glob.sync('src/shared/**/*.ts').forEach((file) => {
|
||||
fs.copy(file, file.replace(/^src\/shared\//, 'src/node/'))
|
||||
fs.copy(file, file.replace(/^src\/shared\//, 'src/client/'))
|
||||
fg.sync('src/shared/**/*.ts').map(async (file) => {
|
||||
await copy(file, file.replace(/^src\/shared\//, 'src/node/'))
|
||||
await copy(file, file.replace(/^src\/shared\//, 'src/client/'))
|
||||
})
|
||||
|
@ -1,35 +0,0 @@
|
||||
import { defineConfig } from 'rollup'
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import esbuild from 'rollup-plugin-esbuild'
|
||||
import json from '@rollup/plugin-json'
|
||||
import alias from '@rollup/plugin-alias'
|
||||
import { resolve } from 'path'
|
||||
|
||||
const r = (p) => resolve(__dirname, '../', p)
|
||||
const pkg = require('../package.json')
|
||||
|
||||
export default defineConfig({
|
||||
input: [r('src/node/index.ts'), r('src/node/cli.ts')],
|
||||
output: {
|
||||
format: 'cjs',
|
||||
dir: r('dist/node')
|
||||
},
|
||||
external: [...Object.keys(pkg.dependencies), 'buffer', 'punycode'],
|
||||
plugins: [
|
||||
alias({
|
||||
entries: {
|
||||
'readable-stream': 'stream'
|
||||
}
|
||||
}),
|
||||
commonjs(),
|
||||
nodeResolve(),
|
||||
esbuild({
|
||||
target: 'node12'
|
||||
}),
|
||||
json()
|
||||
],
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code !== 'EVAL') warn(warning)
|
||||
}
|
||||
})
|
@ -1,12 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["ESNext"]
|
||||
"noUnusedLocals": true,
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["ESNext", "DOM"]
|
||||
},
|
||||
"include": ["../types/shared.d.ts"]
|
||||
"exclude": [
|
||||
"**/node_modules/**",
|
||||
"**/dist/**"
|
||||
]
|
||||
}
|
Loading…
Reference in new issue