From ad5a900cfaff419102b08fd72473e2cc3ab1a08f Mon Sep 17 00:00:00 2001 From: Bas Meeuwissen Date: Wed, 25 Dec 2024 13:45:24 +0100 Subject: [PATCH] #572: index resolution for resources and segments --- packages/build/src/source/resource/Reader.ts | 4 +++- packages/build/src/source/segment/Reader.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/build/src/source/resource/Reader.ts b/packages/build/src/source/resource/Reader.ts index f79dcc2e..9990fce1 100644 --- a/packages/build/src/source/resource/Reader.ts +++ b/packages/build/src/source/resource/Reader.ts @@ -43,7 +43,9 @@ export default class ResourceReader #makeResourceFilename(filename: string): string { - const fullFilename = this.#fileHelper.assureExtension(filename); + const fullFilename = this.#fileManager.isDirectory(filename) + ? `${filename}/index.js` + : this.#fileHelper.assureExtension(filename); if (fullFilename.startsWith('./')) return fullFilename.substring(2); if (fullFilename.startsWith('/')) return fullFilename.substring(1); diff --git a/packages/build/src/source/segment/Reader.ts b/packages/build/src/source/segment/Reader.ts index 38eb4d57..b10f361e 100644 --- a/packages/build/src/source/segment/Reader.ts +++ b/packages/build/src/source/segment/Reader.ts @@ -122,7 +122,9 @@ export default class SegmentReader #makeModuleFilename(filename: string): string { - const fullFilename = this.#fileHelper.assureExtension(filename); + const fullFilename = this.#fileManager.isDirectory(filename) + ? `${filename}/index.js` + : this.#fileHelper.assureExtension(filename); if (fullFilename.startsWith('./')) return fullFilename.substring(2); if (fullFilename.startsWith('/')) return fullFilename.substring(1);