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

Commit 961988a

Browse files
author
Je
committed
fix: fix import url on windows
1 parent 3ef285c commit 961988a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

project.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ export class Project {
265265
head: head,
266266
scripts: [
267267
data ? { type: 'application/json', innerText: JSON.stringify(data), id: 'ssr-data' } : '',
268-
{ src: path.join(baseUrl, `/_aleph/main.${mainModule.hash.slice(0, hashShort)}.js`), type: 'module' },
269-
{ src: path.join(baseUrl, `/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`), nomodule: true },
268+
{ src: util.cleanPath(`${baseUrl}/_aleph/main.${mainModule.hash.slice(0, hashShort)}.js`), type: 'module' },
269+
{ src: util.cleanPath(`${baseUrl}/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`), nomodule: true },
270270
...scripts
271271
],
272272
body,
@@ -283,8 +283,8 @@ export class Project {
283283
lang: defaultLocale,
284284
scripts: [
285285
customLoading?.data ? { type: 'application/json', innerText: JSON.stringify(customLoading?.data), id: 'ssr-data' } : '',
286-
{ src: path.join(baseUrl, `/_aleph/main.${mainModule.hash.slice(0, hashShort)}.js`), type: 'module' },
287-
{ src: path.join(baseUrl, `/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`), nomodule: true },
286+
{ src: util.cleanPath(`${baseUrl}/_aleph/main.${mainModule.hash.slice(0, hashShort)}.js`), type: 'module' },
287+
{ src: util.cleanPath(`${baseUrl}/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`), nomodule: true },
288288
],
289289
head: customLoading?.head || [],
290290
body: `<main>${customLoading?.body || ''}</main>`,
@@ -369,8 +369,8 @@ export class Project {
369369
head: head,
370370
scripts: [
371371
data ? { type: 'application/json', innerText: JSON.stringify(data), id: 'ssr-data' } : '',
372-
{ src: path.join(baseUrl, `/_aleph/main.${mainModule.hash.slice(0, hashShort)}.js`), type: 'module' },
373-
{ src: path.join(baseUrl, `/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`), nomodule: true },
372+
{ src: util.cleanPath(`${baseUrl}/_aleph/main.${mainModule.hash.slice(0, hashShort)}.js`), type: 'module' },
373+
{ src: util.cleanPath(`${baseUrl}/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`), nomodule: true },
374374
...scripts
375375
],
376376
body,
@@ -382,13 +382,13 @@ export class Project {
382382
const publicDir = path.join(this.appRoot, 'public')
383383
if (existsDirSync(publicDir)) {
384384
log.info(colors.bold('- Public Assets'))
385-
for await (const { path: p } of walk(publicDir, { includeDirs: false, skip: [/\/\.[^\/]+($|\/)/] })) {
385+
for await (const { path: p } of walk(publicDir, { includeDirs: false, skip: [/\.DS_Store$/] })) {
386386
const rp = util.trimPrefix(p, publicDir)
387387
const fp = path.join(outputDir, rp)
388388
const fi = await Deno.lstat(p)
389389
await ensureDir(path.dirname(fp))
390390
await Deno.copyFile(p, fp)
391-
log.info(' ✹', rp, colors.dim('•'), colorfulBytesString(fi.size))
391+
log.info(' ✹', rp.split('\\').join('/'), colors.dim('•'), colorfulBytesString(fi.size))
392392
}
393393
}
394394

@@ -595,13 +595,13 @@ export class Project {
595595

596596
if (existsDirSync(apiDir)) {
597597
for await (const { path: p } of walk(apiDir, walkOptions)) {
598-
const mod = await this._compile('/api' + util.trimPrefix(p, apiDir))
598+
const mod = await this._compile('/api' + util.trimPrefix(p, apiDir).split('\\').join('/'))
599599
this.#apiRouting.update(this._getRouteModule(mod))
600600
}
601601
}
602602

603603
for await (const { path: p } of walk(pagesDir, { ...walkOptions, exts: [...walkOptions.exts, '.jsx', '.tsx', '.md'] })) {
604-
const rp = util.trimPrefix(p, pagesDir)
604+
const rp = util.trimPrefix(p, pagesDir).split('\\').join('/')
605605
const mod = await this._compile('/pages' + rp)
606606
this.#routing.update(this._getRouteModule(mod))
607607
}
@@ -1228,7 +1228,7 @@ export class Project {
12281228
const modUrl = new URL(importer.url)
12291229
let pathname = url
12301230
if (!pathname.startsWith('/')) {
1231-
pathname = path.join(path.dirname(modUrl.pathname), url)
1231+
pathname = util.cleanPath(path.dirname(modUrl.pathname) + '/' + url)
12321232
}
12331233
const importUrl = new URL(modUrl.protocol + '//' + modUrl.host + pathname)
12341234
rewrittenURL = getRelativePath(
@@ -1248,7 +1248,7 @@ export class Project {
12481248
const sourceUrl = new URL(importer.url)
12491249
let pathname = url
12501250
if (!pathname.startsWith('/')) {
1251-
pathname = path.join(path.dirname(sourceUrl.pathname), url)
1251+
pathname = util.cleanPath(path.dirname(sourceUrl.pathname) + '/' + url)
12521252
}
12531253
importer.deps.push({
12541254
url: sourceUrl.protocol + '//' + sourceUrl.host + pathname,
@@ -1258,7 +1258,7 @@ export class Project {
12581258
})
12591259
} else {
12601260
importer.deps.push({
1261-
url: path.join(path.dirname(importer.url), url),
1261+
url: util.cleanPath(path.dirname(importer.url) + '/' + url),
12621262
hash: '',
12631263
async,
12641264
external: pluginsResolveRet?.external

0 commit comments

Comments
 (0)