From dad49c3732868307401f9713127a73cdab988a73 Mon Sep 17 00:00:00 2001 From: Katsuhiro Ueno Date: Fri, 5 Apr 2024 05:31:11 +0900 Subject: [PATCH] ignore empty module rather than regarding it as `{ default: undefined }` BREAKING CHANGE: Empty modules are now simply ignored. --- packages/vite-plugin-minissg/README.md | 4 ++-- packages/vite-plugin-minissg/src/module.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/vite-plugin-minissg/README.md b/packages/vite-plugin-minissg/README.md index 4641c09..85f8c4b 100644 --- a/packages/vite-plugin-minissg/README.md +++ b/packages/vite-plugin-minissg/README.md @@ -392,7 +392,7 @@ Intuitively: 1. A module may have `main` function that returns another module. This allows the module to delegate file generation to another - module. + module, which is possibly dynamically created. 2. A module may also have `default` value that gives Minissg the content of a destination file. The content can be given in several forms including string, @@ -414,7 +414,7 @@ Intuitively: See [Static Routing](#static-routing) section below for the details of name concatination. -Empty module is regarded as `{ default: undefined }`. +Empty modules are simply ignored. Through the `main` functions and mapping objects, the collection of modules constitute a tree structure. diff --git a/packages/vite-plugin-minissg/src/module.ts b/packages/vite-plugin-minissg/src/module.ts index 0ab13bb..2416fd8 100644 --- a/packages/vite-plugin-minissg/src/module.ts +++ b/packages/vite-plugin-minissg/src/module.ts @@ -115,8 +115,7 @@ export const run = async ( const context = { ...con, moduleName, module, path, parent: con } return { context: Object.freeze(context), loaded: newLoaded } }) - const subtrees = (await Promise.all(children)).filter(isNotNull) - return subtrees.length > 0 || children.length > 0 ? subtrees : null + return (await Promise.all(children)).filter(isNotNull) }, map: x => x, reduce: ({ context: con, loaded }, z) => {