Skip to content

Clean up module outputFile calculation and move it to the specifications#6967

Open
alfonso-noriega wants to merge 1 commit intomainfrom
03-10-clean_up_module_outputfile_calculation_and_move_it_to_the_specifications
Open

Clean up module outputFile calculation and move it to the specifications#6967
alfonso-noriega wants to merge 1 commit intomainfrom
03-10-clean_up_module_outputfile_calculation_and_move_it_to_the_specifications

Conversation

@alfonso-noriega
Copy link
Contributor

@alfonso-noriega alfonso-noriega commented Mar 10, 2026

WHY are these changes introduced?

The outputFileName property was previously calculated dynamically using a getter method that relied on the extension's build configuration mode. This approach was inflexible and didn't allow for extension-specific customization of output file names.

WHAT is this pull request doing?

  • Converts outputFileName from a computed getter to a direct property on ExtensionInstance
  • Adds an optional getOutputFileName method to the ExtensionSpecification interface
  • Implements getOutputFileName in all UI extension specifications to return ${extension.handle}.js
  • Implements getOutputFileName in function extensions to return index.wasm
  • Refactors the BuildConfig type to use a discriminated union for better type safety
  • Initializes outputFileName in the constructor using the specification's method or defaults to empty string

How to test your changes?

  1. Create extensions of different types (UI extensions, functions, etc.)
  2. Verify that the output file names are generated correctly for each extension type
  3. Test the build process to ensure extensions are built with the expected output file names
  4. Confirm that existing functionality remains unchanged

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@alfonso-noriega alfonso-noriega marked this pull request as ready for review March 10, 2026 10:30
@alfonso-noriega alfonso-noriega requested a review from a team as a code owner March 10, 2026 10:30
@github-actions
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

@binks-code-reviewer
Copy link

binks-code-reviewer bot commented Mar 10, 2026

🤖 Code Review · #projects-dev-ai for questions
React with 👍/👎 or reply — all feedback helps improve the agent.

Complete - No issues

📋 History

✅ No issues → ✅ 2 findings → ❌ Failed → ✅ No issues

@alfonso-noriega alfonso-noriega changed the base branch from 03-10-create_abstract_client_steps_infrastracture_to_externalize_the_ap_modules_client_configurations to graphite-base/6967 March 10, 2026 11:05
@alfonso-noriega alfonso-noriega force-pushed the 03-10-clean_up_module_outputfile_calculation_and_move_it_to_the_specifications branch from bbc0817 to 7b68eb7 Compare March 10, 2026 11:05
@alfonso-noriega alfonso-noriega changed the base branch from graphite-base/6967 to main March 10, 2026 11:05
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.83% 14480/18369
🟡 Branches 73.12% 7195/9840
🟡 Functions 79.09% 3702/4681
🟡 Lines 79.17% 13679/17278

Test suite run success

3791 tests passing in 1448 suites.

Report generated by 🧪jest coverage report action from ecf7d0f

@alfonso-noriega alfonso-noriega force-pushed the 03-10-clean_up_module_outputfile_calculation_and_move_it_to_the_specifications branch from 7b68eb7 to c3ee349 Compare March 10, 2026 11:24
schema: CheckoutSchema,
appModuleFeatures: (_) => ['ui_preview', 'cart_url', 'esbuild', 'single_js_entry_path', 'generates_source_maps'],
buildConfig: {mode: 'ui'},
getOutputFileName: (extension: ExtensionInstance<CheckoutConfigType>) => joinPath('dist', `${extension.handle}.js`),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist/dist/... path regression for UI extensions due to double dist/ prefix

getOutputFileName returns joinPath('dist', ${extension.handle}.js), which already includes dist/, while ExtensionInstance builds outputPath as joinPath(this.directory, 'dist', this.outputFileName ?? ''), producing .../<ext>/dist/dist/<handle>.js. This breaks expected artifact locations and later steps (upload/deploy/preview) that assume dist/<handle>.js.

schema: FunctionExtensionSchema,
appModuleFeatures: (_) => ['function'],
buildConfig: {mode: 'function'},
getOutputFileName: (_extension: ExtensionInstance<FunctionConfigType>) => joinPath('dist', 'index.wasm'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function spec returns dist/index.wasm, conflicting with existing function output path logic

Function getOutputFileName returns joinPath('dist', 'index.wasm'), but ExtensionInstance already has function-specific logic that expects the build path to include dist/index.wasm via config/defaultPath, and other code paths use this.outputFileName ?? '' directly. This can lead to inconsistent read/write locations and missing wasm artifacts depending on which path computation is used.

@alfonso-noriega alfonso-noriega force-pushed the 03-10-clean_up_module_outputfile_calculation_and_move_it_to_the_specifications branch from c3ee349 to 24fb214 Compare March 10, 2026 12:15
@alfonso-noriega alfonso-noriega force-pushed the 03-10-clean_up_module_outputfile_calculation_and_move_it_to_the_specifications branch from 24fb214 to ecf7d0f Compare March 10, 2026 12:41
} else {
return `${this.handle}.js`
}
return basename(this.specification.getOutputFileName?.(this) ?? '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all extension instances always have a build/output file name? extension-instance feels very overloaded today, and I worry we're overloading it further with things that might be optional properties.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change in this PR actually cleans this. Move the optional implementation to the specification, so each module can decide if it has an outputFileName or not.

This function already existed in extension-instance, but isntead of hardcoded if/else we move the ownership to each specification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants