Skip to content

Commit e8c64a2

Browse files
authored
fix: ensure Windows compatibility for block statements (#3)
1 parent c8af617 commit e8c64a2

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

__mocks__/Examples.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ export const MockNoInlineWithComponent = () => {
1010
return <>content</>
1111
}
1212

13-
return <DemoComponent />
13+
return (
14+
<div>
15+
<DemoComponent />
16+
</div>
17+
)
1418
}}
1519
</ComponentBox>
1620
)

__tests__/babelPluginReactLive.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ it('babelPluginReactLive', async () => {
4545
<ComponentBox data-test="id" noInline>{\`const DemoComponent = () => {
4646
return <>content</>
4747
}
48-
render(<DemoComponent />)
48+
render(
49+
<div>
50+
<DemoComponent />
51+
</div>
52+
)
4953
\`}</ComponentBox>
5054
)
5155
}

babelPluginReactLive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function babelPluginReactLive(babel, options) {
5858
if (currentReturnStatement === path.node) {
5959
const code = path
6060
.getSource()
61-
.replace(/return ((.|\n)*)/, 'render($1)')
61+
.replace(/return ((.|\n|\r)*)/, 'render($1)')
6262

6363
const node = t.identifier(code)
6464
path.replaceWith(node)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "git",
1414
"url": "https://github.com/dnbexperience/eufemia.git"
1515
},
16-
"version": "1.2.0",
16+
"version": "1.2.1",
1717
"main": "babelPluginReactLive.js",
1818
"scripts": {
1919
"test": "jest",

0 commit comments

Comments
 (0)