Skip to content

Commit 90e2d21

Browse files
committed
[orga-build] fix dependency issue
1 parent e7e108b commit 90e2d21

File tree

6 files changed

+33
-46
lines changed

6 files changed

+33
-46
lines changed

packages/orga-build/lib/app.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import pages from '@orga-build/pages'
2-
import layouts from '@orga-build/layouts'
3-
import * as components from '@orga-build/components'
1+
import pages from '/@orga-build/pages'
2+
import layouts from '/@orga-build/layouts'
3+
import * as components from '/@orga-build/components'
44
import { Route, Switch, Link } from 'wouter'
55

66
export function App() {

packages/orga-build/lib/build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export async function build({
4040
build: {
4141
ssr: true,
4242
cssCodeSplit: false,
43+
emptyOutDir: true,
4344
rollupOptions: {
4445
input: fileURLToPath(new URL('./ssr.jsx', import.meta.url)),
4546
output: {
@@ -67,6 +68,7 @@ export async function build({
6768
plugins,
6869
build: {
6970
cssCodeSplit: false,
71+
emptyOutDir: true,
7072
rollupOptions: {
7173
input: fileURLToPath(new URL('./client.jsx', import.meta.url)),
7274
preserveEntrySignatures: 'allow-extension'

packages/orga-build/lib/ssr.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pages from '@orga-build/pages'
1+
import pages from '/@orga-build/pages'
22
import { renderToString } from 'react-dom/server'
33
import { App } from './app.jsx'
44
import { Router } from 'wouter'

packages/orga-build/lib/vite.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { setup } from './files.js'
22
import path from 'node:path'
33

4-
const magicModulePrefix = '@orga-build'
5-
const appEntryId = `/${magicModulePrefix}/main.js`
4+
const magicModulePrefix = '/@orga-build/'
5+
const pagesModuleId = magicModulePrefix + 'pages'
6+
const appEntryId = `${magicModulePrefix}main.js`
67

78
/**
89
* @param {Object} options
@@ -15,6 +16,19 @@ export function pluginFactory({ dir }) {
1516
return {
1617
name: 'vite-plugin-orga-pages',
1718
enforce: 'pre',
19+
config: (config, env) => ({
20+
optimizeDeps: {
21+
include: [
22+
'react',
23+
'react/jsx-runtime',
24+
'react-dom',
25+
'react-dom/client',
26+
'wouter'
27+
],
28+
exclude: ['orga-build']
29+
}
30+
}),
31+
1832
configureServer({ watcher, moduleGraph }) {
1933
const reloadVirtualModule = (/** @type {string} */ moduleId) => {
2034
const module = moduleGraph.getModuleById(moduleId)
@@ -27,8 +41,7 @@ export function pluginFactory({ dir }) {
2741
reloadVirtualModule('/')
2842
},
2943

30-
buildStart() {
31-
},
44+
buildStart() {},
3245

3346
async resolveId(id, importer) {
3447
if (id === appEntryId) {
@@ -40,13 +53,13 @@ export function pluginFactory({ dir }) {
4053
},
4154
async load(id) {
4255
if (id === appEntryId) {
43-
return `import "orga-build/csr.jsx";`
56+
return `import "orga-build/csr";`
4457
}
45-
if (id === `${magicModulePrefix}/pages`) {
58+
if (id === pagesModuleId) {
4659
return await renderPageList()
4760
}
48-
if (id.startsWith(`${magicModulePrefix}/pages/`)) {
49-
let pageId = id.replace(`${magicModulePrefix}/pages/`, '/')
61+
if (id.startsWith(pagesModuleId)) {
62+
let pageId = id.replace(pagesModuleId, '')
5063
const page = await files.page(pageId)
5164
if (page) {
5265
return `
@@ -56,7 +69,7 @@ export {default} from '${page.dataPath}';
5669
}
5770
}
5871

59-
if (id === `${magicModulePrefix}/layouts`) {
72+
if (id === `${magicModulePrefix}layouts`) {
6073
const layouts = await files.layouts()
6174
/** @type {string[]} */
6275
const imports = []
@@ -72,7 +85,7 @@ export default layouts;
7285
`
7386
}
7487

75-
if (id === `${magicModulePrefix}/components`) {
88+
if (id === `${magicModulePrefix}components`) {
7689
return await renderComponents()
7790
}
7891
}

packages/orga-build/package.json

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,18 @@
77
"orga-build": "./cli.js"
88
},
99
"scripts": {},
10-
"files": [
11-
"lib/",
12-
"cli.js",
13-
"index.js",
14-
"index.d.ts",
15-
"index.d.ts.map"
16-
],
10+
"files": ["lib/", "cli.js", "index.js", "index.d.ts", "index.d.ts.map"],
1711
"exports": {
1812
".": {
1913
"types": "./index.d.ts",
2014
"import": "./index.js"
2115
},
22-
"./csr.jsx": "./lib/csr.jsx"
16+
"./csr": "./lib/csr.jsx"
2317
},
24-
"keywords": [
25-
"orgajs",
26-
"org-mode",
27-
"build",
28-
"website",
29-
"react"
30-
],
18+
"keywords": ["orgajs", "org-mode", "build", "website", "react"],
3119
"author": "Xiaoxing Hu <[email protected]>",
3220
"license": "MIT",
3321
"dependencies": {
34-
"@orgajs/esbuild": "workspace:^",
35-
"@orgajs/node-loader": "workspace:^",
3622
"@orgajs/rollup": "workspace:*",
3723
"@vitejs/plugin-react": "^4.4.0",
3824
"esbuild": "^0.24.2",
@@ -44,13 +30,11 @@
4430
"wouter": "^3.7.0"
4531
},
4632
"devDependencies": {
47-
"@orgajs/orgx": "workspace:^",
4833
"@types/express": "^5.0.1",
4934
"@types/hast": "^3.0.4",
5035
"@types/node": "^22.13.1",
5136
"@types/react": "^19.0.8",
52-
"@types/react-dom": "^19.0.3",
53-
"orga": "workspace:^"
37+
"@types/react-dom": "^19.0.3"
5438
},
5539
"peerDependencies": {
5640
"react": "^19.0.0",

pnpm-lock.yaml

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)