[Feature] emit metafile for ui extensions to allow for bundle analyzation#6880
[Feature] emit metafile for ui extensions to allow for bundle analyzation#6880robin-drexler merged 1 commit intomainfrom
Conversation
Coverage report
Test suite run success3778 tests passing in 1448 suites. Report generated by 🧪jest coverage report action from 9ca669c |
45adc01 to
3a602b1
Compare
3a602b1 to
e8b32cc
Compare
| esbuildOptions.sourcemap = true | ||
| esbuildOptions.sourceRoot = `${options.stdin.resolveDir}/src` | ||
| } | ||
| if (options.environment === 'production') { |
There was a problem hiding this comment.
Question for reviewers. Do we even ever run this not in production mode? Could we just always emit the metafile?
There was a problem hiding this comment.
Should we actually make this a feature like generates_source_maps?
There was a problem hiding this comment.
Yes to the production question, check the callers of getESBuildOptions, when called from app-watcher-esbuild it is called in development mode, because that's from the dev session flow.
Do we want to generate metafiles only when deploying? or also when deving? is there any performance hit by doing it?
I don't think we need to convert this into a feature, it makes sense to want to this for every esbuild extension.
There was a problem hiding this comment.
Do we want to generate metafiles only when deploying?
I think only doing it for prod builds is ok for now.
This comment has been minimized.
This comment has been minimized.
e8b32cc to
9bfb95a
Compare
ede0bc4 to
0464cd9
Compare
|
@dmerand @isaacroldan thanks for your reviews. I have hopefully addressed all your concerns. Could give this another go, please? 🙏 |
db48137 to
ed8e13d
Compare
c8c5db8 to
db55333
Compare
|
@isaacroldan #6880 (comment) seems fine to me since we're only adding a new function. Would you agree? Also curious why those changes need to be backwards compatible? 🤔 |
0a6738d to
ab6e111
Compare
|
🤖 Code Review · #projects-dev-ai for questions ✅ Complete - No issues 📋 History✅ No issues → ✅ No issues → ✅ No issues |
c24b28d to
e6e4c3b
Compare
e6e4c3b to
9ca669c
Compare
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/path.d.ts import type { URL } from 'url';
/**
* Joins a list of paths together.
*
* @param paths - Paths to join.
* @returns Joined path.
*/
export declare function joinPath(...paths: string[]): string;
/**
* Normalizes a path.
*
* @param path - Path to normalize.
* @returns Normalized path.
*/
export declare function normalizePath(path: string): string;
/**
* Resolves a list of paths together.
*
* @param paths - Paths to resolve.
* @returns Resolved path.
*/
export declare function resolvePath(...paths: string[]): string;
/**
* Returns the relative path from one path to another.
*
* @param from - Path to resolve from.
* @param to - Path to resolve to.
* @returns Relative path.
*/
export declare function relativePath(from: string, to: string): string;
/**
* Returns whether the path is absolute.
*
* @param path - Path to check.
* @returns Whether the path is absolute.
*/
export declare function isAbsolutePath(path: string): boolean;
/**
* Returns the directory name of a path.
*
* @param path - Path to get the directory name of.
* @returns Directory name.
*/
export declare function dirname(path: string): string;
/**
* Returns the base name of a path.
*
* @param path - Path to get the base name of.
* @param ext - Optional extension to remove from the result.
* @returns Base name.
*/
export declare function basename(path: string, ext?: string): string;
/**
* Returns the extension of the path.
*
* @param path - Path to get the extension of.
* @returns Extension.
*/
export declare function extname(path: string): string;
/**
+ * Parses a path into its components (root, dir, base, ext, name).
+ *
+ * @param path - Path to parse.
+ * @returns Parsed path object.
+ */
+export declare function parsePath(path: string): {
+ root: string;
+ dir: string;
+ base: string;
+ ext: string;
+ name: string;
+};
+/**
* Given an absolute filesystem path, it makes it relative to
* the current working directory. This is useful when logging paths
* to allow the users to click on the file and let the OS open it
* in the editor of choice.
*
* @param path - Path to relativize.
* @param dir - Current working directory.
* @returns Relativized path.
*/
export declare function relativizePath(path: string, dir?: string): string;
/**
* Given 2 paths, it returns whether the second path is a subpath of the first path.
*
* @param mainPath - The main path.
* @param subpath - The subpath.
* @returns Whether the subpath is a subpath of the main path.
*/
export declare function isSubpath(mainPath: string, subpath: string): boolean;
/**
* Given a module's import.meta.url it returns the directory containing the module.
*
* @param moduleURL - The value of import.meta.url in the context of the caller module.
* @returns The path to the directory containing the caller module.
*/
export declare function moduleDirectory(moduleURL: string | URL): string;
/**
* When running a script using `npm run`, something interesting happens. If the current
* folder does not have a `package.json` or a `node_modules` folder, npm will traverse
* the directory tree upwards until it finds one. Then it will run the script and set
* `process.cwd()` to that folder, while the actual path is stored in the INIT_CWD
* environment variable (see here: https://docs.npmjs.com/cli/v9/commands/npm-run-script#description).
*
* @returns The path to the current working directory.
*/
export declare function cwd(): string;
/**
* Tries to get the value of the `--path` argument, if provided.
*
* @param argv - The arguments to search for the `--path` argument.
* @returns The value of the `--path` argument, if provided.
*/
export declare function sniffForPath(argv?: string[]): string | undefined;
/**
* Returns whether the `--json` or `-j` flags are present in the arguments.
*
* @param argv - The arguments to search for the `--json` and `-j` flags.
* @returns Whether the `--json` or `-j` flag is present in the arguments.
*/
export declare function sniffForJson(argv?: string[]): boolean;
|
WHY are these changes introduced?
Shopify imposes strict bundle size limits on extensions and functions to ensure great performance. Starting with the 2025-10 version, these limits have been decreased even further to 64kb compressed for ui extensions.
Bundle size can be impacted by different factors, such as large dependencies or inline assets.
However, we are not making it easy to understand why a bundle might exceeding these limits.
See https://shopify.slack.com/archives/C05E3BDFDRB/p1771618346307599 for context
WHAT is this pull request doing?
When
buildfor ui extensions runs, the CLI now emits a metafile for each of them in the extension'sdist/folder.That metafile can then be analyzed by tools like https://esbuild.github.io/analyze/ or locally via tools like https://github.com/btd/esbuild-visualizer
How to test your changes?
pnpm shopify app build --path=/path/to/your/appinside the cli repo/path/to/your/appls extensions/**/dist/*.metafile.jsonPost-release steps
We will mention the metafile in docs like here: https://shopify.dev/docs/api/checkout-ui-extensions/2025-10/upgrading-to-2025-10#file-size-limit
Checklist