-
Notifications
You must be signed in to change notification settings - Fork 229
Clean up module outputFile calculation and move it to the specifications #6967
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| import {createExtensionSpecification} from '../specification.js' | ||
| import {BaseSchema, MetafieldSchema} from '../schemas.js' | ||
| import {loadLocalesConfig} from '../../../utilities/extensions/locales-configuration.js' | ||
| import {ExtensionInstance} from '../extension-instance.js' | ||
| import {zod} from '@shopify/cli-kit/node/schema' | ||
| import {joinPath} from '@shopify/cli-kit/node/path' | ||
|
|
||
| const dependency = '@shopify/checkout-ui-extensions' | ||
|
|
||
| type CheckoutConfigType = zod.infer<typeof CheckoutSchema> | ||
| const CheckoutSchema = BaseSchema.extend({ | ||
| name: zod.string(), | ||
| extension_points: zod.array(zod.string()).optional(), | ||
|
|
@@ -22,6 +25,7 @@ const checkoutSpec = createExtensionSpecification({ | |
| 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`), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| deployConfig: async (config, directory) => { | ||
| return { | ||
| extension_points: config.extension_points, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import {createExtensionSpecification} from '../specification.js' | ||
| import {BaseSchema} from '../schemas.js' | ||
| import {loadLocalesConfig} from '../../../utilities/extensions/locales-configuration.js' | ||
| import {ExtensionInstance} from '../extension-instance.js' | ||
| import {zod} from '@shopify/cli-kit/node/schema' | ||
| import {joinPath} from '@shopify/cli-kit/node/path' | ||
| import {fileExists, readFile} from '@shopify/cli-kit/node/fs' | ||
|
|
@@ -88,6 +89,7 @@ const functionSpec = createExtensionSpecification({ | |
| schema: FunctionExtensionSchema, | ||
| appModuleFeatures: (_) => ['function'], | ||
| buildConfig: {mode: 'function'}, | ||
| getOutputFileName: (_extension: ExtensionInstance<FunctionConfigType>) => joinPath('dist', 'index.wasm'), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function spec returns Function |
||
| deployConfig: async (config, directory, apiKey) => { | ||
| let inputQuery: string | undefined | ||
| const moduleId = randomUUID() | ||
|
|
||
There was a problem hiding this comment.
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-instancefeels very overloaded today, and I worry we're overloading it further with things that might be optional properties.There was a problem hiding this comment.
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