Skip to content

Commit 8e31dd9

Browse files
Copilothotlong
andcommitted
fix(cli): use dynamic import variable to avoid tsc resolution of optional @objectstack/service-i18n
The CLI package uses tsc (not tsup) for building, so a static string literal in `import('@objectstack/service-i18n')` causes TS2307 because the package isn't in CLI's dependencies. Using a variable indirection prevents tsc from attempting module resolution at compile time. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 32e46d0 commit 8e31dd9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/cli/src/commands/serve.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ export default class Serve extends Command {
220220
);
221221
if (!hasI18nPlugin && configHasTranslations) {
222222
try {
223-
const { I18nServicePlugin } = await import('@objectstack/service-i18n');
223+
// Dynamic import with variable to prevent tsc from resolving the optional package
224+
const i18nPkg = '@objectstack/service-i18n';
225+
const { I18nServicePlugin } = await import(/* webpackIgnore: true */ i18nPkg);
224226
const i18nCfg = config.i18n || config.manifest?.i18n || {};
225227
await kernel.use(new I18nServicePlugin({
226228
defaultLocale: i18nCfg.defaultLocale,

0 commit comments

Comments
 (0)