Skip to content

Commit 1fcec8f

Browse files
committed
chore: 🤖 rollup jsx files
1 parent 91a5fca commit 1fcec8f

File tree

12 files changed

+95
-12
lines changed

12 files changed

+95
-12
lines changed

Diff for: dev/src/vite.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import globalPackageJson from '../../package.json' with { type: 'json' }
99

1010
const external = [/@milkdown/]
1111

12-
const libFileName = (format: string) => `index.${format}.js`
13-
1412
function isObject(item: unknown): item is Record<string, unknown> {
1513
return Boolean(item && typeof item === 'object' && !Array.isArray(item))
1614
}
@@ -53,7 +51,7 @@ function viteBuild(path: string, options: BuildOptions = {}): BuildOptions {
5351
lib: {
5452
entry: resolve(dir, 'src', 'index.ts'),
5553
name: `milkdown_${packageDirName}`,
56-
fileName: libFileName,
54+
fileName: 'index',
5755
formats: ['es'],
5856
},
5957
rollupOptions: {

Diff for: packages/components/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
"lib",
9898
"src"
9999
],
100+
"scripts": {
101+
"build": "rollup -c"
102+
},
100103
"peerDependencies": {
101104
"@codemirror/language": "^6",
102105
"@codemirror/state": "^6",

Diff for: packages/components/rollup.config.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import fs from 'node:fs'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import commonjs from '@rollup/plugin-commonjs'
5+
import json from '@rollup/plugin-json'
6+
import resolve from '@rollup/plugin-node-resolve'
7+
import esbuild from 'rollup-plugin-esbuild'
8+
9+
import pkg from './package.json' with { type: 'json' }
10+
11+
const external = [
12+
...Object.keys(pkg.dependencies),
13+
...Object.keys(pkg.peerDependencies || {}),
14+
/@milkdown\/prose/,
15+
]
16+
17+
const main = [
18+
{
19+
input: './src/index.ts',
20+
output: {
21+
file: 'lib/index.js',
22+
format: 'esm',
23+
sourcemap: true,
24+
},
25+
external,
26+
plugins: [
27+
resolve({ browser: true }),
28+
json(),
29+
commonjs(),
30+
esbuild({
31+
target: 'es6',
32+
}),
33+
],
34+
},
35+
]
36+
37+
function componentModule(name) {
38+
const input = `./src/${name}/index.ts`
39+
return [
40+
{
41+
input,
42+
output: {
43+
file: `lib/${name}/index.js`,
44+
format: 'esm',
45+
sourcemap: true,
46+
},
47+
external,
48+
plugins: [
49+
resolve({ browser: true }),
50+
json(),
51+
commonjs(),
52+
esbuild({
53+
target: 'es6',
54+
}),
55+
],
56+
},
57+
]
58+
}
59+
60+
const filename = fileURLToPath(import.meta.url)
61+
const dirname = path.dirname(filename)
62+
const dirs = fs.readdirSync(path.resolve(dirname, './src'))
63+
64+
export default () =>
65+
dirs
66+
.filter((x) => x !== '__internal__' && !x.includes('index'))
67+
.flatMap(componentModule)
68+
.concat(main)

Diff for: packages/components/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"jsxFactory": "h",
66
"jsxFragmentFactory": "Fragment",
77
"jsxImportSource": "vue",
8+
"emitDeclarationOnly": true,
89
"rootDir": "src",
910
"outDir": "lib",
1011
"tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo"

Diff for: packages/exception/vite.config.ts

-3
This file was deleted.

Diff for: packages/integrations/react/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
}
3131
}
3232
},
33+
"scripts": {
34+
"build": "vite build"
35+
},
3336
"files": [
3437
"lib",
3538
"src"

Diff for: packages/integrations/react/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"jsx": "react",
55
"rootDir": "src",
66
"outDir": "lib",
7+
"emitDeclarationOnly": true,
78
"tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo"
89
},
910
"include": ["src"],
File renamed without changes.

Diff for: packages/integrations/vue/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
}
3131
}
3232
},
33+
"scripts": {
34+
"build": "vite build"
35+
},
3336
"files": [
3437
"lib",
3538
"src"

Diff for: packages/integrations/vue/tsconfig.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"extends": "../../../tsconfig.json",
33
"compilerOptions": {
4-
"jsx": "preserve",
5-
"jsxFactory": "h",
6-
"jsxFragmentFactory": "Fragment",
4+
"jsx": "react-jsx",
5+
"jsxImportSource": "vue",
6+
"emitDeclarationOnly": true,
77
"rootDir": "src",
88
"outDir": "lib",
9-
"jsxImportSource": "vue",
109
"tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo"
1110
},
1211
"include": ["src"],

Diff for: packages/integrations/vue/vite.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { pluginViteConfig } from '@milkdown/dev/vite'
2+
import vueJsx from '@vitejs/plugin-vue-jsx'
3+
4+
export default pluginViteConfig(import.meta.url, {
5+
plugins: [vueJsx()],
6+
esbuild: {
7+
jsxFactory: 'h',
8+
jsxFragment: 'Fragment',
9+
},
10+
})

Diff for: packages/plugins/theme-nord/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
},
1818
"main": "./src/index.ts",
1919
"publishConfig": {
20-
"main": "./lib/index.es.js",
20+
"main": "./lib/index.js",
2121
"types": "./lib/index.d.ts",
2222
"exports": {
2323
".": {
2424
"types": "./lib/index.d.ts",
25-
"import": "./lib/index.es.js"
25+
"import": "./lib/index.js"
2626
},
2727
"./style.css": "./lib/style.css"
2828
}

0 commit comments

Comments
 (0)