Skip to content

Commit

Permalink
ignore empty module rather than regarding it as { default: undefined }
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Empty modules are now simply ignored.
  • Loading branch information
uenoB committed Apr 4, 2024
1 parent 4e5918a commit dad49c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/vite-plugin-minissg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions packages/vite-plugin-minissg/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit dad49c3

Please sign in to comment.