cli: fix prepack and postpack commands CJS compat
Switch the prepack and postpack commands from using a direct dynamic import() to the execute.loader pattern, which properly handles CJS double-wrapping of module exports. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -215,20 +215,34 @@ export const buildPlugin = createCliPlugin({
|
||||
reg.addCommand({
|
||||
path: ['package', 'prepack'],
|
||||
description: 'Prepares a package for packaging before publishing',
|
||||
execute: async ({ args, info }) => {
|
||||
cli({ help: info }, undefined, args);
|
||||
const { pre } = await import('./commands/package/pack');
|
||||
await pre();
|
||||
execute: {
|
||||
loader: () =>
|
||||
import('./commands/package/pack').then(m => {
|
||||
const { pre } = (m as any).default ?? m;
|
||||
return {
|
||||
default: async ({ args, info }) => {
|
||||
cli({ help: info }, undefined, args);
|
||||
await pre();
|
||||
},
|
||||
};
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
reg.addCommand({
|
||||
path: ['package', 'postpack'],
|
||||
description: 'Restores the changes made by the prepack command',
|
||||
execute: async ({ args, info }) => {
|
||||
cli({ help: info }, undefined, args);
|
||||
const { post } = await import('./commands/package/pack');
|
||||
await post();
|
||||
execute: {
|
||||
loader: () =>
|
||||
import('./commands/package/pack').then(m => {
|
||||
const { post } = (m as any).default ?? m;
|
||||
return {
|
||||
default: async ({ args, info }) => {
|
||||
cli({ help: info }, undefined, args);
|
||||
await post();
|
||||
},
|
||||
};
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user