Skip to content

Commit

Permalink
fix(ssr-compiler): namespace and name should be optional in Component…
Browse files Browse the repository at this point in the history
…TransformOptions (#5058)
  • Loading branch information
cardoso authored Dec 18, 2024
1 parent dbce15f commit 57c1bd0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/@lwc/ssr-compiler/src/__tests__/estemplate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { is, builders as b } from 'estree-toolkit';
import { describe, test, expect } from 'vitest';
import { esTemplate, esTemplateWithYield } from '../estemplate';
import type { ClassDeclaration, FunctionDeclaration } from 'estree';

if (process.env.NODE_ENV !== 'production') {
// vitest seems to bypass the modifications we do in src/estree/validators.ts 🤷
Expand All @@ -33,7 +34,7 @@ describe.each(
test('when attempting to replace unreplaceable code constructs', () => {
// Someone might try to create a template where 'class' or 'function'
// is provided as an argument to the ES template.
const isFunctionOrClass = (node: any) =>
const isFunctionOrClass = (node: any): node is FunctionDeclaration | ClassDeclaration =>
is.functionDeclaration(node) || is.classDeclaration(node);
const createTemplate = () => topLevelFn`
${isFunctionOrClass} classOrFunctionDecl {}
Expand Down
4 changes: 3 additions & 1 deletion packages/@lwc/ssr-compiler/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export interface IHoistInstantiation {
}

export type TemplateTransformOptions = Pick<TemplateCompilerConfig, 'name' | 'namespace'>;
export type ComponentTransformOptions = Pick<LwcBabelPluginOptions, 'name' | 'namespace'> & {
export type ComponentTransformOptions = Partial<
Pick<LwcBabelPluginOptions, 'name' | 'namespace'>
> & {
// TODO [#5031]: Unify dynamicImports and experimentalDynamicComponent options
experimentalDynamicComponent?: LwcBabelPluginOptions['dynamicImports'];
};

0 comments on commit 57c1bd0

Please # to comment.