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

Commit 30eac09

Browse files
committed
fix: fix circular imports dead loop
#89, #114
1 parent 7b32a00 commit 30eac09

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

server/app.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export class Appliaction {
134134
} else if (isRemote) {
135135
mod.loader = 'js'
136136
}
137+
this.#modules.set(url, mod)
137138
return mod
138139
}
139140

@@ -1189,10 +1190,6 @@ export class Appliaction {
11891190
}
11901191
}
11911192

1192-
if (!this.#modules.has(url)) {
1193-
this.#modules.set(url, mod)
1194-
}
1195-
11961193
return mod
11971194
}
11981195

@@ -1357,24 +1354,23 @@ export class Appliaction {
13571354
}
13581355

13591356
// create and copy polyfill
1360-
const polyfillMod = this.newModule('/polyfill.js')
13611357
const hash = (new Sha1).update(buildChecksum).update(AlephRuntimeCode).update(`${this.config.buildTarget}-${VERSION}`).hex()
13621358
const polyfillFile = path.join(this.buildDir, `polyfill.bundle.${util.shortHash(hash)}.js`)
1359+
const polyfillMod = this.newModule('/polyfill.js')
1360+
polyfillMod.hash = polyfillMod.sourceHash = hash
13631361
if (!existsFileSync(polyfillFile)) {
13641362
const rawPolyfillFile = `${alephPkgUrl}/compiler/polyfills/${this.config.buildTarget}/polyfill.js`
13651363
await this.runDenoBundle(rawPolyfillFile, polyfillFile, AlephRuntimeCode, true)
13661364
}
1367-
polyfillMod.hash = polyfillMod.sourceHash = hash
1368-
this.#modules.set(polyfillMod.url, polyfillMod)
13691365
log.info(` {} polyfill (${this.config.buildTarget.toUpperCase()}) ${colors.dim('• ' + util.formatBytes(Deno.statSync(polyfillFile).size))}`)
13701366

1371-
// bundle and copy page moudles
1372-
await Promise.all(pageModules.map(async mod => this.createPageBundle(mod, localSharedDeps)))
1373-
13741367
// create main.bundle.xxxxxxxxx.js
13751368
const mainModule = this.getModule('/main.ts')!
13761369
const bundleFile = path.join(this.buildDir, `main.bundle.${util.shortHash(mainModule.hash)}.js`)
13771370
await Deno.copyFile(mainModule.bundlingFile, bundleFile)
1371+
1372+
// bundle and copy page moudles
1373+
await Promise.all(pageModules.map(async mod => this.createPageBundle(mod, localSharedDeps)))
13781374
}
13791375

13801376
/** create chunk bundle. */
@@ -1389,7 +1385,6 @@ export class Appliaction {
13891385
] : []
13901386
}
13911387
}).flat().join('\n')
1392-
const mod = this.newModule(`/${name}.js`)
13931388
const hash = (new Sha1).update(buildChecksum).update(bundlingCode).hex()
13941389
const bundlingFile = path.join(this.buildDir, `${name}.bundling.js`)
13951390
const bundleFile = path.join(this.buildDir, `${name}.bundle.${util.shortHash(hash)}.js`)
@@ -1400,8 +1395,8 @@ export class Appliaction {
14001395
Deno.remove(bundlingFile)
14011396
}
14021397

1398+
const mod = this.newModule(`/${name}.js`)
14031399
mod.hash = mod.sourceHash = hash
1404-
this.#modules.set(mod.url, mod)
14051400

14061401
log.info(` {} ${name} ${colors.dim('• ' + util.formatBytes(Deno.statSync(bundleFile).size))}`)
14071402
}

0 commit comments

Comments
 (0)