Skip to content

Commit

Permalink
fix: fix WC regex for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca committed Oct 17, 2024
1 parent 9693d60 commit a93bcde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/brisa/src/utils/server-component-plugin/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ describe('utils', () => {
expect(out.dependencies).toBeEmpty();
});

it('should not add the action if is a web-component with Window separator', () => {
const wcPath = `${FIXTURES}\\web-components\\web-component.tsx`;
const code = `
export default function WebComponent() {
return <button onClick={() => console.log('clicked')}>click</button>;
}
`;
const allWebComponents = {
'web-component': wcPath,
};

const out = serverComponentPlugin(code, {
allWebComponents,
fileID: 'a1',
path: wcPath,
});
expect(out.hasActions).toBeFalse();
expect(out.dependencies).toBeEmpty();
});

it('should wrap the web-component to SSR wrapper when selectorToWrapDeclarativeShadowDom is true', () => {
const code = `
export default function WebComponent() {
Expand Down
2 changes: 1 addition & 1 deletion packages/brisa/src/utils/server-component-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ServerComponentPluginOptions = {
const { parseCodeToAST, generateCodeFromAST } = AST('tsx');
const JSX_NAME = new Set(['jsx', 'jsxDEV', 'jsxs']);
const SERVER_OUPUTS = new Set(['bun', 'node']);
const WEB_COMPONENT_REGEX = /.*\/web-components\/.*/;
const WEB_COMPONENT_REGEX = /.*[\/\\]web-components[\/\\].*/;
const FN_EXPRESSIONS = new Set([
'ArrowFunctionExpression',
'FunctionExpression',
Expand Down

0 comments on commit a93bcde

Please sign in to comment.