Open10
Deno 製フレームワーク Aleph.js を使ってみる
aleph.config.js
export default {
"ssr": false, // SPA mode
}
を試したらクライアントエラー
404 http://localhost:8080/_aleph/data/index.json
ドキュメントに書かれているのが最新バージョンではないのでレポジトリのタグを確認した方が良いかもしれない。
起動時に --allow-run
オプションが必要なのは、フロントエンド用の bundle をしているから。2回目の起動では bundle をスキップしてるっぽい。
deno run \
--allow-net=deno.land,codeload.github.com \
--allow-read=. \
--allow-write=. \
https://deno.land/x/aleph@v0.3.0-alpha.18/cli.ts \
init heroku-alephjs-example
deno run \
--allow-net=deno.land,esm.sh,:8080 \
--allow-read=.,$HOME/.deno/bin,$HOME/.cache/deno \
--allow-write=.,$HOME/.cache/deno \
--allow-env \
--allow-run \
https://deno.land/x/aleph@v0.3.0-alpha.18/cli.ts \
start
--no-check
option 付きで起動するとエラーになる。
その後、cache の影響で no-check
option がなくてもエラーになる?
base path は変更できる。
aleph.config.ts
import type { Config } from 'https://deno.land/x/aleph@v0.3.0-alpha.25/types.ts'
export default (): Config => ({
baseUrl: "/tool",
})
$ deno cache --reload https://deno.land/x/aleph@v0.3.0-alpha.32/framework/react/renderer.ts
Download ...
error: Import 'https://deno.land/x/aleph@v0.3.0-alpha.32/server/renderer.ts' failed: 404 Not Found
at https://deno.land/x/aleph@v0.3.0-alpha.32/framework/react/renderer.ts:4:0
$ deno cache --import-map import_map.json framework/react/renderer.ts
error: Cannot resolve module "file:///home/chiba/data/git/github.com/chibat/aleph.js/server/renderer.ts" from "file:///home/chiba/data/git/github.com/chibat/aleph.js/framework/react/renderer.ts".
at file:///home/chiba/data/git/github.com/chibat/aleph.js/framework/react/renderer.ts:4:0
$ git diff
diff --git a/framework/react/renderer.ts b/framework/react/renderer.ts
index 5c9c37a..8f9585b 100644
--- a/framework/react/renderer.ts
+++ b/framework/react/renderer.ts
@@ -1,7 +1,7 @@
import { createElement, ComponentType, ReactElement } from 'react'
import { renderToString } from 'react-dom/server'
import util from '../../shared/util.ts'
-import type { FrameworkRenderResult } from '../../server/renderer.ts'
+import type { FrameworkRenderResult } from '../../server/ssr.ts'
import type { RouterURL } from '../../types.ts'
import events from '../core/events.ts'
import { RouterContext, SSRContext } from './context.ts'
$ deno cache --reload https://deno.land/x/aleph@v0.3.0-alpha.32/framework/react/components/Router.ts
Download ...
error: Import 'https://deno.land/x/aleph@v0.3.0-alpha.32/framework/react/components/pageprops.ts' failed: 404 Not Found
at https://deno.land/x/aleph@v0.3.0-alpha.32/framework/react/components/Router.ts:16:0
$ deno cache --import-map import_map.json framework/react/components/Router.ts
error: Cannot resolve module "file:///home/chiba/data/git/github.com/chibat/aleph.js/framework/react/components/pageprops.ts" from "file:///home/chiba/data/git/github.com/chibat/aleph.js/framework/react/components/Router.ts".
at file:///home/chiba/data/git/github.com/chibat/aleph.js/framework/react/components/Router.ts:16:0
o framework/react/pageprops.ts
x framework/react/components/pageprops.ts
diff --git a/framework/react/components/Router.ts b/framework/react/components/Router.ts
index e758fcc..9db2e3c 100644
--- a/framework/react/components/Router.ts
+++ b/framework/react/components/Router.ts
@@ -13,7 +13,7 @@ import { isLikelyReactComponent } from '../helper.ts'
import { loadPageData } from '../pagedata.ts'
import { createPageProps } from '../pageprops.ts'
import { E400MissingComponent, E404Page, ErrorBoundary } from './ErrorBoundary.ts'
-import type { PageRoute } from './pageprops.ts'
+import type { PageRoute } from '../pageprops.ts'
$ git clone -b v0.3.0-alpha.32 git@github.com:alephjs/aleph.js.git
$ cd aleph.js/
$ deno cache --import-map import_map.json --reload framework/react/renderer.ts
Download ...
error: Cannot resolve module "file:///C:/Users/tomofumi/data/work/aleph.js/server/renderer.ts" from "file:///C:/Users/tomofumi/data/work/aleph.js/framework/react/renderer.ts".
at file:///C:/Users/tomofumi/data/work/aleph.js/framework/react/renderer.ts:4:0
$ deno cache --import-map import_map.json --reload framework/react/components/Router.ts
Download ..
error: Cannot resolve module "file:///C:/Users/tomofumi/data/work/aleph.js/framework/react/components/pageprops.ts" from "file:///C:/Users/tomofumi/data/work/aleph.js/framework/react/components/Router.ts".
at file:///C:/Users/tomofumi/data/work/aleph.js/framework/react/components/Router.ts:16:0