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

Commit fe9c913

Browse files
committed
Improve url resolve
1 parent 1461098 commit fe9c913

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

server/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { basename, join } from 'https://deno.land/[email protected]/path/mod.ts'
21
import { bold } from 'https://deno.land/[email protected]/fmt/colors.ts'
2+
import { basename, join } from 'https://deno.land/[email protected]/path/mod.ts'
33
import type { ImportMap, ReactResolve } from '../compiler/mod.ts'
44
import { defaultReactVersion } from '../shared/constants.ts'
5-
import { existsFileSync, existsDirSync } from '../shared/fs.ts'
5+
import { existsDirSync, existsFileSync } from '../shared/fs.ts'
66
import log from '../shared/log.ts'
77
import util from '../shared/util.ts'
88
import type { Config, CSSOptions, PostCSSPlugin } from '../types.ts'
@@ -33,7 +33,7 @@ export const defaultConfig: Readonly<RequiredConfig> = {
3333
env: {},
3434
react: {
3535
version: defaultReactVersion,
36-
esmShBuildVersion: 39,
36+
esmShBuildVersion: 40,
3737
}
3838
}
3939

server/ssr.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { basename, dirname } from 'https://deno.land/[email protected]/path/mod.ts'
12
import { createBlankRouterURL, RouteModule } from '../framework/core/routing.ts'
2-
import { dirname, basename } from 'https://deno.land/[email protected]/path/mod.ts'
33
import log from '../shared/log.ts'
44
import util from '../shared/util.ts'
55
import type { RouterURL } from '../types.ts'
@@ -98,12 +98,12 @@ export class Renderer {
9898
const isDev = this.#app.isDev
9999
const state = { entryFile: '' }
100100
const appModule = this.#app.findModuleByName('app')
101-
const { default: App } = appModule ? await import(`file://${appModule.jsFile}#${appModule.hash.slice(0, 6)}`) : {} as any
101+
const { default: App } = appModule ? await import(`file://${appModule.jsFile}#${appModule.hash.slice(0, 8)}`) : {} as any
102102
const nestedPageComponents = await Promise.all(nestedModules
103103
.filter(({ url }) => this.#app.getModule(url) !== null)
104104
.map(async ({ url }) => {
105105
const { jsFile, hash } = this.#app.getModule(url)!
106-
const { default: Component } = await import(`file://${jsFile}#${hash.slice(0, 6)}`)
106+
const { default: Component } = await import(`file://${jsFile}#${hash.slice(0, 8)}`)
107107
state.entryFile = dirname(url) + '/' + basename(jsFile)
108108
return {
109109
url,
@@ -158,8 +158,8 @@ export class Renderer {
158158
async render404Page(url: RouterURL): Promise<string> {
159159
const appModule = this.#app.findModuleByName('app')
160160
const e404Module = this.#app.findModuleByName('404')
161-
const { default: App } = appModule ? await import(`file://${appModule.jsFile}#${appModule.hash.slice(0, 6)}`) : {} as any
162-
const { default: E404 } = e404Module ? await import(`file://${e404Module.jsFile}#${e404Module.hash.slice(0, 6)}`) : {} as any
161+
const { default: App } = appModule ? await import(`file://${appModule.jsFile}#${appModule.hash.slice(0, 8)}`) : {} as any
162+
const { default: E404 } = e404Module ? await import(`file://${e404Module.jsFile}#${e404Module.hash.slice(0, 8)}`) : {} as any
163163
const styles = await this.lookupStyleModules(...[
164164
appModule ? appModule.url : [],
165165
e404Module ? e404Module.url : []
@@ -198,7 +198,7 @@ export class Renderer {
198198
const loadingModule = this.#app.findModuleByName('loading')
199199

200200
if (loadingModule) {
201-
const { default: Loading } = await import(`file://${loadingModule.jsFile}#${loadingModule.hash.slice(0, 6)}`)
201+
const { default: Loading } = await import(`file://${loadingModule.jsFile}#${loadingModule.hash.slice(0, 8)}`)
202202
const styles = await this.lookupStyleModules(loadingModule.url)
203203
const {
204204
head,
@@ -238,7 +238,7 @@ export class Renderer {
238238

239239
private async lookupStyleModules(...urls: string[]): Promise<Record<string, string>> {
240240
return (await Promise.all(this.#app.lookupStyleModules(...urls).map(async ({ jsFile, hash }) => {
241-
const { default: { __url$: url, __css$: css } } = await import(`file://${jsFile}#${hash.slice(0, 6)}`)
241+
const { default: { __url$: url, __css$: css } } = await import(`file://${jsFile}#${hash.slice(0, 8)}`)
242242
return { url, css }
243243
}))).reduce((styles, mod) => {
244244
styles[mod.url] = mod.css

0 commit comments

Comments
 (0)