Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 62af566

Browse files
committed
breaking: remove mod.ts and react.ts in project root
1 parent f16ecb2 commit 62af566

File tree

10 files changed

+39
-33
lines changed

10 files changed

+39
-33
lines changed

cli/init.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export default async function (nameArg?: string) {
6060
const importMap = {
6161
imports: {
6262
'~/': './',
63-
'aleph': `https://deno.land/x/aleph@v${VERSION}/mod.ts`,
64-
'aleph/': `https://deno.land/x/aleph@v${VERSION}/`,
63+
'framework': `https://deno.land/x/aleph@v${VERSION}/framework/core/mod.ts`,
64+
'framework:react': `https://deno.land/x/aleph@v${VERSION}/framework/react/mod.ts`,
6565
'react': `https://esm.sh/react@${defaultReactVersion}`,
6666
'react-dom': `https://esm.sh/react-dom@${defaultReactVersion}`,
6767
},

framework/core/mod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './redirect.ts'

framework/core/redirect.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import util from '../../shared/util.ts'
2+
import events from './events.ts'
3+
4+
export async function redirect(url: string, replace?: boolean) {
5+
const { location, history } = window as any
6+
7+
if (!util.isNEString(url)) {
8+
return
9+
}
10+
11+
if (util.isLikelyHttpURL(url) || url.startsWith('file://') || url.startsWith('mailto:')) {
12+
location.href = url
13+
return
14+
}
15+
16+
url = util.cleanPath(url)
17+
if (replace) {
18+
history.replaceState(null, '', url)
19+
} else {
20+
history.pushState(null, '', url)
21+
}
22+
events.emit('popstate', { type: 'popstate', resetScroll: true })
23+
}

framework/core/routing.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import util from '../../shared/util.ts'
22
import type { RouterURL } from '../../types.ts'
3-
import events from './events.ts'
3+
import { redirect } from './redirect.ts'
44

55
const ghostRoute: Route = { path: '', module: { url: '' } }
66

@@ -271,24 +271,3 @@ export function rewriteURL(reqUrl: string, baseURL: string, rewrites: Record<str
271271
}
272272
return url
273273
}
274-
275-
export async function redirect(url: string, replace?: boolean) {
276-
const { location, history } = window as any
277-
278-
if (!util.isNEString(url)) {
279-
return
280-
}
281-
282-
if (util.isLikelyHttpURL(url) || url.startsWith('file://') || url.startsWith('mailto:')) {
283-
location.href = url
284-
return
285-
}
286-
287-
url = util.cleanPath(url)
288-
if (replace) {
289-
history.replaceState(null, '', url)
290-
} else {
291-
history.pushState(null, '', url)
292-
}
293-
events.emit('popstate', { type: 'popstate', resetScroll: true })
294-
}

framework/react/mod.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './hooks.ts'
2+
export * from './hoc.ts'

import_map.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"imports": {
3-
"aleph": "https://deno.land/x/[email protected]/mod.ts",
4-
"aleph/": "https://deno.land/x/[email protected]/",
3+
"framework": "https://deno.land/x/[email protected]/framework/core/mod.ts",
4+
"framework:react": "https://deno.land/x/[email protected]/framework/react/mod.ts",
55
"react": "https://esm.sh/[email protected]",
66
"react-dom": "https://esm.sh/[email protected]"
77
}

mod.ts

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

publish.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// custom script for https://deno.land/x/publish
22

3+
import { defaultReactVersion } from './shared/constants.ts'
4+
35
export async function prepublish(version: string) {
46
const p = Deno.run({
57
cmd: ['deno', 'run', '-A', 'build.ts'],
@@ -12,8 +14,10 @@ export async function prepublish(version: string) {
1214
const data = await Deno.readTextFile('./import_map.json')
1315
const importMap = JSON.parse(data)
1416
Object.assign(importMap.imports, {
15-
'aleph': `https://deno.land/x/aleph@v${version}/mod.ts`,
16-
'aleph/': `https://deno.land/x/aleph@v${version}/`,
17+
'framework': `https://deno.land/x/aleph@v${version}/framework/core/mod.ts`,
18+
'framework:react': `https://deno.land/x/aleph@v${version}/framework/react/mod.ts`,
19+
'react': `https://esm.sh/react@${defaultReactVersion}`,
20+
'react-dom': `https://esm.sh/react-dom@${defaultReactVersion}`
1721
})
1822
await Deno.writeTextFile(
1923
'./import_map.json',

react.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

server/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ export async function loadImportMap(workingDir: string): Promise<ImportMap> {
137137
if (DEV_PORT) {
138138
const alephPkgUri = getAlephPkgUri()
139139
const imports = {
140-
'aleph': `${alephPkgUri}/mod.ts`,
141-
'aleph/': `${alephPkgUri}/`,
140+
'framework': `${alephPkgUri}/framework/core/mod.ts`,
141+
'framework:react': `${alephPkgUri}/framework/react/mod.ts`,
142142
'react': `https://esm.sh/react@${defaultReactVersion}`,
143143
'react-dom': `https://esm.sh/react-dom@${defaultReactVersion}`,
144144
}

0 commit comments

Comments
 (0)