diff --git a/.changeset/angry-cycles-call.md b/.changeset/angry-cycles-call.md new file mode 100644 index 0000000000..e8db20b701 --- /dev/null +++ b/.changeset/angry-cycles-call.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Preserve directory structure for CommonJS build output, just like ESM. This makes the build output more stable and easier to browse, and allows for more effective tree shaking and lazy imports. diff --git a/packages/cli/src/lib/builder/config.ts b/packages/cli/src/lib/builder/config.ts index a11ffe8845..59e1cd57c3 100644 --- a/packages/cli/src/lib/builder/config.ts +++ b/packages/cli/src/lib/builder/config.ts @@ -123,6 +123,8 @@ export async function makeRollupConfigs( format: 'commonjs', interop: 'compat', sourcemap: true, + preserveModules: true, + preserveModulesRoot: `${targetDir}/src`, exports: 'named', }); }