build: tsdv
This commit is contained in:
parent
053018d090
commit
1e99e257da
183
norm.config.mjs
183
norm.config.mjs
|
@ -1,183 +0,0 @@
|
|||
// @ts-check
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
import {
|
||||
defineConfig,
|
||||
defineProjectConfig,
|
||||
mergeProjectConfig,
|
||||
vite,
|
||||
} from '@norm/cli'
|
||||
import { preprocess } from 'svelte/compiler'
|
||||
import glob from 'fast-glob'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
import sveltePreprocess from 'svelte-preprocess'
|
||||
import { createVuePlugin } from './packages/vue/plugin.mjs'
|
||||
import vue from './packages/vue-next/plugin.mjs'
|
||||
import { resolveModule } from 'local-pkg'
|
||||
import { dirname } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
// https://stackoverflow.com/a/50052194
|
||||
export const rootDir = dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const sveltePreprocessor = sveltePreprocess({
|
||||
typescript: true,
|
||||
// https://github.com/sveltejs/svelte/issues/189#issuecomment-586142198
|
||||
replace: [
|
||||
[/(>)[\s]*([<{])/g, '$1$2'],
|
||||
[/({[/:][a-z]+})[\s]*([<{])/g, '$1$2'],
|
||||
[/({[#:][a-z]+ .+?})[\s]*([<{])/g, '$1$2'],
|
||||
[/([>}])[\s]+(<|{[/#:][a-z][^}]*})/g, '$1$2'],
|
||||
],
|
||||
})
|
||||
|
||||
const pkgName = 'decode-named-character-reference'
|
||||
const resolveOptions = {
|
||||
alias: {
|
||||
// do not resolve `browser` field to make it work at SSR
|
||||
// https://github.com/vitejs/vite/issues/4405
|
||||
[pkgName]: resolveModule(pkgName),
|
||||
},
|
||||
}
|
||||
|
||||
const libraryConfig = defineProjectConfig({
|
||||
preset: {
|
||||
type: 'library',
|
||||
exports: {
|
||||
'.': './src/index.ts',
|
||||
},
|
||||
},
|
||||
build: {
|
||||
target: 'es2019', // nullish coalescing in es2020
|
||||
},
|
||||
resolve: resolveOptions,
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
setupFiles: path.resolve(rootDir, 'scripts/test-setup.ts'),
|
||||
},
|
||||
})
|
||||
|
||||
async function buildFilesForSvelte() {
|
||||
console.log('building svelte entry and helpers...')
|
||||
for (const [src, dest] of Object.entries({
|
||||
'src/helpers.ts': 'helpers.js',
|
||||
'src/index.ts': 'svelte-entry.js',
|
||||
})) {
|
||||
await vite.build({
|
||||
build: {
|
||||
emptyOutDir: false,
|
||||
lib: {
|
||||
entry: src,
|
||||
formats: ['es'],
|
||||
fileName(format) {
|
||||
if (format === 'es') return dest
|
||||
throw new Error('should not be here')
|
||||
},
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ['./helpers', /\.svelte$/],
|
||||
},
|
||||
},
|
||||
resolve: resolveOptions,
|
||||
})
|
||||
}
|
||||
|
||||
console.log('processing svelte files...')
|
||||
const files = await glob('src/*.svelte')
|
||||
for (let file of files) {
|
||||
const dest = file.replace('src/', 'dist/')
|
||||
await fs.ensureDir(path.dirname(dest))
|
||||
|
||||
if (fs.statSync(file).isDirectory()) return
|
||||
|
||||
if (file.endsWith('.svelte')) {
|
||||
const source = await fs.readFile(file, 'utf8')
|
||||
const item = await preprocess(source, sveltePreprocessor, {
|
||||
filename: file,
|
||||
})
|
||||
await fs.writeFile(
|
||||
dest,
|
||||
item.code.replace('<script lang="ts">', '<script>')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('processing style files (backward compatibility)...')
|
||||
await fs.move('dist/style.css', 'dist/index.css')
|
||||
await fs.copy('dist/index.css', 'dist/index.min.css')
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
projects: {
|
||||
'packages/bytemd': mergeProjectConfig(libraryConfig, {
|
||||
plugins: [
|
||||
svelte({
|
||||
preprocess: [sveltePreprocessor],
|
||||
}),
|
||||
{
|
||||
name: 'process-svelte-files',
|
||||
async closeBundle() {
|
||||
if (process.env.VITEST) return
|
||||
|
||||
await buildFilesForSvelte()
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
'packages/plugin-breaks': libraryConfig,
|
||||
'packages/plugin-frontmatter': libraryConfig,
|
||||
'packages/plugin-gemoji': libraryConfig,
|
||||
'packages/plugin-gfm': libraryConfig,
|
||||
'packages/plugin-highlight': mergeProjectConfig(libraryConfig, {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
globals: {
|
||||
'highlight.js': 'hljs',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
'packages/plugin-highlight-ssr': mergeProjectConfig(libraryConfig, {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
globals: {
|
||||
'highlight.js/lib/core': 'hljs',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
lowlight: 'lowlight/lib/common', // FIXME: tree-shaking
|
||||
},
|
||||
},
|
||||
}),
|
||||
'packages/plugin-math': libraryConfig,
|
||||
'packages/plugin-math-ssr': libraryConfig,
|
||||
'packages/plugin-medium-zoom': libraryConfig,
|
||||
'packages/plugin-mermaid': libraryConfig,
|
||||
'packages/react': libraryConfig,
|
||||
'packages/vue': mergeProjectConfig(libraryConfig, {
|
||||
...libraryConfig,
|
||||
plugins: [createVuePlugin()],
|
||||
}),
|
||||
'packages/vue-next': mergeProjectConfig(libraryConfig, {
|
||||
...libraryConfig,
|
||||
plugins: [vue()],
|
||||
}),
|
||||
playground: {
|
||||
preset: {
|
||||
type: 'web-app',
|
||||
},
|
||||
base: '/playground/',
|
||||
plugins: [
|
||||
svelte({
|
||||
preprocess: [sveltePreprocessor],
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
15
package.json
15
package.json
|
@ -3,26 +3,29 @@
|
|||
"version": "1.15.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "norm build bytemd '@bytemd/*'",
|
||||
"dev": "norm serve playground",
|
||||
"build": "tsc --build && pnpm --filter './packages/**' build",
|
||||
"dev": "pnpm --filter playground dev",
|
||||
"docs:build": "npx vitepress build docs",
|
||||
"docs:dev": "npx vitepress dev docs",
|
||||
"docs:serve": "npx vitepress serve docs",
|
||||
"format": "norm format",
|
||||
"format": "prettier --write '**/*.{ts,tsx,json,md,svelte}' && sort-package-json package.json 'packages/*/package.json'",
|
||||
"postinstall": "node scripts/postinstall.mjs && npm run format && sort-json packages/*/locales/*.json",
|
||||
"pub": "npm run build && norm version && pnpm --recursive --registry https://registry.npmjs.org/ publish --access public",
|
||||
"test": "norm test bytemd"
|
||||
},
|
||||
"prettier": {
|
||||
"pluginSearchDirs": [
|
||||
"."
|
||||
],
|
||||
"proseWrap": "never",
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
},
|
||||
"devDependencies": {
|
||||
"@norm/cli": "^0.4.43",
|
||||
"@sveltejs/vite-plugin-svelte": "1.0.0-next.47",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/svelte": "^3.1.2",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/lodash-es": "^4.17.6",
|
||||
"fast-glob": "^3.2.11",
|
||||
"fs-extra": "^10.1.0",
|
||||
|
@ -30,14 +33,16 @@
|
|||
"local-pkg": "^0.4.1",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mustache": "^4.2.0",
|
||||
"prettier": "^2.6.2",
|
||||
"prettier-plugin-svelte": "^2.7.0",
|
||||
"sass": "^1.52.2",
|
||||
"sort-json": "^2.0.1",
|
||||
"sort-package-json": "^1.57.0",
|
||||
"svelte": "^3.48.0",
|
||||
"svelte-preprocess": "^4.10.6",
|
||||
"svelte2tsx": "^0.5.10",
|
||||
"typescript": "^4.7.3",
|
||||
"vite": "^2.9.9"
|
||||
"vite": "3.0.0-alpha.9"
|
||||
},
|
||||
"packageManager": "pnpm@7.1.0",
|
||||
"bundlewatch": {
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
// @ts-check
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
import { preprocess } from 'svelte/compiler'
|
||||
import glob from 'fast-glob'
|
||||
import { build } from 'vite'
|
||||
import { resolveModule } from 'local-pkg'
|
||||
import sveltePreprocess from 'svelte-preprocess'
|
||||
|
||||
export const sveltePreprocessor = sveltePreprocess({
|
||||
typescript: true,
|
||||
// https://github.com/sveltejs/svelte/issues/189#issuecomment-586142198
|
||||
replace: [
|
||||
[/(>)[\s]*([<{])/g, '$1$2'],
|
||||
[/({[/:][a-z]+})[\s]*([<{])/g, '$1$2'],
|
||||
[/({[#:][a-z]+ .+?})[\s]*([<{])/g, '$1$2'],
|
||||
[/([>}])[\s]+(<|{[/#:][a-z][^}]*})/g, '$1$2'],
|
||||
],
|
||||
})
|
||||
|
||||
const pkgName = 'decode-named-character-reference'
|
||||
const resolveOptions = {
|
||||
alias: {
|
||||
// do not resolve `browser` field to make it work at SSR
|
||||
// https://github.com/vitejs/vite/issues/4405
|
||||
[pkgName]: resolveModule(pkgName),
|
||||
},
|
||||
}
|
||||
|
||||
async function buildFilesForSvelte() {
|
||||
console.log('building svelte entry and helpers...')
|
||||
for (const [src, dest] of Object.entries({
|
||||
'src/helpers.ts': 'helpers.js',
|
||||
'src/index.ts': 'svelte-entry.js',
|
||||
})) {
|
||||
await build({
|
||||
build: {
|
||||
emptyOutDir: false,
|
||||
lib: {
|
||||
entry: src,
|
||||
formats: ['es'],
|
||||
fileName(format) {
|
||||
if (format === 'es') return dest
|
||||
throw new Error('should not be here')
|
||||
},
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ['./helpers', /\.svelte$/],
|
||||
},
|
||||
},
|
||||
resolve: resolveOptions,
|
||||
})
|
||||
}
|
||||
|
||||
console.log('processing svelte files...')
|
||||
const files = await glob('src/*.svelte')
|
||||
for (let file of files) {
|
||||
const dest = file.replace('src/', 'dist/')
|
||||
await fs.ensureDir(path.dirname(dest))
|
||||
|
||||
if (fs.statSync(file).isDirectory()) return
|
||||
|
||||
if (file.endsWith('.svelte')) {
|
||||
const source = await fs.readFile(file, 'utf8')
|
||||
const item = await preprocess(source, sveltePreprocessor, {
|
||||
filename: file,
|
||||
})
|
||||
await fs.writeFile(
|
||||
dest,
|
||||
item.code.replace('<script lang="ts">', '<script>')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('processing style files (backward compatibility)...')
|
||||
await fs.move('dist/style.css', 'dist/index.css')
|
||||
await fs.copy('dist/index.css', 'dist/index.min.css')
|
||||
}
|
||||
|
||||
buildFilesForSvelte()
|
|
@ -26,12 +26,17 @@
|
|||
"./dist/index.min.css": "./dist/index.min.css"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"svelte": "./dist/svelte-entry.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/codemirror": "^5.60.5"
|
||||
},
|
||||
|
@ -56,6 +61,5 @@
|
|||
"unist-util-visit": "^4.1.0",
|
||||
"vfile": "^5.3.2",
|
||||
"word-count": "^0.2.2"
|
||||
},
|
||||
"svelte": "./dist/svelte-entry.js"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
import { sveltePreprocessor } from './build.mjs'
|
||||
|
||||
// nullish coalescing in es2020
|
||||
// TODO: 'decode-named-character-reference'
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
plugins: [
|
||||
svelte({
|
||||
preprocess: [sveltePreprocessor],
|
||||
}),
|
||||
],
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bytemd": "workspace:*",
|
||||
"remark-breaks": "^3.0.2"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"bytemd": "workspace:*",
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bytemd": "workspace:*",
|
||||
"remark-gemoji": "^7.0.1"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@icon-park/svg": "^1.4.0",
|
||||
"bytemd": "workspace:*",
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"highlight.js": "^11.5.1"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
// TODO: external, global name 'highlight.js/lib/core': 'hljs',
|
||||
// TODO: resolve lowlight: 'lowlight/lib/common', tree-shaking
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
minify: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"highlight.js": "^11.5.1"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@icon-park/svg": "^1.4.0",
|
||||
"bytemd": "workspace:*",
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/katex": "^0.14.0",
|
||||
"katex": "^0.15.6"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"medium-zoom": "^1.0.6"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/mermaid": "^8.2.9",
|
||||
"mermaid": "^9.1.1"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"bytemd": "workspace:*"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
})
|
|
@ -25,12 +25,16 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"bytemd": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^2.3.1",
|
||||
"vue": "^3.2.33"
|
||||
"vue": "^3.2.36"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.0.0"
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
plugins: [vue()],
|
||||
})
|
|
@ -25,6 +25,10 @@
|
|||
"dist",
|
||||
"locales"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsdv build",
|
||||
"dev": "tsdv watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"bytemd": "workspace:*"
|
||||
},
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export * from 'vite-plugin-vue2'
|
|
@ -0,0 +1,10 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'tsdv'
|
||||
|
||||
import { createVuePlugin } from 'vite-plugin-vue2'
|
||||
|
||||
export default defineConfig({
|
||||
target: 'es2019',
|
||||
tsc: false,
|
||||
plugins: [createVuePlugin()],
|
||||
})
|
|
@ -1,18 +0,0 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [1.15.0](https://github.com/bytedance/bytemd/compare/v1.14.0...v1.15.0) (2022-05-17)
|
||||
|
||||
## [1.14.0](https://github.com/bytedance/bytemd/compare/v1.13.1...v1.14.0) (2022-05-09)
|
||||
|
||||
### [1.13.1](https://github.com/bytedance/bytemd/compare/v1.13.0...v1.13.1) (2022-04-06)
|
||||
|
||||
## [1.13.0](https://github.com/bytedance/bytemd/compare/v1.12.4...v1.13.0) (2022-03-31)
|
||||
|
||||
### [1.12.4](https://github.com/bytedance/bytemd/compare/v1.12.3...v1.12.4) (2022-03-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **playground:** locales path ([97328dd](https://github.com/bytedance/bytemd/commit/97328dd5acb399a53a52f4a906dbb849e888fa83))
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"name": "playground",
|
||||
"version": "1.15.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@bytemd/plugin-breaks": "workspace:*",
|
||||
|
@ -17,5 +16,9 @@
|
|||
"github-markdown-css": "^5.1.0",
|
||||
"highlight.js": "^11.5.1",
|
||||
"katex": "^0.15.6"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
/// <reference types="@norm/cli/env" />
|
||||
/// <reference types="vite/client" />
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
import sveltePreprocess from 'svelte-preprocess'
|
||||
|
||||
const sveltePreprocessor = sveltePreprocess({
|
||||
typescript: true,
|
||||
// // https://github.com/sveltejs/svelte/issues/189#issuecomment-586142198
|
||||
// replace: [
|
||||
// [/(>)[\s]*([<{])/g, '$1$2'],
|
||||
// [/({[/:][a-z]+})[\s]*([<{])/g, '$1$2'],
|
||||
// [/({[#:][a-z]+ .+?})[\s]*([<{])/g, '$1$2'],
|
||||
// [/([>}])[\s]+(<|{[/#:][a-z][^}]*})/g, '$1$2'],
|
||||
// ],
|
||||
})
|
||||
|
||||
export default defineConfig({
|
||||
base: '/playground/',
|
||||
plugins: [
|
||||
svelte({
|
||||
preprocess: [sveltePreprocessor],
|
||||
}),
|
||||
],
|
||||
})
|
2224
pnpm-lock.yaml
2224
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -3,8 +3,8 @@ import fs from 'fs-extra'
|
|||
import path from 'path'
|
||||
import mustache from 'mustache'
|
||||
import _ from 'lodash-es'
|
||||
import { rootDir } from '../norm.config.mjs'
|
||||
import { createRequire } from 'module'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
function readFileSyncSafe(p) {
|
||||
try {
|
||||
|
@ -14,6 +14,9 @@ function readFileSyncSafe(p) {
|
|||
}
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/50052194
|
||||
const rootDir = path.resolve(fileURLToPath(import.meta.url), '../..')
|
||||
|
||||
const packagesDir = path.join(rootDir, 'packages')
|
||||
const packages = fs.readdirSync(packagesDir)
|
||||
const plugins = packages.filter((x) => x.startsWith('plugin-'))
|
||||
|
@ -31,6 +34,11 @@ packages.forEach((p) => {
|
|||
fs.writeJsonSync(tsconfig, c)
|
||||
})
|
||||
|
||||
fs.writeJsonSync('tsconfig.json', {
|
||||
files: [],
|
||||
references: packages.map((p) => ({ path: path.join('packages', p) })),
|
||||
})
|
||||
|
||||
packages.forEach((p) => {
|
||||
// license
|
||||
fs.copyFileSync(
|
||||
|
@ -63,6 +71,10 @@ packages.forEach((p) => {
|
|||
'./lib/locales/*': './locales/*',
|
||||
}
|
||||
pkg.files = ['dist', 'locales']
|
||||
pkg.scripts = {
|
||||
dev: 'tsdv watch',
|
||||
build: 'tsdv build',
|
||||
}
|
||||
|
||||
if (pkg.name === 'bytemd') {
|
||||
pkg.exports['./dist/index.css'] = './dist/index.css'
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "packages/bytemd" },
|
||||
{ "path": "packages/plugin-breaks" },
|
||||
{ "path": "packages/plugin-frontmatter" },
|
||||
{ "path": "packages/plugin-gemoji" },
|
||||
{ "path": "packages/plugin-gfm" },
|
||||
{ "path": "packages/plugin-highlight" },
|
||||
{ "path": "packages/plugin-highlight-ssr" },
|
||||
{ "path": "packages/plugin-math" },
|
||||
{ "path": "packages/plugin-math-ssr" },
|
||||
{ "path": "packages/plugin-medium-zoom" },
|
||||
{ "path": "packages/plugin-mermaid" },
|
||||
{ "path": "packages/react" },
|
||||
{ "path": "packages/vue" },
|
||||
{ "path": "packages/vue-next" }
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue