Skip to content

Commit dcb2b78

Browse files
committed
remove the tied dependency to @arrow-js
1 parent f15f529 commit dcb2b78

File tree

11 files changed

+26
-18
lines changed

11 files changed

+26
-18
lines changed

adex/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"exports": {
99
"./vite": "./src/vite.js",
1010
"./utils": "./src/utils.js",
11-
"./ssr": "./src/ssr.js",
12-
"./html": "./src/html.js",
13-
"./reactive": "./src/reactive.js"
11+
"./ssr": "./src/ssr.js"
1412
},
1513
"publishConfig": {
1614
"access": "public"

adex/src/html.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

adex/src/reactive.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

adex/src/runtime/client.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { html } from 'adex/html'
2-
31
const pageRoutes = import.meta.glob('./pages/**/*.page.{js,ts,jsx,tsx}')
2+
43
let mounterPath
4+
5+
render()
6+
57
async function render() {
68
const root = document.getElementById('root')
79
mounterPath = root.getAttribute('mounter')
@@ -12,15 +14,21 @@ async function render() {
1214
} catch (err) {
1315
console.error(err)
1416
}
15-
16-
const modImport: any = await pageRoutes[mounterPath]()
17+
const pathInPageMap = normalizePath(mounterPath)
18+
const modImport: any = await pageRoutes[pathInPageMap]()
1719
const Page = modImport.default
1820
const mountable = Page(loaderData)
1921
root.innerHTML = ''
2022
mountable(root)
2123
}
2224

23-
render()
25+
function normalizePath(path) {
26+
let result = String(path)
27+
if (/^[./][/]?/.test(result)) {
28+
result = result.replace(/^[./][/]?/, '')
29+
}
30+
return './' + result
31+
}
2432

2533
if (import.meta.hot) {
2634
import.meta.hot.accept(mounterPath, newModule => {

adex/src/runtime/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ async function buildHandler({ routes }) {
116116
loadedData = 'loader' in mod ? await mod.loader({ req }) : {}
117117
} catch (err) {
118118
throw new Error(
119-
`Failed to execute loader for url:\`${req.url}\` with page module: \`${hasMappedPage.path}\``
119+
`Failed to execute loader for url:\`${req.url}\` with page module: \`${hasMappedPage.relativePath}\``
120120
)
121121
}
122122
const str = renderToString(mod.default(loadedData))
123123
const html = buildTemplate({
124124
page: str,
125-
mounter: hasMappedPage.path,
125+
mounter: hasMappedPage.relativePath,
126126
clientEntry: clientEntryPath,
127127
prefillData: loadedData,
128128
})

adex/src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export { default as ms } from 'ms'
22
export { default as Youch } from 'youch'
3-
import { existsSync, readFileSync, statSync } from 'node:fs'
3+
import { existsSync, readFileSync } from 'node:fs'
44

55
import * as routeManifest from '@barelyhuman/fs-route-manifest'
6-
import { match } from 'path-to-regexp'
76
import { dirname, join } from 'node:path'
87
import { fileURLToPath } from 'node:url'
8+
import { match } from 'path-to-regexp'
99

1010
export const routerUtils = {
1111
...routeManifest,

playground/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"prettier": "@barelyhuman/prettier-config",
2121
"dependencies": {
22+
"@arrow-js/core": "1.0.0-alpha.9",
2223
"adex": "workspace:*"
2324
}
2425
}

playground/src/pages/dynamic/$$catch.page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html } from 'adex/html'
1+
import { html } from '@arrow-js/core'
22
export const loader = ({ req }) => {
33
return {
44
catch: req.params.catch,

playground/src/pages/hello/$name.page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html } from 'adex/html'
1+
import { html } from '@arrow-js/core'
22

33
export const loader = ({ req }) => {
44
console.log({

playground/src/pages/index.page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { reactive } from 'adex/reactive'
2-
import { html } from 'adex/html'
1+
import { reactive } from '@arrow-js/core'
2+
import { html } from '@arrow-js/core'
33

44
export const loader = async () => {
55
return {

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)