-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15572c7
commit de289ad
Showing
8 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { genAllPublicUtils, Module, Project, publicGenPath } from "../../project/mod.ts"; | ||
import { camelify } from "../../types/case_conversions.ts"; | ||
import { GeneratedCodeBuilder } from "./mod.ts"; | ||
|
||
export async function compileModulePublicUtilsHelper( | ||
project: Project, | ||
module: Module, | ||
) { | ||
const reexport = new GeneratedCodeBuilder(publicGenPath(project, module)); | ||
const utilsPath = reexport.relative(genAllPublicUtils(project)); | ||
|
||
for (const dependency of Object.keys(module.config.dependencies || {})) { | ||
reexport.append` | ||
// Reexports public utils for ${dependency} | ||
export { ${camelify(dependency)} } from ${JSON.stringify(utilsPath)}; | ||
`; | ||
} | ||
|
||
await reexport.write(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { genAllPublicUtils, genModulePublicUtils, Project, publicPath } from "../../project/mod.ts"; | ||
import { GeneratedCodeBuilder } from "./mod.ts"; | ||
import { camelify } from "../../types/case_conversions.ts"; | ||
import { exists } from "../../deps.ts"; | ||
|
||
export async function compilePublicUtilsHelpers(project: Project) { | ||
const allPublicUtils = new GeneratedCodeBuilder(genAllPublicUtils(project)); | ||
|
||
for (const module of project.modules.values()) { | ||
const reexporter = new GeneratedCodeBuilder(genModulePublicUtils(project, module), 2); | ||
|
||
// If it exists, reexport the `public.ts` file for this module | ||
if (await exists(publicPath(module), { isFile: true })) { | ||
reexporter.append` | ||
export * from ${JSON.stringify(reexporter.relative(publicPath(module)))}; | ||
`; | ||
} | ||
|
||
// Export the module's name as a constant | ||
reexporter.append`export const __CANONICAL_MODULE_NAME = "${module.name}";`; | ||
|
||
await reexporter.write(); | ||
} | ||
|
||
// Generate the `all.ts` file | ||
for (const module of project.modules.values()) { | ||
const importPath = allPublicUtils.relative( | ||
genModulePublicUtils( | ||
project, | ||
module, | ||
), | ||
); | ||
// Export the module's public utils under the module's name | ||
allPublicUtils.append` | ||
// Public utils for ${module.name} | ||
export * as ${camelify(module.name)} from ${JSON.stringify(importPath)}; | ||
`; | ||
} | ||
|
||
await allPublicUtils.write(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters