Skip to content

Commit

Permalink
Add support for importSource in TSX
Browse files Browse the repository at this point in the history
  • Loading branch information
KrofDrakula committed Jul 22, 2022
1 parent 856b9d5 commit 35f56f8
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 18 deletions.
6 changes: 4 additions & 2 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ module.exports = {
modules,
},
],
['@babel/preset-typescript'],
[
'@babel/preset-react',
{
pragma: 'h',
pragmaFrag: 'Fragment',
importSource: 'preact',
runtime: 'automatic',
},
],
'@babel/preset-flow',
],
env: { test: withTests },
},
Expand Down
2 changes: 1 addition & 1 deletion examples/preact-kitchen-sink/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
],
webpackFinal: (config) => {
config.module.rules.push({
test: [/\.stories\.js$/],
test: [/\.stories\.(js|ts|jsx|tsx)$/],
use: [require.resolve('@storybook/source-loader')],
include: [path.resolve(__dirname, '../src')],
enforce: 'pre',
Expand Down
1 change: 0 additions & 1 deletion examples/preact-kitchen-sink/src/Button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
/**
* The button component will render a clickable button
*/
Expand Down
1 change: 0 additions & 1 deletion examples/preact-kitchen-sink/src/React.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import React from 'react';
import PropTypes from 'prop-types';

Expand Down
2 changes: 0 additions & 2 deletions examples/preact-kitchen-sink/src/Welcome.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { h } from 'preact';

const Main = (props) => (
<article
{...props}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { useState } from 'preact/hooks';
import { action, actions } from '@storybook/addon-actions';
import Button from '../Button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import Button from '../Button';

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { linkTo } from '@storybook/addon-links';
import Button from '../Button';

Expand Down
1 change: 0 additions & 1 deletion examples/preact-kitchen-sink/src/stories/button.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { action } from '@storybook/addon-actions';
import Button from '../Button';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { ReactFunctionalComponent, ReactClassComponent } from '../React';

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { h } from 'preact';

const TestComponent = () => <div>This component should render OK.</div>;

export default TestComponent;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import TestComponent from './no-pragma';

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from 'preact';
import { linkTo } from '@storybook/addon-links';
import Welcome from '../Welcome';

Expand Down
5 changes: 3 additions & 2 deletions examples/preact-kitchen-sink/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"jsx": "preserve",
"jsx": "react-jsx",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
"jsxFragmentFactory": "Fragment",
"jsxImportSource": "preact"
}
}

0 comments on commit 35f56f8

Please sign in to comment.