Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsedModules optional parameter to build function #2343

Open
jeshecdom opened this issue Mar 10, 2025 · 3 comments
Open

Add parsedModules optional parameter to build function #2343

jeshecdom opened this issue Mar 10, 2025 · 3 comments
Labels
kind: testing Tests (*.spec.ts)

Comments

@jeshecdom
Copy link
Contributor

We need to add parseModules optional parameter to build, like this:

export async function build(args: {
    config: Project;
    project: VirtualFileSystem;
    stdlib: string | VirtualFileSystem;
    logger?: ILogger;
    parser?: Parser;
    ast?: FactoryAst;
    parsedModules?: AstModule[]   <------- new optional parameter
}):

and then pass it to the precompile function as is.

We need to do this in order to avoid copying the code of build for compiling autogenerated ASTs. Copying the code of build can lead to bugs due to accidental omissions while copying or modifying (as I recently experienced in PR #2083). Also, code duplication can lead to unsynchronized code in different parts of the codebase.

@jeshecdom
Copy link
Contributor Author

Correct. Then, we need to extract the current code of build in an auxiliary function, and add two public accesses to it: one without parsedModules and one with it.

@jeshecdom
Copy link
Contributor Author

For the moment, keep the copied build function. See comment #2344 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: testing Tests (*.spec.ts)
Projects
None yet
Development

No branches or pull requests

2 participants