Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix WC regex for Windows #561

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading